Feature: add likeStatus to get_watch_playlist (closes #148)
This commit is contained in:
parent
dbb2e90961
commit
7b20fcec12
2 changed files with 16 additions and 5 deletions
|
|
@ -12,6 +12,10 @@ class WatchMixin:
|
|||
Get a watch list of tracks. This watch playlist appears when you press
|
||||
play on a track in YouTube Music.
|
||||
|
||||
Please note that the `INDIFFERENT` likeStatus of tracks returned by this
|
||||
endpoint may be either `INDIFFERENT` or `DISLIKE`, due to ambiguous data
|
||||
returned by YouTube Music.
|
||||
|
||||
:param videoId: videoId of the played video
|
||||
:param playlistId: playlistId of the played playlist or album
|
||||
:param limit: minimum number of watch playlist items to return
|
||||
|
|
@ -34,7 +38,9 @@ class WatchMixin:
|
|||
"width": 400,
|
||||
"height": 225
|
||||
}
|
||||
]
|
||||
],
|
||||
"feedbackTokens": [],
|
||||
"likeStatus": "LIKE"
|
||||
},...
|
||||
],
|
||||
"lyrics": "MPLYt_HNNclO0Ddoc-17"
|
||||
|
|
|
|||
|
|
@ -10,11 +10,15 @@ def parse_watch_playlist(results):
|
|||
if 'unplayableText' in data:
|
||||
continue
|
||||
|
||||
feedback_tokens = None
|
||||
feedback_tokens = like_status = None
|
||||
for item in nav(data, MENU_ITEMS):
|
||||
if 'toggleMenuServiceItemRenderer' in item:
|
||||
feedback_tokens = parse_song_menu_tokens(item)
|
||||
break
|
||||
service = item['toggleMenuServiceItemRenderer']['defaultServiceEndpoint']
|
||||
if 'feedbackEndpoint' in service:
|
||||
feedback_tokens = parse_song_menu_tokens(item)
|
||||
if 'likeEndpoint' in service:
|
||||
status = ['LIKE', 'INDIFFERENT']
|
||||
like_status = status[status.index(service['likeEndpoint']['status']) - 1]
|
||||
|
||||
runs = data['longBylineText']['runs']
|
||||
last_artist_index = get_last_artist_index(runs)
|
||||
|
|
@ -29,7 +33,8 @@ def parse_watch_playlist(results):
|
|||
'length': nav(data, ['lengthText', 'runs', 0, 'text']),
|
||||
'playlistId': nav(data, NAVIGATION_PLAYLIST_ID),
|
||||
'thumbnail': nav(data, THUMBNAIL),
|
||||
'feedbackTokens': feedback_tokens
|
||||
'feedbackTokens': feedback_tokens,
|
||||
'likeStatus': like_status
|
||||
}
|
||||
tracks.append(track)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue