Merge remote-tracking branch 'origin/master' into jcbirdwell-alt_auth

This commit is contained in:
sigma67 2023-12-31 11:34:14 +01:00
commit 90af0c7a5a
No known key found for this signature in database
GPG key ID: 1C314227DF0103D0
3 changed files with 24 additions and 8 deletions

View file

@ -120,14 +120,19 @@ class BrowsingMixin:
""" """
Get information about an artist and their top releases (songs, Get information about an artist and their top releases (songs,
albums, singles, videos, and related artists). The top lists albums, singles, videos, and related artists). The top lists
contain pointers for getting the full list of releases. For contain pointers for getting the full list of releases.
songs/videos, pass the browseId to :py:func:`get_playlist`.
For albums/singles, pass browseId and params to :py:func: For songs/videos, pass the browseId to :py:func:`get_playlist`.
`get_artist_albums`. For albums/singles, pass browseId and params to :py:func:`get_artist_albums`.
:param channelId: channel id of the artist :param channelId: channel id of the artist
:return: Dictionary with requested information. :return: Dictionary with requested information.
.. warning::
The returned channelId is not the same as the one passed to the function.
It should be used only with :py:func:`subscribe_artists`.
Example:: Example::
{ {
@ -243,7 +248,7 @@ class BrowsingMixin:
""" """
Get the full list of an artist's albums or singles Get the full list of an artist's albums or singles
:param channelId: channel Id of the artist :param channelId: browseId of the artist as returned by :py:func:`get_artist`
:param params: params obtained by :py:func:`get_artist` :param params: params obtained by :py:func:`get_artist`
:return: List of albums in the format of :py:func:`get_library_albums`, :return: List of albums in the format of :py:func:`get_library_albums`,
except artists key is missing. except artists key is missing.

View file

@ -7,13 +7,15 @@ from ._utils import validate_order_parameter, prepare_order_params
from ytmusicapi.helpers import * from ytmusicapi.helpers import *
from ytmusicapi.navigation import * from ytmusicapi.navigation import *
from ytmusicapi.continuations import get_continuations from ytmusicapi.continuations import get_continuations
from ytmusicapi.parsers.library import parse_library_albums, parse_library_artists, get_library_contents from ytmusicapi.parsers.library import parse_library_albums, parse_library_artists, get_library_contents, \
pop_songs_random_mix
from ytmusicapi.parsers.albums import parse_album_header from ytmusicapi.parsers.albums import parse_album_header
from ytmusicapi.parsers.uploads import parse_uploaded_items from ytmusicapi.parsers.uploads import parse_uploaded_items
from ..auth.types import AuthType from ..auth.types import AuthType
class UploadsMixin: class UploadsMixin:
def get_library_upload_songs(self, limit: int = 25, order: str = None) -> List[Dict]: def get_library_upload_songs(self, limit: int = 25, order: str = None) -> List[Dict]:
""" """
Returns a list of uploaded songs Returns a list of uploaded songs
@ -47,7 +49,8 @@ class UploadsMixin:
results = get_library_contents(response, MUSIC_SHELF) results = get_library_contents(response, MUSIC_SHELF)
if results is None: if results is None:
return [] return []
songs = parse_uploaded_items(results['contents'][1:]) pop_songs_random_mix(results)
songs = parse_uploaded_items(results['contents'])
if 'continuations' in results: if 'continuations' in results:
request_func = lambda additionalParams: self._send_request( request_func = lambda additionalParams: self._send_request(

View file

@ -75,11 +75,19 @@ def parse_library_artists(response, request_func, limit):
return artists return artists
def pop_songs_random_mix(results) -> None:
"""remove the random mix that conditionally appears at the start of library songs"""
if results:
if len(results['contents']) >= 2:
results['contents'].pop(0)
def parse_library_songs(response): def parse_library_songs(response):
results = get_library_contents(response, MUSIC_SHELF) results = get_library_contents(response, MUSIC_SHELF)
pop_songs_random_mix(results)
return { return {
'results': results, 'results': results,
'parsed': parse_playlist_items(results['contents'][1:]) if results else results 'parsed': parse_playlist_items(results['contents']) if results else results
} }