Корректная замена заполнителей пути (#track-artist)

This commit is contained in:
Lev Plyusnin 2025-06-15 11:24:03 +07:00
parent e435328907
commit 1d944cc9fb
No known key found for this signature in database
GPG key ID: 21C6C2C9C0A4460D
4 changed files with 12 additions and 13 deletions

View file

@ -122,7 +122,7 @@ ID:
--unsafe-path Не очищать путь от недопустимых символов
--dir <Папка> Папка для загрузки музыки (по умолчанию: .)
--path-pattern <Паттерн>
Поддерживает следующие заполнители: #number, #artist, #album-artist, #title, #album, #year, #artist-id, #album-id, #track-id, #number-padded (по умолчанию: #album-artist/#album/#number - #title)
Поддерживает следующие заполнители: #number, #track-artist, #album-artist, #title, #album, #year, #artist-id, #album-id, #track-id, #number-padded (по умолчанию: #album-artist/#album/#number - #title)
Авторизация:
--token <Токен> Токен для авторизации. См. README для способов получения

View file

@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "yandex-music-downloader"
version = "3.5.0"
version = "3.5.1"
description = "Загрузчик музыки с сервиса Яндекс.Музыка"
requires-python = ">=3.9"
readme = "README.md"

View file

@ -205,7 +205,7 @@ def main():
type=Path,
help=show_default(
"Поддерживает следующие заполнители:"
" #number, #artist, #album-artist, #title,"
" #number, #track-artist, #album-artist, #title,"
" #album, #year, #artist-id, #album-id, #track-id, #number-padded"
),
)

View file

@ -135,27 +135,26 @@ def prepare_base_path(
) -> Path:
path_str = str(path_pattern)
album = None
artist = None
album_artist = None
track_artist = None
track_position = None
if albums := track.albums:
album = albums[0]
track_position = album.track_position
if artists := album.artists:
album_artist = artists[0]
if artists := track.artists:
artist = artists[0]
elif artists := album.artists:
artists = artists[0]
if artist is None and (artists := track.artists):
artist = artists[0]
track_artist = artists[0]
repl_dict: dict[str, Union[str, int, None]] = {
"#number-padded": str(track_position.index).zfill(len(str(album.track_count)))
if track_position and album
else None,
"#album-artist": artist.name if artist else None,
"#artist-id": artist.id if artist else None,
"#album-artist": album_artist.name if album_artist else None,
"#track-artist": track_artist.name if track_artist else None,
"#artist-id": track_artist.id if track_artist else None,
"#album-id": album.id if album else None,
"#track-id": track.id,
"#number": track_position.index if track_position else None,
"#artist": artist.name if artist else None,
"#title": full_title(track),
"#album": full_title(album) if album else None,
"#year": album.year if album else None,