Update behavior of get_lyrics to match YouTube API
This commit is contained in:
parent
3de9b5e4e8
commit
bfbbcc5859
3 changed files with 7 additions and 12 deletions
|
|
@ -101,11 +101,8 @@ class TestYTMusic(unittest.TestCase):
|
|||
self.assertIsNotNone(lyrics_song["lyrics"])
|
||||
self.assertIsNotNone(lyrics_song["source"])
|
||||
|
||||
playlist = youtube.get_watch_playlist("9TnpB8WgW4s")
|
||||
no_lyrics_song = youtube.get_lyrics(playlist["lyrics"])
|
||||
self.assertFalse(no_lyrics_song["lyricsFound"])
|
||||
self.assertIsNotNone(no_lyrics_song["lyrics"])
|
||||
self.assertIsNotNone(no_lyrics_song["source"])
|
||||
browseId = youtube.get_watch_playlist("9TnpB8WgW4s")
|
||||
self.assertIsNone(browseId)
|
||||
|
||||
###############
|
||||
# WATCH
|
||||
|
|
|
|||
|
|
@ -683,9 +683,5 @@ class BrowsingMixin:
|
|||
'musicDescriptionShelfRenderer']['description']['runs'][0]['text']
|
||||
lyrics['source'] = response['contents']['sectionListRenderer']['contents'][0][
|
||||
'musicDescriptionShelfRenderer']['footer']['runs'][0]['text']
|
||||
else:
|
||||
lyrics['lyricsFound'] = False
|
||||
lyrics['lyrics'] = response['contents']['messageRenderer']['subtext'][
|
||||
'messageSubtextRenderer']['text']['runs'][0]['text']
|
||||
lyrics['source'] = response['contents']['messageRenderer']['text']['runs'][0]['text']
|
||||
|
||||
return lyrics
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class WatchMixin:
|
|||
])
|
||||
|
||||
lyrics_browse_id = None
|
||||
if len(watchNextRenderer['tabs']) > 1:
|
||||
if 'unselectable' not in watchNextRenderer['tabs'][1]['tabRenderer']:
|
||||
lyrics_browse_id = watchNextRenderer['tabs'][1]['tabRenderer']['endpoint'][
|
||||
'browseEndpoint']['browseId']
|
||||
|
||||
|
|
@ -82,7 +82,9 @@ class WatchMixin:
|
|||
|
||||
return {'tracks': tracks, 'lyrics': lyrics_browse_id}
|
||||
|
||||
def get_watch_playlist_shuffle(self, playlistId: str = None, limit=50) -> Dict[List[Dict], str]:
|
||||
def get_watch_playlist_shuffle(self,
|
||||
playlistId: str = None,
|
||||
limit=50) -> Dict[List[Dict], str]:
|
||||
"""
|
||||
Shuffle any playlist
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue