From 01f882e0a126ddc1c21af3957ba4591493b8e98f Mon Sep 17 00:00:00 2001 From: Hellow <74311245+HeIIow2@users.noreply.github.com> Date: Tue, 13 Jun 2023 22:12:35 +0200 Subject: [PATCH] completely implemented downloading from youtube --- src/music_kraken/pages/youtube.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/music_kraken/pages/youtube.py b/src/music_kraken/pages/youtube.py index 94d29ba..6f3a3cb 100644 --- a/src/music_kraken/pages/youtube.py +++ b/src/music_kraken/pages/youtube.py @@ -201,16 +201,33 @@ class YouTube(Page): title = data["title"] license_str = None - for music_track in data.get("musicTracks", []): - title = music_track["song"] - license_str = music_track["license"] + + artist_list: List[Artist] = [] + + _author: str = data["author"] + if _author.endswith(" - Topic"): + artist_list.append(Artist( + name=_author.replace(" - Topic", ""), + source_list=[Source( + self.SOURCE_TYPE, get_invidious_url(path=f"/channel/{data['authorId']}") + )] + )) + + else: + for music_track in data.get("musicTracks", []): + title = music_track["song"] + license_str = music_track["license"] + + for artist_name in music_track["artist"].split(" x "): + artist_list.append(Artist(name=artist_name)) return Song( title=title, source_list=[Source( self.SOURCE_TYPE, get_invidious_url(path="/watch", query=f"v={data['videoId']}") )], - notes=FormattedText(html=data["descriptionHtml"] + f"\n
{license_str} p>" ) + notes=FormattedText(html=data["descriptionHtml"] + f"\n
{license_str} p>" ), + main_artist_list=artist_list ), int(data["published"]) def fetch_song(self, source: Source, stop_at_level: int = 1) -> Song: