From eeec4e1f1b738a9b3c91d3025d19cc25b8c34a58 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 26 Feb 2026 11:11:00 -0700 Subject: [PATCH] feat(tracks): add edition tags to output filenames Extend track.edition to support a list of tags (e.g., ["IMAX", "3D"]) that are inserted into the output filename before the resolution. --- unshackle/core/titles/episode.py | 7 ++++++- unshackle/core/titles/movie.py | 5 +++++ unshackle/core/titles/song.py | 5 +++++ unshackle/core/tracks/audio.py | 2 +- unshackle/core/tracks/track.py | 6 +++--- unshackle/core/tracks/video.py | 2 +- 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/unshackle/core/titles/episode.py b/unshackle/core/titles/episode.py index 869bfb8..4c0e07e 100644 --- a/unshackle/core/titles/episode.py +++ b/unshackle/core/titles/episode.py @@ -158,6 +158,11 @@ class Episode(Title): if getattr(config, "repack", False): name += " REPACK" + if self.tracks: + first_track = next(iter(self.tracks), None) + if first_track and first_track.edition: + name += " " + " ".join(first_track.edition) + if primary_video_track: resolution_token = _get_resolution_token(primary_video_track) if resolution_token: @@ -286,4 +291,4 @@ class Series(SortedKeyList, ABC): return tree -__all__ = ("Episode", "Series") \ No newline at end of file +__all__ = ("Episode", "Series") diff --git a/unshackle/core/titles/movie.py b/unshackle/core/titles/movie.py index 3eb0b50..f647d36 100644 --- a/unshackle/core/titles/movie.py +++ b/unshackle/core/titles/movie.py @@ -93,6 +93,11 @@ class Movie(Title): if getattr(config, "repack", False): name += " REPACK" + if self.tracks: + first_track = next(iter(self.tracks), None) + if first_track and first_track.edition: + name += " " + " ".join(first_track.edition) + if primary_video_track: resolution_token = _get_resolution_token(primary_video_track) if resolution_token: diff --git a/unshackle/core/titles/song.py b/unshackle/core/titles/song.py index 580e33e..ad63478 100644 --- a/unshackle/core/titles/song.py +++ b/unshackle/core/titles/song.py @@ -103,6 +103,11 @@ class Song(Title): if getattr(config, "repack", False): name += " REPACK" + if self.tracks: + first_track = next(iter(self.tracks), None) + if first_track and first_track.edition: + name += " " + " ".join(first_track.edition) + # Service (use track source if available) if show_service: source_name = None diff --git a/unshackle/core/tracks/audio.py b/unshackle/core/tracks/audio.py index 0069efa..a469b7f 100644 --- a/unshackle/core/tracks/audio.py +++ b/unshackle/core/tracks/audio.py @@ -151,7 +151,7 @@ class Audio(Track): ), f"{self.bitrate // 1000} kb/s" if self.bitrate else None, self.get_track_name(), - self.edition, + ", ".join(self.edition) if self.edition else None, ], ) ) diff --git a/unshackle/core/tracks/track.py b/unshackle/core/tracks/track.py index a6beb7f..6031dc2 100644 --- a/unshackle/core/tracks/track.py +++ b/unshackle/core/tracks/track.py @@ -66,8 +66,8 @@ class Track: raise TypeError(f"Expected name to be a {str}, not {type(name)}") if not isinstance(id_, (str, type(None))): raise TypeError(f"Expected id_ to be a {str}, not {type(id_)}") - if not isinstance(edition, (str, type(None))): - raise TypeError(f"Expected edition to be a {str}, not {type(edition)}") + if not isinstance(edition, (str, list, type(None))): + raise TypeError(f"Expected edition to be a {str}, {list}, or None, not {type(edition)}") if not isinstance(downloader, (Callable, type(None))): raise TypeError(f"Expected downloader to be a {Callable}, not {type(downloader)}") if not isinstance(downloader_args, (dict, type(None))): @@ -103,7 +103,7 @@ class Track: self.needs_repack = needs_repack self.name = name self.drm = drm - self.edition: str = edition + self.edition: list[str] = [edition] if isinstance(edition, str) else (edition or []) self.downloader = downloader self.downloader_args = downloader_args self.from_file = from_file diff --git a/unshackle/core/tracks/video.py b/unshackle/core/tracks/video.py index 79fbb92..a8cb97b 100644 --- a/unshackle/core/tracks/video.py +++ b/unshackle/core/tracks/video.py @@ -291,7 +291,7 @@ class Video(Track): ], ) ), - self.edition, + ", ".join(self.edition) if self.edition else None, ], ) )