Resend request when ytm returns invalid per_page count for get_library_songs

This commit is contained in:
czifumasa 2020-08-01 14:32:55 +02:00
commit e4325938a2
3 changed files with 80 additions and 12 deletions

View file

@ -1,3 +1,4 @@
from .playlists import parse_playlist_items
from .utils import *
@ -75,3 +76,13 @@ def parse_library_artists(response, request_func, limit):
request_func, parse_func))
return artists
def parse_library_songs(response):
results = find_object_by_key(nav(response, SINGLE_COLUMN_TAB + SECTION_LIST),
'itemSectionRenderer')
results = nav(results, ITEM_SECTION)
if 'musicShelfRenderer' not in results:
return []
results = results['musicShelfRenderer']
return {'results': results, 'parsed': parse_playlist_items(results['contents'][1:])}