From fd9a93f5553f670840a9aa02e4ac245b74312ebb Mon Sep 17 00:00:00 2001 From: Hellow <74311245+HeIIow2@users.noreply.github.com> Date: Tue, 12 Sep 2023 22:16:08 +0200 Subject: [PATCH] feat: implemented artist details --- src/music_kraken/pages/bandcamp.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/music_kraken/pages/bandcamp.py b/src/music_kraken/pages/bandcamp.py index 925bf0b..039e4eb 100644 --- a/src/music_kraken/pages/bandcamp.py +++ b/src/music_kraken/pages/bandcamp.py @@ -14,7 +14,8 @@ from ..objects import ( Album, Label, Target, - Contact + Contact, + ID3Timestamp ) from ..connection import Connection from ..utils.support_classes import DownloadResult @@ -224,16 +225,23 @@ class Bandcamp(Page): soup = self.get_soup_from_response(r) - if DEBUG: - # dump_to_file("album_page.html", r.text, exit_after_dump=False) - pass - data_container = soup.find("script", {"type": "application/ld+json"}) if DEBUG: dump_to_file("album_data.json", data_container.text, is_json=True, exit_after_dump=False) data = json.loads(data_container.text) + artist_data = data["byArtist"] + + album = Album( + title=data["name"], + source_list=[Source(self.SOURCE_TYPE, data.get("mainEntityOfPage", data["@id"]))], + date=ID3Timestamp.strptime(data["datePublished"], "%d %b %Y %H:%M:%S %Z"), + artist_list=[Artist( + name=artist_data["name"], + source_list=[Source(self.SOURCE_TYPE, artist_data["@id"])] + )] + ) for i, track_json in enumerate(data.get("track", {}).get("itemListElement", [])): if DEBUG: