diff options
| author | exislow <exislow@users.noreply.github.com> | 2025-08-12 10:55:48 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-12 10:55:48 +0200 |
| commit | e8db68992f5934aabc8f21de7a725135b4c9da6e (patch) | |
| tree | 9dec420a9431e4cde49df090bfa096de62e33158 | |
| parent | 23fda8ed33cfbbd03e11e27bd5d6964e54dd2dca (diff) | |
| parent | afdb523cb56d8d408f4a61be61937f23a4dfea9e (diff) | |
| download | tidal-dl-ng-e8db68992f5934aabc8f21de7a725135b4c9da6e.tar.gz | |
Merge pull request #498 from exislow/490-add-album_date-placeholder-for-full-iso-release-date-yyyy-mm-dd
feat: add support for formatting album release dates
| -rw-r--r-- | tidal_dl_ng/helper/path.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/tidal_dl_ng/helper/path.py b/tidal_dl_ng/helper/path.py index 0f7de31..311527b 100644 --- a/tidal_dl_ng/helper/path.py +++ b/tidal_dl_ng/helper/path.py @@ -135,6 +135,7 @@ def format_str_media( _format_numbers, _format_ids, _format_durations, + _format_dates, _format_metadata, _format_volumes, ): @@ -333,12 +334,35 @@ def _format_durations( m, s = divmod(media.duration, 60) return f"{m:01d}:{s:02d}" - # Format year - elif name == "album_year": + return None + + +def _format_dates( + name: str, + media: Track | Album | Playlist | UserPlaylist | Video | Mix, + *_args, +) -> str | None: + """Handle date-related format strings. + + Args: + name (str): The format string name to check. + media (Track | Album | Playlist | UserPlaylist | Video | Mix): The media object to extract date information from. + *_args (Any): Additional arguments (not used). + + Returns: + str | None: The formatted date or None if the format string is not date-related. + """ + if name == "album_year": if isinstance(media, Album): return str(media.year) elif isinstance(media, Track): return str(media.album.year) + elif name == "album_date": + if isinstance(media, Album): + return media.release_date.strftime("%Y-%m-%d") if media.release_date else None + elif isinstance(media, Track): + return media.album.release_date.strftime("%Y-%m-%d") if media.album.release_date else None + return None |
