Handle unplayable items in search results (closes #123)
This commit is contained in:
parent
27024f34f7
commit
c110ea71ff
1 changed files with 7 additions and 4 deletions
|
|
@ -28,7 +28,8 @@ class Parser:
|
||||||
|
|
||||||
if resultType in ['song', 'video']:
|
if resultType in ['song', 'video']:
|
||||||
search_result['videoId'] = nav(
|
search_result['videoId'] = nav(
|
||||||
data, PLAY_BUTTON)['playNavigationEndpoint']['watchEndpoint']['videoId']
|
data, PLAY_BUTTON + ['playNavigationEndpoint', 'watchEndpoint', 'videoId'],
|
||||||
|
True)
|
||||||
search_result['title'] = get_item_text(data, 0)
|
search_result['title'] = get_item_text(data, 0)
|
||||||
|
|
||||||
if resultType in ['artist', 'album', 'playlist']:
|
if resultType in ['artist', 'album', 'playlist']:
|
||||||
|
|
@ -69,10 +70,12 @@ class Parser:
|
||||||
'name': runs[last_artist_index + 2]['text'],
|
'name': runs[last_artist_index + 2]['text'],
|
||||||
'id': nav(runs[last_artist_index + 2], NAVIGATION_BROWSE_ID)
|
'id': nav(runs[last_artist_index + 2], NAVIGATION_BROWSE_ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
search_result['duration'] = runs[-1]['text']
|
search_result['duration'] = runs[-1]['text']
|
||||||
toggle_menu = find_object_by_key(nav(data, MENU_ITEMS),
|
if 'menu' in data:
|
||||||
'toggleMenuServiceItemRenderer')
|
toggle_menu = find_object_by_key(nav(data, MENU_ITEMS),
|
||||||
search_result['feedbackTokens'] = parse_song_menu_tokens(toggle_menu)
|
'toggleMenuServiceItemRenderer')
|
||||||
|
search_result['feedbackTokens'] = parse_song_menu_tokens(toggle_menu)
|
||||||
|
|
||||||
elif resultType in ['video']:
|
elif resultType in ['video']:
|
||||||
search_result['artist'] = get_item_text(data, 1, 0 + default_offset)
|
search_result['artist'] = get_item_text(data, 1, 0 + default_offset)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue