- add season_overwrite and episode_overwrite for Schedule work
- print File path at the end of file for Schedule work - add discord downloader
This commit is contained in:
@@ -78,14 +78,25 @@ class Episode(Title):
|
||||
self.year = year
|
||||
self.description = description
|
||||
|
||||
def _build_template_context(self, media_info: MediaInfo, show_service: bool = True) -> dict:
|
||||
def _build_template_context(self, media_info: MediaInfo, show_service: bool = True,season_overwrite=None,episode_overwrite=None) -> dict:
|
||||
"""Build template context dictionary from MediaInfo."""
|
||||
context = self._build_base_template_context(media_info, show_service)
|
||||
context["title"] = self.title.replace("$", "S")
|
||||
context["year"] = self.year or ""
|
||||
context["season"] = f"S{self.season:02}"
|
||||
context["episode"] = f"E{self.number:02}"
|
||||
context["season_episode"] = f"S{self.season:02}E{self.number:02}"
|
||||
|
||||
if season_overwrite is not None:
|
||||
season = season_overwrite
|
||||
else:
|
||||
season = self.season
|
||||
|
||||
if episode_overwrite is not None:
|
||||
episode = episode_overwrite
|
||||
else:
|
||||
episode = self.number
|
||||
|
||||
context["season"] = f"S{season:02}"
|
||||
context["episode"] = f"E{episode:02}"
|
||||
context["season_episode"] = f"S{season:02}E{episode:02}"
|
||||
context["episode_name"] = self.name or ""
|
||||
return context
|
||||
|
||||
@@ -98,7 +109,7 @@ class Episode(Title):
|
||||
name=self.name or "",
|
||||
).strip()
|
||||
|
||||
def get_filename(self, media_info: MediaInfo, folder: bool = False, show_service: bool = True) -> str:
|
||||
def get_filename(self, media_info: MediaInfo, folder: bool = False, show_service: bool = True,season_overwrite=None,episode_overwrite=None) -> str:
|
||||
if folder:
|
||||
series_template = config.output_template.get("series")
|
||||
if series_template:
|
||||
@@ -114,7 +125,7 @@ class Episode(Title):
|
||||
|
||||
formatter = TemplateFormatter(folder_template)
|
||||
context = self._build_template_context(media_info, show_service)
|
||||
context['season'] = f"S{self.season:02}"
|
||||
context['season'] = f"S{self.season:02}" if not season_overwrite else f"S{season_overwrite:02}"
|
||||
|
||||
folder_name = formatter.format(context)
|
||||
|
||||
@@ -130,7 +141,7 @@ class Episode(Title):
|
||||
return sanitize_filename(name, " ")
|
||||
|
||||
formatter = TemplateFormatter(config.output_template["series"])
|
||||
context = self._build_template_context(media_info, show_service)
|
||||
context = self._build_template_context(media_info, show_service,season_overwrite,episode_overwrite)
|
||||
return formatter.format(context)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user