diff --git a/src/actual_donwload.py b/src/actual_donwload.py index bb8d1b1..286299a 100644 --- a/src/actual_donwload.py +++ b/src/actual_donwload.py @@ -30,7 +30,8 @@ if __name__ == "__main__": youtube_music_test = [ "s: #a Only Smile #r Your best friend", - "8" + "8", + "2" ] music_kraken.cli.download(genre="test", command_list=youtube_music_test, process_metadata_anyway=True) diff --git a/src/music_kraken/pages/bandcamp.py b/src/music_kraken/pages/bandcamp.py index 039e4eb..276f640 100644 --- a/src/music_kraken/pages/bandcamp.py +++ b/src/music_kraken/pages/bandcamp.py @@ -256,7 +256,37 @@ class Bandcamp(Page): def fetch_song(self, source: Source, stop_at_level: int = 1) -> Song: print(source) - return Song() + + r = self.connection.get(source.url) + if r is None: + return Song() + + soup = self.get_soup_from_response(r) + + data_container = soup.find("script", {"type": "application/ld+json"}) + + if DEBUG: + dump_to_file("bandcamp_song_data.json", data_container.text, is_json=True, exit_after_dump=False) + + data = json.loads(data_container.text) + album_data = data["inAlbum"] + artist_data = data["byArtist"] + + song = Song( + title=data["name"], + source_list=[Source(self.SOURCE_TYPE, data.get("mainEntityOfPage", data["@id"]))], + album_list=[Album( + title=album_data["name"], + date=ID3Timestamp.strptime(data["datePublished"], "%d %b %Y %H:%M:%S %Z"), + source_list=[Source(self.SOURCE_TYPE, album_data["@id"])] + )], + main_artist_list=[Artist( + name=artist_data["name"], + source_list=[Source(self.SOURCE_TYPE, artist_data["@id"])] + )] + ) + + return song def download_song_to_target(self, source: Source, target: Target, desc: str = None) -> DownloadResult: return DownloadResult()