get_library_songs, get_library_upload_songs: fix empty result for libraries containing exactly 1 song

This commit is contained in:
sigma67 2023-12-18 20:34:36 +01:00
commit 8f7970b264
No known key found for this signature in database
GPG key ID: 1C314227DF0103D0
2 changed files with 13 additions and 3 deletions

View file

@ -75,11 +75,18 @@ 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 len(results) >= 2:
results.pop(0)
def parse_library_songs(response):
results = get_library_contents(response, MUSIC_SHELF)
pop_songs_random_mix(results['contents'])
return {
'results': results,
'parsed': parse_playlist_items(results['contents'][1:]) if results else results
'parsed': parse_playlist_items(results['contents']) if results else results
}