Fix search edge case for song results with no duration

This commit is contained in:
sigma67 2021-02-01 11:10:37 +01:00
commit a45e872d16
No known key found for this signature in database
GPG key ID: 1545A01D4474BAF0
2 changed files with 9 additions and 5 deletions

View file

@ -25,8 +25,8 @@ def get_last_artist_index(runs):
return next(
len(runs) - i - 1 for i, run in enumerate(reversed(runs))
if 'navigationEndpoint' in run and
(nav(run, NAVIGATION_BROWSE_ID).startswith('UC') or
nav(run, NAVIGATION_BROWSE_ID).startswith('FEmusic_library_privately_owned_artist')))
(nav(run, NAVIGATION_BROWSE_ID).startswith('UC') or nav(
run, NAVIGATION_BROWSE_ID).startswith('FEmusic_library_privately_owned_artist')))
except StopIteration: # try to find album if no artist IDs available
if 'navigationEndpoint' in runs[-3] or runs[-3]['text'].endswith('views'): # has album
return len(runs) - 5
@ -45,7 +45,8 @@ def parse_song_album(data, index):
def parse_song_album_runs(runs, last_artist_index):
if len(runs) - last_artist_index == 5: # has album
if len(runs) > last_artist_index + 1 and type(
runs[last_artist_index + 2]) is dict: # has album
return {
'name': runs[last_artist_index + 2]['text'],
'id': nav(runs[last_artist_index + 2], NAVIGATION_BROWSE_ID, True)