From 184d1d1aeb056d6b90df03437b2edde88661b19d Mon Sep 17 00:00:00 2001 From: Lev Plyusnin Date: Tue, 23 Apr 2024 22:22:05 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B8=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B7=D0=B0=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D0=BD=D0=B8=D1=82=D0=B5=D0=BB=D1=8F,=20=D1=84?= =?UTF-8?q?=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ymd/cli.py | 9 +++++---- ymd/core.py | 7 +++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ymd/cli.py b/ymd/cli.py index bf562e1..d64ed88 100644 --- a/ymd/cli.py +++ b/ymd/cli.py @@ -238,13 +238,14 @@ def main(): covers_cache: dict[str, bytes] = {} track_number = 0 - # track number should be padded to an appropriate string width with zeroes, e.g: - # up to 99 tracks in total - 01, 02, ...; up to 999 tracks - 001, 002, ...; etc. - track_number_pad = len(str(len(result_tracks))) # get max track number width + track_number_pad = len(str(len(result_tracks))) for track in result_tracks: track_number += 1 save_path = args.dir / core.prepare_track_path( - args.path_pattern, track, args.unsafe_path, str(track_number).zfill(track_number_pad) + args.path_pattern, + track, + args.unsafe_path, + str(track_number).zfill(track_number_pad), ) if args.skip_existing and save_path.is_file(): continue diff --git a/ymd/core.py b/ymd/core.py index 1f029b9..fe538f6 100644 --- a/ymd/core.py +++ b/ymd/core.py @@ -19,7 +19,10 @@ DEFAULT_COVER_RESOLUTION = 400 def prepare_track_path( - path_pattern: Path, track: BasicTrackInfo, unsafe_path: bool = False, track_number_str: str = "" + path_pattern: Path, + track: BasicTrackInfo, + unsafe_path: bool = False, + track_number_str: str = "", ) -> Path: path_str = str(path_pattern) album = track.album @@ -29,7 +32,7 @@ def prepare_track_path( "#artist-id": artist.name, "#album-id": album.id, "#track-id": track.id, - "#track-number": track_number_str, + "#number-padded": track_number_str, "#number": track.number, "#artist": artist.name, "#title": track.title,