diff --git a/src/music_kraken/pages/youtube_music/_list_render.py b/src/music_kraken/pages/youtube_music/_list_render.py index 2813b12..1acecee 100644 --- a/src/music_kraken/pages/youtube_music/_list_render.py +++ b/src/music_kraken/pages/youtube_music/_list_render.py @@ -29,7 +29,6 @@ def music_card_shelf_renderer(renderer: dict) -> List[DatabaseObject]: def music_responsive_list_item_flex_column_renderer(renderer: dict) -> List[DatabaseObject]: return parse_run_list(renderer.get("text", {}).get("runs", [])) - def music_responsive_list_item_renderer(renderer: dict) -> List[DatabaseObject]: results = [] @@ -68,7 +67,6 @@ def music_responsive_list_item_renderer(renderer: dict) -> List[DatabaseObject]: return results - def music_shelf_renderer(renderer: dict) -> List[DatabaseObject]: result = [] for subrenderer in renderer.get("contents"): @@ -76,12 +74,20 @@ def music_shelf_renderer(renderer: dict) -> List[DatabaseObject]: return result +def music_carousel_shelf_renderer(renderer: dict): + return music_shelf_renderer(renderer=renderer) + +def music_two_row_item_renderer(renderer: dict): + return parse_run_list(renderer.get("title", {}).get("runs", [])) + RENDERER_PARSERS = { "musicCardShelfRenderer": music_card_shelf_renderer, "musicResponsiveListItemRenderer": music_responsive_list_item_renderer, "musicResponsiveListItemFlexColumnRenderer": music_responsive_list_item_flex_column_renderer, "musicShelfRenderer": music_card_shelf_renderer, + "musicCarouselShelfRenderer": music_carousel_shelf_renderer, + "musicTwoRowItemRenderer": music_two_row_item_renderer, "itemSectionRenderer": lambda _: [], } diff --git a/src/music_kraken/pages/youtube_music/youtube_music.py b/src/music_kraken/pages/youtube_music/youtube_music.py index 08568ea..8b46a9b 100644 --- a/src/music_kraken/pages/youtube_music/youtube_music.py +++ b/src/music_kraken/pages/youtube_music/youtube_music.py @@ -65,7 +65,7 @@ class YoutubeMusicConnection(Connection): value=cookie_value, path='/', domain='.youtube.com' ) - # self.start_heartbeat() + def heartbeat(self): r = self.get("https://music.youtube.com/verify_session", is_heartbeat=True) @@ -291,6 +291,18 @@ class YoutubeMusic(SuperYouTube): for i, content in enumerate(renderer_list): dump_to_file(f"{i}-artists-renderer.json", json.dumps(content), is_json=True, exit_after_dump=False) + results = [] + + """ + cant use fixed indices, because if something has no entries, the list dissappears + instead I have to try parse everything, and just reject community playlists and profiles. + """ + + for renderer in renderer_list: + results.extend(parse_renderer(renderer)) + + print(results) + return Artist() def fetch_song(self, source: Source, stop_at_level: int = 1) -> Song: