mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-05-17 06:09:29 +00:00
fix(template): detect folder spacer from template separators, not raw string
The previous heuristic checked the raw template string for dots, which could match dots inside variable names or title content, causing Plex-friendly folder names to incorrectly use dots as spacers. Now strips template variables first and checks only the separators between them to determine user intent.
This commit is contained in:
@@ -107,10 +107,9 @@ class Episode(Title):
|
||||
|
||||
folder_name = formatter.format(context)
|
||||
|
||||
if '.' in config.folder_template and ' ' not in config.folder_template:
|
||||
return sanitize_filename(folder_name, ".")
|
||||
else:
|
||||
return sanitize_filename(folder_name, " ")
|
||||
separators = re.sub(r'\{[^}]*\}', '', config.folder_template)
|
||||
spacer = "." if "." in separators and " " not in separators else " "
|
||||
return sanitize_filename(folder_name, spacer)
|
||||
|
||||
series_template = config.output_template.get("series")
|
||||
if series_template:
|
||||
@@ -130,10 +129,9 @@ class Episode(Title):
|
||||
|
||||
folder_name = formatter.format(context)
|
||||
|
||||
if '.' in series_template and ' ' not in series_template:
|
||||
return sanitize_filename(folder_name, ".")
|
||||
else:
|
||||
return sanitize_filename(folder_name, " ")
|
||||
separators = re.sub(r'\{[^}]*\}', '', derived_template)
|
||||
spacer = "." if "." in separators and " " not in separators else " "
|
||||
return sanitize_filename(folder_name, spacer)
|
||||
else:
|
||||
name = f"{self.title}"
|
||||
if self.year:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import re
|
||||
from abc import ABC
|
||||
from typing import Any, Iterable, Optional, Union
|
||||
|
||||
@@ -63,10 +64,10 @@ class Movie(Title):
|
||||
formatter = TemplateFormatter(config.folder_template)
|
||||
context = self._build_template_context(media_info, show_service)
|
||||
folder_name = formatter.format(context)
|
||||
if '.' in config.folder_template and ' ' not in config.folder_template:
|
||||
return sanitize_filename(folder_name, ".")
|
||||
else:
|
||||
return sanitize_filename(folder_name, " ")
|
||||
|
||||
separators = re.sub(r'\{[^}]*\}', '', config.folder_template)
|
||||
spacer = "." if "." in separators and " " not in separators else " "
|
||||
return sanitize_filename(folder_name, spacer)
|
||||
name = f"{self.name}"
|
||||
if self.year:
|
||||
name += f" ({self.year})"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import re
|
||||
from abc import ABC
|
||||
from typing import Any, Iterable, Optional, Union
|
||||
|
||||
@@ -98,10 +99,10 @@ class Song(Title):
|
||||
formatter = TemplateFormatter(config.folder_template)
|
||||
context = self._build_template_context(media_info, show_service)
|
||||
folder_name = formatter.format(context)
|
||||
if '.' in config.folder_template and ' ' not in config.folder_template:
|
||||
return sanitize_filename(folder_name, ".")
|
||||
else:
|
||||
return sanitize_filename(folder_name, " ")
|
||||
|
||||
separators = re.sub(r'\{[^}]*\}', '', config.folder_template)
|
||||
spacer = "." if "." in separators and " " not in separators else " "
|
||||
return sanitize_filename(folder_name, spacer)
|
||||
name = f"{self.artist} - {self.album}"
|
||||
if self.year:
|
||||
name += f" ({self.year})"
|
||||
|
||||
Reference in New Issue
Block a user