fix(export): name the file from the first write

This commit is contained in:
imSp4rky
2026-09-23 15:11:15 -06:00
parent 347668eafa
commit a19c3e3879
3 changed files with 10 additions and 3 deletions
+2 -1
View File
@@ -800,7 +800,8 @@ The file name tells what the file holds, in the form
- The scope is `S01` only when the file holds every episode the service lists for that season.
Otherwise it names each run of episodes. Whole seasons in a row become `S01-S03`. After three
parts, `+N` counts the parts left out. A movie has no scope.
- The quality parts come from the tracks in the file. Each value shows once.
- The quality parts come from the video and audio tracks selected for the titles in the file.
Each value shows once.
- unshackle renames the file after each write, so the name always matches what the file holds.
When a run stops early, the file is complete for the titles it holds.
- When another file already has the name, unshackle adds `-2`, `-3`, and so on. It never
+1 -1
View File
@@ -214,7 +214,7 @@ def test_export_messages(tmp_path: Path, caplog: pytest.LogCaptureFixture) -> No
instance.log_export_summary()
lines = [r.getMessage() for r in caplog.records]
assert "Exporting to Example Movie 2024_1080p_h264_sdr_dash-EXAMPLE.json" in lines
assert "Exporting to Example Movie 2024_1080p_h264_sdr_dash_aac2.0-EXAMPLE.json" in lines
assert "Exported 'Example Movie' (2024): 1 video, 2 audio, 0 subtitles, 1 key" in lines
final = tmp_path / "Example Movie 2024_1080p_h264_sdr_dash_aac2.0-EXAMPLE.json"
assert f"Saved the export to {final}: 1 title, 1 key" in lines
+7 -1
View File
@@ -199,8 +199,14 @@ class ExportNamer:
self.path: Optional[Path] = None
def add(self, title: Title_T, track: AnyTrack) -> None:
"""Record ``track`` and the video and audio tracks selected for ``title``.
The first write of a title is often a subtitle, and a name from that track alone would
leave out the quality of the title.
"""
self.titles.setdefault(str(title.id), title)
self.tracks.setdefault(f"{title.id}/{track.id}", track)
for t in [track, *title.tracks.videos, *title.tracks.audio]:
self.tracks.setdefault(f"{title.id}/{t.id}", t)
def name(self) -> str:
return export_name(list(self.titles.values()), self.tracks.values(), self.service_tag, self.seasons)