Parse setVideoId for unplayable items (closes #83)
This commit is contained in:
parent
b40ca2d6bf
commit
14daa31ab1
1 changed files with 11 additions and 7 deletions
|
|
@ -12,22 +12,26 @@ def parse_playlist_items(results, menu_entries: List[List] = None):
|
||||||
data = result['musicResponsiveListItemRenderer']
|
data = result['musicResponsiveListItemRenderer']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# if playlist is not owned, the playlist item can't be interacted with
|
|
||||||
videoId = setVideoId = None
|
videoId = setVideoId = None
|
||||||
like = None
|
like = None
|
||||||
|
|
||||||
# if item is not playable, there is no videoId
|
# if the item has a menu, find its setVideoId
|
||||||
if 'playNavigationEndpoint' in nav(data, PLAY_BUTTON):
|
if 'menu' in data:
|
||||||
videoId = nav(data,
|
for item in reversed(nav(data, MENU_ITEMS)):
|
||||||
PLAY_BUTTON)['playNavigationEndpoint']['watchEndpoint']['videoId']
|
|
||||||
|
|
||||||
for item in nav(data, MENU_ITEMS):
|
|
||||||
if 'menuServiceItemRenderer' in item and 'playlistEditEndpoint' in nav(
|
if 'menuServiceItemRenderer' in item and 'playlistEditEndpoint' in nav(
|
||||||
item, MENU_SERVICE):
|
item, MENU_SERVICE):
|
||||||
setVideoId = nav(
|
setVideoId = nav(
|
||||||
item, MENU_SERVICE)['playlistEditEndpoint']['actions'][0]['setVideoId']
|
item, MENU_SERVICE)['playlistEditEndpoint']['actions'][0]['setVideoId']
|
||||||
|
videoId = nav(
|
||||||
|
item,
|
||||||
|
MENU_SERVICE)['playlistEditEndpoint']['actions'][0]['removedVideoId']
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# if item is not playable, the videoId was retrieved above
|
||||||
|
if 'playNavigationEndpoint' in nav(data, PLAY_BUTTON):
|
||||||
|
videoId = nav(data,
|
||||||
|
PLAY_BUTTON)['playNavigationEndpoint']['watchEndpoint']['videoId']
|
||||||
|
|
||||||
if 'menu' in data:
|
if 'menu' in data:
|
||||||
like = nav(data, MENU_LIKE_STATUS, True)
|
like = nav(data, MENU_LIKE_STATUS, True)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue