From 1ba6c97f5ab52c0515818eaef6c0fde905e10495 Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Thu, 23 May 2024 13:20:34 +0200 Subject: [PATCH] feat: more extensive browse id --- music_kraken/pages/youtube_music/youtube_music.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/music_kraken/pages/youtube_music/youtube_music.py b/music_kraken/pages/youtube_music/youtube_music.py index 3dc8fc9..794b05a 100644 --- a/music_kraken/pages/youtube_music/youtube_music.py +++ b/music_kraken/pages/youtube_music/youtube_music.py @@ -549,6 +549,11 @@ class YoutubeMusic(SuperYouTube): return album def fetch_lyrics(self, video_id: str, playlist_id: str = None) -> str: + """ + 1. fetches the tabs of a song, to get the browse id + 2. finds the browse id of the lyrics + 3. fetches the lyrics with the browse id + """ request_data = { "context": {**self.credentials.context, "adSignalsInfo": {"params": []}}, "videoId": video_id, @@ -575,7 +580,8 @@ class YoutubeMusic(SuperYouTube): pageType = traverse_json_path(tab, "tabRenderer.endpoint.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType", default="") if pageType in ("MUSIC_TAB_TYPE_LYRICS", "MUSIC_PAGE_TYPE_TRACK_LYRICS") or "lyrics" in pageType.lower(): browse_id = traverse_json_path(tab, "tabRenderer.endpoint.browseEndpoint.browseId", default=None) - break + if browse_id is not None: + break if browse_id is None: return None