feat(export): separate export file name parts with dots

Titles, scope and quality parts use dots and never follow output_template.
This commit is contained in:
imSp4rky
2026-09-23 15:26:46 -06:00
parent 878838de30
commit d014c69d00
3 changed files with 47 additions and 31 deletions
+7 -7
View File
@@ -1,7 +1,8 @@
"""The file name of a ``dl --export`` file, built from the titles and tracks it holds.
The name has the form ``{title} {scope}_{resolutions}_{codecs}_{ranges}_{manifests}_{audio}-{TAG}``,
for example ``Example Show S01_2160p_h265_sdr_hdr10_dash_ddp5.1-EXAMPLE``. An empty part is left out.
The name has the form ``{title}.{scope}.{resolutions}.{codecs}.{ranges}.{manifests}.{audio}-{TAG}``,
for example ``Example.Show.S01.2160p.h265.sdr.hdr10.dash.ddp5.1-EXAMPLE``. An empty part is left out.
The name always uses dots and never reads the output templates.
"""
from __future__ import annotations
@@ -60,11 +61,11 @@ def title_part(titles: Sequence[Title_T]) -> str:
text += f" +{others}"
else:
text = str(first)
return sanitize_filename(text, spacer=" ", unicode=True)[:MAX_TITLE_LENGTH].strip(" .")
return sanitize_filename(text, spacer=".", unicode=True)[:MAX_TITLE_LENGTH].strip(" .")
def scope_part(titles: Sequence[Title_T], seasons: Mapping[int, Collection[int]]) -> str:
"""``S01`` for a whole season, ``S01E05-E09`` for a run of episodes, runs joined with ``_``.
"""``S01`` for a whole season, ``S01E05-E09`` for a run of episodes, runs joined with ``.``.
A season counts as whole only when every episode the service listed for it is in ``titles``.
Whole seasons in a row collapse to ``S01-S03``. After ``MAX_SCOPE_PARTS`` parts, ``+N``
@@ -102,7 +103,7 @@ def scope_part(titles: Sequence[Title_T], seasons: Mapping[int, Collection[int]]
if len(parts) > MAX_SCOPE_PARTS:
parts = [*parts[:MAX_SCOPE_PARTS], f"+{len(parts) - MAX_SCOPE_PARTS}"]
return "_".join(parts)
return ".".join(parts)
def resolution(track: Video) -> Optional[int]:
@@ -169,8 +170,7 @@ def export_name(
"""
head = title_part(titles) if titles else ""
scope = scope_part(titles, seasons or {}) if titles and isinstance(titles[0], Episode) else ""
head = f"{head} {scope}".strip()
return "_".join(p for p in (head, *quality_parts(tracks)) if p) + f"-{service_tag}"
return ".".join(p for p in (head, scope, *quality_parts(tracks)) if p) + f"-{service_tag}"
def move_export(current: Path, name: str) -> Path: