mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-27 11:25:08 +00:00
feat(output): support nested directories in folder templates
Treat `/` in folder templates as a path separator (sanitize per segment) and let movies use a folder when a `movies` template is set.
This commit is contained in:
@@ -110,7 +110,7 @@ class Episode(Title):
|
||||
|
||||
separators = re.sub(r"\{[^}]*\}", "", template)
|
||||
spacer = "." if "." in separators and " " not in separators else " "
|
||||
return sanitize_filename(folder_name, spacer)
|
||||
return "/".join(sanitize_filename(p, spacer) for p in folder_name.split("/") if p)
|
||||
|
||||
series_template = config.output_template.get("series")
|
||||
if series_template:
|
||||
@@ -160,7 +160,7 @@ class Series(SortedKeyList, ABC):
|
||||
sum(seasons.values())
|
||||
season_breakdown = ", ".join(f"S{season}({count})" for season, count in sorted(seasons.items()))
|
||||
tree = Tree(
|
||||
f"{num_seasons} season{'s'[:num_seasons^1]}, {season_breakdown}",
|
||||
f"{num_seasons} season{'s'[: num_seasons ^ 1]}, {season_breakdown}",
|
||||
guide_style="bright_black",
|
||||
)
|
||||
if verbose:
|
||||
|
||||
@@ -68,7 +68,7 @@ class Movie(Title):
|
||||
|
||||
separators = re.sub(r"\{[^}]*\}", "", template)
|
||||
spacer = "." if "." in separators and " " not in separators else " "
|
||||
return sanitize_filename(folder_name, spacer)
|
||||
return "/".join(sanitize_filename(p, spacer) for p in folder_name.split("/") if p)
|
||||
name = f"{self.name}"
|
||||
if self.year:
|
||||
name += f" ({self.year})"
|
||||
|
||||
@@ -103,7 +103,7 @@ class Song(Title):
|
||||
|
||||
separators = re.sub(r"\{[^}]*\}", "", template)
|
||||
spacer = "." if "." in separators and " " not in separators else " "
|
||||
return sanitize_filename(folder_name, spacer)
|
||||
return "/".join(sanitize_filename(p, spacer) for p in folder_name.split("/") if p)
|
||||
name = f"{self.artist} - {self.album}"
|
||||
if self.year:
|
||||
name += f" ({self.year})"
|
||||
|
||||
Reference in New Issue
Block a user