From ddf025d85054e99957d577e011593c4790d88d38 Mon Sep 17 00:00:00 2001 From: Luca Bilke Date: Tue, 27 Jun 2023 10:54:39 +0200 Subject: [PATCH] add track cover metadata, fix paths --- scrape.sh | 7 +++++++ tidal_scrape.py | 13 ++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100755 scrape.sh diff --git a/scrape.sh b/scrape.sh new file mode 100755 index 0000000..74031e1 --- /dev/null +++ b/scrape.sh @@ -0,0 +1,7 @@ +#!/bin/sh +export USER_ID=188721652 +export DL_PATH=/home/luca/Downloads +export DEST_PATH=/home/luca/Music +export AUTH_PATH=/home/luca/Secrets +export SKIP_DOWNLOADED=True +/bin/env python tidal_scrape.py diff --git a/tidal_scrape.py b/tidal_scrape.py index 078d890..ace1cec 100755 --- a/tidal_scrape.py +++ b/tidal_scrape.py @@ -70,7 +70,7 @@ def set_metadata(track: tidalapi.Track, file: str) -> None: if tagger.totaldisc <= 1: tagger.totaltrack = track.album.num_tracks # type: ignore[reportOptionalMemberAccess] - coverpath = track.album.cover(1280) # type: ignore[reportOptionalMemberAccess] + coverpath = f"{DEST_PATH}/{track.album.name}/cover.png" # type: ignore[reportOptionalMemberAccess] tagger.save(coverpath) @@ -122,6 +122,7 @@ def download_track( def download_cover(album: tidalapi.Album) -> None: print(f"Downloading cover for {album.name}") # type: ignore[reportOptionalMemberAccess] + album_name = re.sub("/", " ", album.name) # type: ignore[reportOptionalMemberAccess] dest_path = f"{DEST_PATH}/{album_name}/cover.png" # type: ignore[reportOptionalMemberAccess] url = album.image(1280) @@ -164,10 +165,12 @@ user = session.get_user(USER_ID) favorites = tidalapi.user.Favorites(session, user.id) albums = favorites.albums() dl_tracks = [] -for album in albums: - download_cover(album) - tracks = album.tracks() - dl_tracks += tracks +# for album in albums: +# download_cover(album) +# dl_tracks += album.tracks() +album = albums[0] +download_cover(album) +dl_tracks += album.tracks() for track in dl_tracks: check, _ = download_track(track)