added support for 'track-number' placeholder
This commit is contained in:
parent
6a23b575b1
commit
2c510f37ed
2 changed files with 9 additions and 3 deletions
|
|
@ -131,7 +131,7 @@ def main():
|
||||||
help=show_default(
|
help=show_default(
|
||||||
"Поддерживает следующие заполнители:"
|
"Поддерживает следующие заполнители:"
|
||||||
" #number, #artist, #album-artist, #title,"
|
" #number, #artist, #album-artist, #title,"
|
||||||
" #album, #year, #artist-id, #album-id, #track-id"
|
" #album, #year, #artist-id, #album-id, #track-id, #track-number"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -237,9 +237,14 @@ def main():
|
||||||
print(f"Треков: {len(result_tracks)}")
|
print(f"Треков: {len(result_tracks)}")
|
||||||
|
|
||||||
covers_cache: dict[str, bytes] = {}
|
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
|
||||||
for track in result_tracks:
|
for track in result_tracks:
|
||||||
|
track_number += 1
|
||||||
save_path = args.dir / core.prepare_track_path(
|
save_path = args.dir / core.prepare_track_path(
|
||||||
args.path_pattern, track, args.unsafe_path
|
args.path_pattern, track, args.unsafe_path, str(track_number).zfill(track_number_pad)
|
||||||
)
|
)
|
||||||
if args.skip_existing and save_path.is_file():
|
if args.skip_existing and save_path.is_file():
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ DEFAULT_COVER_RESOLUTION = 400
|
||||||
|
|
||||||
|
|
||||||
def prepare_track_path(
|
def prepare_track_path(
|
||||||
path_pattern: Path, track: BasicTrackInfo, unsafe_path: bool = False
|
path_pattern: Path, track: BasicTrackInfo, unsafe_path: bool = False, track_number_str: str = ""
|
||||||
) -> Path:
|
) -> Path:
|
||||||
path_str = str(path_pattern)
|
path_str = str(path_pattern)
|
||||||
album = track.album
|
album = track.album
|
||||||
|
|
@ -29,6 +29,7 @@ def prepare_track_path(
|
||||||
"#artist-id": artist.name,
|
"#artist-id": artist.name,
|
||||||
"#album-id": album.id,
|
"#album-id": album.id,
|
||||||
"#track-id": track.id,
|
"#track-id": track.id,
|
||||||
|
"#track-number": track_number_str,
|
||||||
"#number": track.number,
|
"#number": track.number,
|
||||||
"#artist": artist.name,
|
"#artist": artist.name,
|
||||||
"#title": track.title,
|
"#title": track.title,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue