Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into jcbirdwell-alt_auth
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma67 committed Dec 31, 2023
2 parents c848e50 + e85ce83 commit 90af0c7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
15 changes: 10 additions & 5 deletions ytmusicapi/mixins/browsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,19 @@ def get_artist(self, channelId: str) -> Dict:
"""
Get information about an artist and their top releases (songs,
albums, singles, videos, and related artists). The top lists
contain pointers for getting the full list of releases. For
songs/videos, pass the browseId to :py:func:`get_playlist`.
For albums/singles, pass browseId and params to :py:func:
`get_artist_albums`.
contain pointers for getting the full list of releases.
For songs/videos, pass the browseId to :py:func:`get_playlist`.
For albums/singles, pass browseId and params to :py:func:`get_artist_albums`.
:param channelId: channel id of the artist
: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::
{
Expand Down Expand Up @@ -243,7 +248,7 @@ def get_artist_albums(self, channelId: str, params: str) -> List[Dict]:
"""
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`
:return: List of albums in the format of :py:func:`get_library_albums`,
except artists key is missing.
Expand Down
7 changes: 5 additions & 2 deletions ytmusicapi/mixins/uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
from ytmusicapi.helpers import *
from ytmusicapi.navigation import *
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.uploads import parse_uploaded_items
from ..auth.types import AuthType


class UploadsMixin:

def get_library_upload_songs(self, limit: int = 25, order: str = None) -> List[Dict]:
"""
Returns a list of uploaded songs
Expand Down Expand Up @@ -47,7 +49,8 @@ def get_library_upload_songs(self, limit: int = 25, order: str = None) -> List[D
results = get_library_contents(response, MUSIC_SHELF)
if results is None:
return []
songs = parse_uploaded_items(results['contents'][1:])
pop_songs_random_mix(results)
songs = parse_uploaded_items(results['contents'])

if 'continuations' in results:
request_func = lambda additionalParams: self._send_request(
Expand Down
10 changes: 9 additions & 1 deletion ytmusicapi/parsers/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,19 @@ def parse_library_artists(response, request_func, limit):
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):
results = get_library_contents(response, MUSIC_SHELF)
pop_songs_random_mix(results)
return {
'results': results,
'parsed': parse_playlist_items(results['contents'][1:]) if results else results
'parsed': parse_playlist_items(results['contents']) if results else results
}


Expand Down

0 comments on commit 90af0c7

Please sign in to comment.