Skip to content

Commit

Permalink
Fix bandcamp album metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
justin025 committed Dec 14, 2024
1 parent 79b5f1e commit 16c7635
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/onthespot/api/bandcamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,16 @@ def bandcamp_get_track_metadata(token, url):
track_data[attribute_name] = decoded_value_json
except json.JSONDecodeError:
track_data[attribute_name] = decoded_value

album_webpage = make_call(url, text=True, use_ssl=True)
try:
album_webpage = make_call(track_data['embed']['album_embed_data']['linkback'], text=True, use_ssl=True)
except Exception:
pass
matches = re.findall(r'<script type="application/ld\+json">\s*(\{.*?\})\s*</script>', album_webpage, re.DOTALL)
for match in matches:
json_data_str = match
json_data_str = re.sub(r',\s*}', '}', json_data_str) # Remove trailing commas
album_data = json.loads(json_data_str)
print(album_data)

# Year
year = ''
Expand Down
2 changes: 1 addition & 1 deletion src/onthespot/gui/mainui.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ..api.youtube import youtube_add_account, youtube_get_track_metadata
from ..downloader import DownloadWorker
from ..otsconfig import config
from ..runtimedata import account_pool, download_queue, download_queue_lock, get_init_tray, parsing, pending, get_logger, temp_download_path
from ..runtimedata import account_pool, download_queue, download_queue_lock, get_init_tray, parsing, pending, pending_lock, get_logger, temp_download_path
from .dl_progressbtn import DownloadActionsButtons
from .settings import load_config, save_config
from .thumb_listitem import LabelWithThumb
Expand Down

0 comments on commit 16c7635

Please sign in to comment.