mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-12 20:15:10 +00:00
fix(export): name the file from the first write
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user