Merge branch 'collaborative-playlists' of git://github.com/nforro/ytmusicapi into nforro-collaborative-playlists
This commit is contained in:
commit
31d0e88730
2 changed files with 18 additions and 18 deletions
|
|
@ -89,7 +89,7 @@ def parse_albums(results):
|
||||||
return albums
|
return albums
|
||||||
|
|
||||||
|
|
||||||
def parse_playlist_items(results, owned=False):
|
def parse_playlist_items(results):
|
||||||
songs = []
|
songs = []
|
||||||
count = 1
|
count = 1
|
||||||
for result in results:
|
for result in results:
|
||||||
|
|
@ -101,21 +101,21 @@ def parse_playlist_items(results, owned=False):
|
||||||
try:
|
try:
|
||||||
# if playlist is not owned, the playlist item can't be interacted with
|
# if playlist is not owned, the playlist item can't be interacted with
|
||||||
videoId = setVideoId = None
|
videoId = setVideoId = None
|
||||||
if owned:
|
|
||||||
for item in nav(data, MENU_ITEMS):
|
# if item is not playable, there is no videoId
|
||||||
if 'menuServiceItemRenderer' in item and 'playlistEditEndpoint' in nav(
|
if 'playNavigationEndpoint' in nav(data, PLAY_BUTTON):
|
||||||
item, MENU_SERVICE):
|
videoId = nav(
|
||||||
setVideoId = nav(
|
data, PLAY_BUTTON)['playNavigationEndpoint']['watchEndpoint']['videoId']
|
||||||
item, MENU_SERVICE)['playlistEditEndpoint']['actions'][0]['setVideoId']
|
|
||||||
videoId = nav(
|
for item in nav(data, MENU_ITEMS):
|
||||||
item,
|
if 'menuServiceItemRenderer' in item and 'playlistEditEndpoint' in nav(
|
||||||
MENU_SERVICE)['playlistEditEndpoint']['actions'][0]['removedVideoId']
|
item, MENU_SERVICE):
|
||||||
break
|
setVideoId = nav(
|
||||||
else:
|
item, MENU_SERVICE)['playlistEditEndpoint']['actions'][0]['setVideoId']
|
||||||
# if item is not playable, there is no videoId
|
|
||||||
if 'playNavigationEndpoint' in nav(data, PLAY_BUTTON):
|
|
||||||
videoId = nav(
|
videoId = nav(
|
||||||
data, PLAY_BUTTON)['playNavigationEndpoint']['watchEndpoint']['videoId']
|
item,
|
||||||
|
MENU_SERVICE)['playlistEditEndpoint']['actions'][0]['removedVideoId']
|
||||||
|
break
|
||||||
|
|
||||||
title = get_item_text(data, 0)
|
title = get_item_text(data, 0)
|
||||||
if title == 'Song deleted':
|
if title == 'Song deleted':
|
||||||
|
|
@ -138,7 +138,7 @@ def parse_playlist_items(results, owned=False):
|
||||||
song = {'videoId': videoId, 'title': title, 'artists': artists, 'album': album}
|
song = {'videoId': videoId, 'title': title, 'artists': artists, 'album': album}
|
||||||
if duration:
|
if duration:
|
||||||
song['duration'] = duration
|
song['duration'] = duration
|
||||||
if owned:
|
if setVideoId:
|
||||||
song['setVideoId'] = setVideoId
|
song['setVideoId'] = setVideoId
|
||||||
|
|
||||||
songs.append(song)
|
songs.append(song)
|
||||||
|
|
|
||||||
|
|
@ -739,13 +739,13 @@ class YTMusic:
|
||||||
playlist['tracks'] = []
|
playlist['tracks'] = []
|
||||||
|
|
||||||
if song_count > 0:
|
if song_count > 0:
|
||||||
playlist['tracks'].extend(parse_playlist_items(results['contents'], own_playlist))
|
playlist['tracks'].extend(parse_playlist_items(results['contents']))
|
||||||
songs_to_get = min(limit, song_count)
|
songs_to_get = min(limit, song_count)
|
||||||
|
|
||||||
if 'continuations' in results:
|
if 'continuations' in results:
|
||||||
request_func = lambda additionalParams: self.__send_request(
|
request_func = lambda additionalParams: self.__send_request(
|
||||||
endpoint, body, additionalParams)
|
endpoint, body, additionalParams)
|
||||||
parse_func = lambda contents: parse_playlist_items(contents, own_playlist)
|
parse_func = lambda contents: parse_playlist_items(contents)
|
||||||
playlist['tracks'].extend(
|
playlist['tracks'].extend(
|
||||||
get_continuations(results, 'musicPlaylistShelfContinuation', 100, songs_to_get,
|
get_continuations(results, 'musicPlaylistShelfContinuation', 100, songs_to_get,
|
||||||
request_func, parse_func))
|
request_func, parse_func))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue