From e49df1e71977b9c0522dc81a73782d8c97895bd3 Mon Sep 17 00:00:00 2001 From: Nathan Thomas Date: Mon, 6 Sep 2021 20:18:50 -0700 Subject: [PATCH] Add `id` key in FOLDER_FORMAT #150 --- rip/config.toml | 2 +- streamrip/constants.py | 1 + streamrip/media.py | 1 - streamrip/metadata.py | 3 +++ 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/rip/config.toml b/rip/config.toml index 4c3e20f..b3f7918 100644 --- a/rip/config.toml +++ b/rip/config.toml @@ -144,7 +144,7 @@ add_singles_to_folder = false # "container", and "albumcomposer" folder_format = "{albumartist} - {title} ({year}) [{container}] [{bit_depth}B-{sampling_rate}kHz]" # Available keys: "tracknumber", "artist", "albumartist", "composer", "title", -# and "albumcomposer" +# "id", and "albumcomposer" track_format = "{tracknumber}. {artist} - {title}" # Only allow printable ASCII characters in filenames. restrict_characters = false diff --git a/streamrip/constants.py b/streamrip/constants.py index ee00ed8..afdb23a 100644 --- a/streamrip/constants.py +++ b/streamrip/constants.py @@ -136,6 +136,7 @@ ALBUM_KEYS = ( "sampling_rate", "container", "albumcomposer", + "id", ) # TODO: rename these to DEFAULT_FOLDER_FORMAT etc FOLDER_FORMAT = "{albumartist} - {title} ({year}) [{container}] [{bit_depth}B-{sampling_rate}kHz]" diff --git a/streamrip/media.py b/streamrip/media.py index cf597c5..e49d439 100644 --- a/streamrip/media.py +++ b/streamrip/media.py @@ -515,7 +515,6 @@ class Track(Media): a dict with the keys allowed in formatter strings, and their values in the TrackMetadata object. """ - print(f"{restrict=}") formatter = self.meta.get_formatter(max_quality=self.quality) logger.debug("Track meta formatter %s", formatter) filename = clean_format(self.file_format, formatter, restrict=restrict) diff --git a/streamrip/metadata.py b/streamrip/metadata.py index eada572..bbd0cf4 100644 --- a/streamrip/metadata.py +++ b/streamrip/metadata.py @@ -167,6 +167,7 @@ class TrackMetadata: self.sampling_rate = resp.get("maximum_sampling_rate") self.quality = get_quality_id(self.bit_depth, self.sampling_rate) self.booklets = resp.get("goodies") + self.id = resp.get("id") if self.sampling_rate is not None: self.sampling_rate *= 1000 @@ -188,6 +189,7 @@ class TrackMetadata: # 80, 160, 320, 640, 1280 self.cover_urls = get_cover_urls(resp, self.__source) self.streamable = resp.get("allowStreaming", False) + self.id = resp.get("id") if q := resp.get( "audioQuality" @@ -220,6 +222,7 @@ class TrackMetadata: self.cover_urls = get_cover_urls(resp, self.__source) self.streamable = True + self.id = resp.get("id") elif self.__source == "soundcloud": raise NotImplementedError