From a3883d37b6e84a63df757ed0d30be6acd0fd2346 Mon Sep 17 00:00:00 2001 From: jonathan // hollis Date: Thu, 4 Jul 2024 13:09:58 +0930 Subject: [PATCH 1/6] Update README.md --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index e54b8222..91d14428 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,22 @@ +### hollis notes! + +getting into debug: + +``` +python3 -m venv ./ + +# for windows: +./Scripts/Activate.ps1 +# for linux: +source ./bin/activate + +python3 -m pip install -r requirements.txt + +python3 -m zotify +``` + +--- + # Zotify ### A highly customizable music and podcast downloader. From 7df252b8d8e640cd61c93ac8b42080faad247232 Mon Sep 17 00:00:00 2001 From: hollis Date: Thu, 4 Jul 2024 13:35:52 +0930 Subject: [PATCH 2/6] add pyvenv to gitignore --- .gitignore | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 04856825..9866d864 100644 --- a/.gitignore +++ b/.gitignore @@ -87,6 +87,11 @@ ipython_config.py # For a library or package, you might want to ignore these files since the code is # intended to run in multiple environments; otherwise, check them in: # .python-version +bin/ +lib/ +lib64 +share/ +pyvenv.cfg # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. @@ -150,4 +155,4 @@ cython_debug/ #Download Folder Zotify\ Music/ -Zotify\ Podcasts/ +Zotify\ Podcasts/ \ No newline at end of file From f4365b3da9e200e3f469c3283a1ce575c83e6ef1 Mon Sep 17 00:00:00 2001 From: hollis Date: Thu, 4 Jul 2024 13:56:34 +0930 Subject: [PATCH 3/6] grab and populate total number of tracks --- zotify/const.py | 4 ++++ zotify/track.py | 12 +++++++----- zotify/utils.py | 5 +++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/zotify/const.py b/zotify/const.py index e269a903..d50d4006 100644 --- a/zotify/const.py +++ b/zotify/const.py @@ -8,6 +8,8 @@ TRACKNUMBER = 'tracknumber' +TOTALTRACKS = 'totaltracks' + DISCNUMBER = 'discnumber' YEAR = 'year' @@ -58,6 +60,8 @@ TRACK_NUMBER = 'track_number' +TOTAL_TRACKS = 'total_tracks' + DISC_NUMBER = 'disc_number' SHOW = 'show' diff --git a/zotify/track.py b/zotify/track.py index bb2af89b..3f960cd9 100644 --- a/zotify/track.py +++ b/zotify/track.py @@ -8,7 +8,7 @@ from librespot.metadata import TrackId import ffmpy -from zotify.const import TRACKS, ALBUM, GENRES, NAME, ITEMS, DISC_NUMBER, TRACK_NUMBER, IS_PLAYABLE, ARTISTS, IMAGES, URL, \ +from zotify.const import TRACKS, ALBUM, GENRES, NAME, ITEMS, DISC_NUMBER, TRACK_NUMBER, TOTAL_TRACKS, IS_PLAYABLE, ARTISTS, IMAGES, URL, \ RELEASE_DATE, ID, TRACKS_URL, FOLLOWED_ARTISTS_URL, SAVED_TRACKS_URL, TRACK_STATS_URL, CODEC_MAP, EXT_MAP, DURATION_MS, \ HREF, ARTISTS, WIDTH from zotify.termoutput import Printer, PrintChannel @@ -46,7 +46,7 @@ def get_followed_artists() -> list: return artists -def get_song_info(song_id) -> Tuple[List[str], List[Any], str, str, Any, Any, Any, Any, Any, Any, int]: +def get_song_info(song_id) -> Tuple[List[str], List[Any], str, str, Any, Any, Any, Any, Any, Any, Any, int]: """ Retrieves metadata for downloaded songs """ with Loader(PrintChannel.PROGRESS_INFO, "Fetching track information..."): (raw, info) = Zotify.invoke_url(f'{TRACKS_URL}?ids={song_id}&market=from_token') @@ -63,6 +63,7 @@ def get_song_info(song_id) -> Tuple[List[str], List[Any], str, str, Any, Any, An name = info[TRACKS][0][NAME] release_year = info[TRACKS][0][ALBUM][RELEASE_DATE].split('-')[0] disc_number = info[TRACKS][0][DISC_NUMBER] + total_tracks = info[TRACKS][0][ALBUM][TOTAL_TRACKS] track_number = info[TRACKS][0][TRACK_NUMBER] scraped_song_id = info[TRACKS][0][ID] is_playable = info[TRACKS][0][IS_PLAYABLE] @@ -74,7 +75,7 @@ def get_song_info(song_id) -> Tuple[List[str], List[Any], str, str, Any, Any, An image = i image_url = image[URL] - return artists, info[TRACKS][0][ARTISTS], album_name, name, image_url, release_year, disc_number, track_number, scraped_song_id, is_playable, duration_ms + return artists, info[TRACKS][0][ARTISTS], album_name, name, image_url, release_year, disc_number, track_number, total_tracks, scraped_song_id, is_playable, duration_ms except Exception as e: raise ValueError(f'Failed to parse TRACKS_URL response: {str(e)}\n{raw}') @@ -155,7 +156,7 @@ def download_track(mode: str, track_id: str, extra_keys=None, disable_progressba output_template = Zotify.CONFIG.get_output(mode) (artists, raw_artists, album_name, name, image_url, release_year, disc_number, - track_number, scraped_song_id, is_playable, duration_ms) = get_song_info(track_id) + track_number, total_tracks, scraped_song_id, is_playable, duration_ms) = get_song_info(track_id) song_name = fix_filename(artists[0]) + ' - ' + fix_filename(name) @@ -170,6 +171,7 @@ def download_track(mode: str, track_id: str, extra_keys=None, disable_progressba output_template = output_template.replace("{release_year}", fix_filename(release_year)) output_template = output_template.replace("{disc_number}", fix_filename(disc_number)) output_template = output_template.replace("{track_number}", fix_filename(track_number)) + output_template = output_template.replace("{total_tracks}", fix_filename(total_tracks)) output_template = output_template.replace("{id}", fix_filename(scraped_song_id)) output_template = output_template.replace("{track_id}", fix_filename(track_id)) output_template = output_template.replace("{ext}", ext) @@ -261,7 +263,7 @@ def download_track(mode: str, track_id: str, extra_keys=None, disable_progressba Printer.print(PrintChannel.SKIPS, f"### Skipping lyrics for {song_name}: lyrics not available ###") convert_audio_format(filename_temp) try: - set_audio_tags(filename_temp, artists, genres, name, album_name, release_year, disc_number, track_number) + set_audio_tags(filename_temp, artists, genres, name, album_name, release_year, disc_number, track_number, total_tracks) set_music_thumbnail(filename_temp, image_url) except Exception: Printer.print(PrintChannel.ERRORS, "Unable to write metadata, ensure ffmpeg is installed and added to your PATH.") diff --git a/zotify/utils.py b/zotify/utils.py index dce9fd24..ff3d6d34 100644 --- a/zotify/utils.py +++ b/zotify/utils.py @@ -11,7 +11,7 @@ import music_tag import requests -from zotify.const import ARTIST, GENRE, TRACKTITLE, ALBUM, YEAR, DISCNUMBER, TRACKNUMBER, ARTWORK, \ +from zotify.const import ARTIST, GENRE, TRACKTITLE, ALBUM, YEAR, DISCNUMBER, TRACKNUMBER, TOTALTRACKS, ARTWORK, \ WINDOWS_SYSTEM, LINUX_SYSTEM, ALBUMARTIST from zotify.zotify import Zotify @@ -126,7 +126,7 @@ def clear() -> None: os.system('clear') -def set_audio_tags(filename, artists, genres, name, album_name, release_year, disc_number, track_number) -> None: +def set_audio_tags(filename, artists, genres, name, album_name, release_year, disc_number, track_number, total_tracks) -> None: """ sets music_tag metadata """ tags = music_tag.load_file(filename) tags[ALBUMARTIST] = artists[0] @@ -137,6 +137,7 @@ def set_audio_tags(filename, artists, genres, name, album_name, release_year, di tags[YEAR] = release_year tags[DISCNUMBER] = disc_number tags[TRACKNUMBER] = track_number + tags[TOTALTRACKS] = total_tracks tags.save() From bbc7d901bc9dee23d0d8fbd4ae0a2dc85a444b26 Mon Sep 17 00:00:00 2001 From: hollis Date: Thu, 4 Jul 2024 13:58:40 +0930 Subject: [PATCH 4/6] move total_tracks under track_number for consistency --- zotify/track.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zotify/track.py b/zotify/track.py index 3f960cd9..e5c81fc1 100644 --- a/zotify/track.py +++ b/zotify/track.py @@ -63,8 +63,8 @@ def get_song_info(song_id) -> Tuple[List[str], List[Any], str, str, Any, Any, An name = info[TRACKS][0][NAME] release_year = info[TRACKS][0][ALBUM][RELEASE_DATE].split('-')[0] disc_number = info[TRACKS][0][DISC_NUMBER] - total_tracks = info[TRACKS][0][ALBUM][TOTAL_TRACKS] track_number = info[TRACKS][0][TRACK_NUMBER] + total_tracks = info[TRACKS][0][ALBUM][TOTAL_TRACKS] scraped_song_id = info[TRACKS][0][ID] is_playable = info[TRACKS][0][IS_PLAYABLE] duration_ms = info[TRACKS][0][DURATION_MS] From 14d0888d24eecf9c999b23013c9715fa790a5499 Mon Sep 17 00:00:00 2001 From: hollis Date: Thu, 4 Jul 2024 14:00:32 +0930 Subject: [PATCH 5/6] Revert "add pyvenv to gitignore" This reverts commit 7df252b8d8e640cd61c93ac8b42080faad247232. --- .gitignore | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 9866d864..04856825 100644 --- a/.gitignore +++ b/.gitignore @@ -87,11 +87,6 @@ ipython_config.py # For a library or package, you might want to ignore these files since the code is # intended to run in multiple environments; otherwise, check them in: # .python-version -bin/ -lib/ -lib64 -share/ -pyvenv.cfg # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. @@ -155,4 +150,4 @@ cython_debug/ #Download Folder Zotify\ Music/ -Zotify\ Podcasts/ \ No newline at end of file +Zotify\ Podcasts/ From ca70220420312868d33ad11ae71201d6638a68fb Mon Sep 17 00:00:00 2001 From: hollis Date: Thu, 4 Jul 2024 14:01:04 +0930 Subject: [PATCH 6/6] Revert "Update README.md" This reverts commit a3883d37b6e84a63df757ed0d30be6acd0fd2346. --- README.md | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/README.md b/README.md index 91d14428..e54b8222 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,3 @@ -### hollis notes! - -getting into debug: - -``` -python3 -m venv ./ - -# for windows: -./Scripts/Activate.ps1 -# for linux: -source ./bin/activate - -python3 -m pip install -r requirements.txt - -python3 -m zotify -``` - ---- - # Zotify ### A highly customizable music and podcast downloader.