mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-29 12:35:13 +00:00
feat(config): per-title-type folder templates
Allow output_template.folder to be a dict with movies/series/songs keys so music libraries can use artist/album folder layouts while movies and series keep their own scheme. Legacy string form still applies to all title types.
This commit is contained in:
@@ -100,14 +100,15 @@ class Episode(Title):
|
||||
|
||||
def get_filename(self, media_info: MediaInfo, folder: bool = False, show_service: bool = True) -> str:
|
||||
if folder:
|
||||
if config.folder_template:
|
||||
formatter = TemplateFormatter(config.folder_template)
|
||||
template = config.get_folder_template("series")
|
||||
if template:
|
||||
formatter = TemplateFormatter(template)
|
||||
context = self._build_template_context(media_info, show_service)
|
||||
context["season"] = f"S{self.season:02}"
|
||||
|
||||
folder_name = formatter.format(context)
|
||||
|
||||
separators = re.sub(r"\{[^}]*\}", "", config.folder_template)
|
||||
separators = re.sub(r"\{[^}]*\}", "", template)
|
||||
spacer = "." if "." in separators and " " not in separators else " "
|
||||
return sanitize_filename(folder_name, spacer)
|
||||
|
||||
|
||||
@@ -60,12 +60,13 @@ class Movie(Title):
|
||||
|
||||
def get_filename(self, media_info: MediaInfo, folder: bool = False, show_service: bool = True) -> str:
|
||||
if folder:
|
||||
if config.folder_template:
|
||||
formatter = TemplateFormatter(config.folder_template)
|
||||
template = config.get_folder_template("movies")
|
||||
if template:
|
||||
formatter = TemplateFormatter(template)
|
||||
context = self._build_template_context(media_info, show_service)
|
||||
folder_name = formatter.format(context)
|
||||
|
||||
separators = re.sub(r"\{[^}]*\}", "", config.folder_template)
|
||||
separators = re.sub(r"\{[^}]*\}", "", template)
|
||||
spacer = "." if "." in separators and " " not in separators else " "
|
||||
return sanitize_filename(folder_name, spacer)
|
||||
name = f"{self.name}"
|
||||
|
||||
@@ -95,12 +95,13 @@ class Song(Title):
|
||||
|
||||
def get_filename(self, media_info: MediaInfo, folder: bool = False, show_service: bool = True) -> str:
|
||||
if folder:
|
||||
if config.folder_template:
|
||||
formatter = TemplateFormatter(config.folder_template)
|
||||
template = config.get_folder_template("songs")
|
||||
if template:
|
||||
formatter = TemplateFormatter(template)
|
||||
context = self._build_template_context(media_info, show_service)
|
||||
folder_name = formatter.format(context)
|
||||
|
||||
separators = re.sub(r"\{[^}]*\}", "", config.folder_template)
|
||||
separators = re.sub(r"\{[^}]*\}", "", template)
|
||||
spacer = "." if "." in separators and " " not in separators else " "
|
||||
return sanitize_filename(folder_name, spacer)
|
||||
name = f"{self.artist} - {self.album}"
|
||||
|
||||
Reference in New Issue
Block a user