mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-24 09:55:12 +00:00
fix(naming): correct language tag rule matching and add state conditions
Rules took only a scalar, so the documented list syntax raised LanguageTagError after the mux. Normalise every condition, treat an invalid tag as no match, guard the surrounding post-mux config reads, and let a rule match dual, multi and dubbed so a release can carry its own tag.
This commit is contained in:
@@ -258,7 +258,11 @@ class Episode(Title):
|
||||
name += f" {self.folder_season()}"
|
||||
return sanitize_filename(name, " ")
|
||||
|
||||
formatter = TemplateFormatter(config.output_template["series"])
|
||||
template = config.output_template.get("series")
|
||||
if not template:
|
||||
return sanitize_filename(str(self), " ")
|
||||
|
||||
formatter = TemplateFormatter(template)
|
||||
context = self.build_template_context(media_info, show_service)
|
||||
return formatter.format(context)
|
||||
|
||||
|
||||
@@ -76,7 +76,11 @@ class Movie(Title):
|
||||
name += f" ({self.year})"
|
||||
return sanitize_filename(name, " ")
|
||||
|
||||
formatter = TemplateFormatter(config.output_template["movies"])
|
||||
template = config.output_template.get("movies")
|
||||
if not template:
|
||||
return sanitize_filename(str(self), " ")
|
||||
|
||||
formatter = TemplateFormatter(template)
|
||||
context = self.build_template_context(media_info, show_service)
|
||||
return formatter.format(context)
|
||||
|
||||
|
||||
@@ -213,13 +213,15 @@ class Title:
|
||||
if original_lang_tag and original_lang_tag not in audio_lang_bases:
|
||||
context["dubbed"] = "DUBBED"
|
||||
|
||||
lang_tag_rules = config.language_tags.get("rules") if config.language_tags else None
|
||||
language_tags = config.language_tags if isinstance(config.language_tags, dict) else {}
|
||||
lang_tag_rules = language_tags.get("rules")
|
||||
if lang_tag_rules and self.tracks:
|
||||
from unshackle.core.utils.language_tags import evaluate_language_tag
|
||||
|
||||
audio_langs = [a.language for a in self.tracks.audio]
|
||||
sub_langs = [s.language for s in self.tracks.subtitles]
|
||||
context["lang_tag"] = evaluate_language_tag(lang_tag_rules, audio_langs, sub_langs)
|
||||
states = {name: bool(context[name]) for name in ("dual", "multi", "dubbed")}
|
||||
context["lang_tag"] = evaluate_language_tag(lang_tag_rules, audio_langs, sub_langs, states)
|
||||
|
||||
if config.tag_rules:
|
||||
from unshackle.core.utils.tag_rules import evaluate_tag_rules
|
||||
|
||||
Reference in New Issue
Block a user