summaryrefslogtreecommitdiff
path: root/tidal_dl_ng/helper/path.py
diff options
context:
space:
mode:
authorRobert Honz <exislow+github@gmail.com>2024-11-10 14:21:10 +0100
committerRobert Honz <exislow+github@gmail.com>2024-11-10 14:21:10 +0100
commitce02215d7cbf8d05998985b129adef7694bf9c1e (patch)
treee970e855585a45406625d702986ec8d234ce6180 /tidal_dl_ng/helper/path.py
parent07a899ab77e102f34461af4455a3e677c99f0d33 (diff)
downloadtidal-dl-ng-ce02215d7cbf8d05998985b129adef7694bf9c1e.tar.gz
`{track_volume_num_optional}` and `{track_volume_num_optional_CD}` added for an optional sub CD folder structure. Fixes #151
Diffstat (limited to 'tidal_dl_ng/helper/path.py')
-rw-r--r--tidal_dl_ng/helper/path.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tidal_dl_ng/helper/path.py b/tidal_dl_ng/helper/path.py
index 4be06e7..3d72cdf 100644
--- a/tidal_dl_ng/helper/path.py
+++ b/tidal_dl_ng/helper/path.py
@@ -155,6 +155,14 @@ def format_str_media(name: str, media: Track | Album | Playlist | UserPlaylist |
case "track_volume_num":
if isinstance(media, Track | Video):
result = str(media.volume_num)
+ case "track_volume_num_optional":
+ if isinstance(media, Track | Video):
+ num_volumes: int = media.album.num_volumes if hasattr(media, "album") else 1
+ result = "" if media.volume_num is num_volumes else str(media.volume_num)
+ case "track_volume_num_optional_CD":
+ if isinstance(media, Track | Video):
+ num_volumes: int = media.album.num_volumes if hasattr(media, "album") else 1
+ result = "" if media.volume_num is num_volumes else f"CD{media.volume_num!s}"
except Exception as e:
# TODO: Implement better exception logging.
print(e)