Include original media in media groups
This commit is contained in:
parent
89d462e280
commit
954608c5f9
3 changed files with 212 additions and 14 deletions
|
|
@ -233,7 +233,7 @@ def test_audio_pipeline_media_downloaded_returns_canonical_file_info_and_variant
|
|||
return str(output_path)
|
||||
|
||||
def fake_probe_media(file_path: str):
|
||||
if file_path.endswith("vbr7.mp3"):
|
||||
if file_path.endswith(".mp3-vbr7.mp3"):
|
||||
return {
|
||||
"format": {
|
||||
"duration": "61.2",
|
||||
|
|
@ -253,6 +253,26 @@ def test_audio_pipeline_media_downloaded_returns_canonical_file_info_and_variant
|
|||
}
|
||||
],
|
||||
}
|
||||
if file_path.endswith(".mp3"):
|
||||
return {
|
||||
"format": {
|
||||
"duration": "61.2",
|
||||
"size": "5678",
|
||||
"bit_rate": "128000",
|
||||
"format_name": "mp3",
|
||||
"format_long_name": "MP3",
|
||||
},
|
||||
"streams": [
|
||||
{
|
||||
"codec_type": "audio",
|
||||
"codec_name": "mp3",
|
||||
"bit_rate": "128000",
|
||||
"duration_ts": "61200",
|
||||
"sample_rate": "44100",
|
||||
"channels": 2,
|
||||
}
|
||||
],
|
||||
}
|
||||
return {
|
||||
"format": {
|
||||
"duration": "61.2",
|
||||
|
|
@ -333,9 +353,22 @@ def test_audio_pipeline_media_downloaded_returns_canonical_file_info_and_variant
|
|||
"samplingrate": 48000,
|
||||
"channels": 2,
|
||||
},
|
||||
{
|
||||
"url": f"https://mirror.example/feeds/nasa/audio/{audio_base_path}",
|
||||
"path": audio_base_path,
|
||||
"type": "audio/mpeg",
|
||||
"medium": "audio",
|
||||
"isDefault": "false",
|
||||
"fileSize": "5678",
|
||||
"bitrate": 128000,
|
||||
"duration": "61.2",
|
||||
"samplingrate": 44100,
|
||||
"channels": 2,
|
||||
},
|
||||
],
|
||||
}
|
||||
assert persisted == [
|
||||
(audio_base_path, "audio/mpeg"),
|
||||
(f"{audio_base_path}-vbr7.mp3", "audio/mp3"),
|
||||
(f"{audio_base_path}-vbr3.aac", "audio/aac"),
|
||||
]
|
||||
|
|
@ -383,8 +416,16 @@ def test_video_pipeline_media_downloaded_returns_canonical_file_info_and_variant
|
|||
lambda _: {
|
||||
"format": {
|
||||
"duration": "60.0",
|
||||
"size": "9876",
|
||||
"bit_rate": "123456",
|
||||
"size": (
|
||||
"12345"
|
||||
if _.endswith(".mp4") and not _.endswith("-720.mp4")
|
||||
else "9876"
|
||||
),
|
||||
"bit_rate": (
|
||||
"456789"
|
||||
if _.endswith(".mp4") and not _.endswith("-720.mp4")
|
||||
else "123456"
|
||||
),
|
||||
"format_name": "mp4",
|
||||
"format_long_name": "MP4",
|
||||
},
|
||||
|
|
@ -392,11 +433,27 @@ def test_video_pipeline_media_downloaded_returns_canonical_file_info_and_variant
|
|||
{
|
||||
"codec_type": "video",
|
||||
"codec_name": "h264",
|
||||
"bit_rate": "123456",
|
||||
"bit_rate": (
|
||||
"456789"
|
||||
if _.endswith(".mp4") and not _.endswith("-720.mp4")
|
||||
else "123456"
|
||||
),
|
||||
"duration_ts": "60000",
|
||||
"width": 1280,
|
||||
"height": 720,
|
||||
"avg_frame_rate": "30/1",
|
||||
"width": (
|
||||
640
|
||||
if _.endswith(".mp4") and not _.endswith("-720.mp4")
|
||||
else 1280
|
||||
),
|
||||
"height": (
|
||||
360
|
||||
if _.endswith(".mp4") and not _.endswith("-720.mp4")
|
||||
else 720
|
||||
),
|
||||
"avg_frame_rate": (
|
||||
"24/1"
|
||||
if _.endswith(".mp4") and not _.endswith("-720.mp4")
|
||||
else "30/1"
|
||||
),
|
||||
},
|
||||
{
|
||||
"codec_type": "audio",
|
||||
|
|
@ -451,10 +508,26 @@ def test_video_pipeline_media_downloaded_returns_canonical_file_info_and_variant
|
|||
"width": 1280,
|
||||
"height": 720,
|
||||
"framerate": "30/1",
|
||||
}
|
||||
},
|
||||
{
|
||||
"url": f"https://mirror.example/feeds/nasa/video/{video_base_path}",
|
||||
"path": video_base_path,
|
||||
"type": "video/mp4",
|
||||
"medium": "video",
|
||||
"isDefault": "false",
|
||||
"fileSize": "12345",
|
||||
"bitrate": 456789,
|
||||
"duration": "60.0",
|
||||
"width": 640,
|
||||
"height": 360,
|
||||
"framerate": "24/1",
|
||||
},
|
||||
],
|
||||
}
|
||||
assert persisted == [(f"{video_base_path}-720.mp4", "video/mp4")]
|
||||
assert persisted == [
|
||||
(video_base_path, "video/mp4"),
|
||||
(f"{video_base_path}-720.mp4", "video/mp4"),
|
||||
]
|
||||
|
||||
|
||||
def test_audio_pipeline_media_to_download_checks_canonical_path(
|
||||
|
|
@ -465,8 +538,11 @@ def test_audio_pipeline_media_to_download_checks_canonical_path(
|
|||
monkeypatch.setattr(pipeline, "inc_stats", lambda status: None)
|
||||
source_url = "https://example.com/podcast.mp3"
|
||||
audio_base_path = local_audio_path(source_url)
|
||||
original_path = store_dir(pipeline) / audio_base_path
|
||||
canonical_path = store_dir(pipeline) / f"{audio_base_path}-vbr7.mp3"
|
||||
secondary_path = store_dir(pipeline) / f"{audio_base_path}-vbr3.aac"
|
||||
original_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
original_path.write_bytes(b"original")
|
||||
canonical_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
canonical_path.write_bytes(b"default")
|
||||
secondary_path.write_bytes(b"alt")
|
||||
|
|
@ -524,5 +600,10 @@ def test_audio_pipeline_media_to_download_checks_canonical_path(
|
|||
assert result is not None
|
||||
assert result["path"] == f"{audio_base_path}-vbr7.mp3"
|
||||
assert result["status"] == "uptodate"
|
||||
assert [variant.get("path") for variant in result["variants"]] == [
|
||||
f"{audio_base_path}-vbr7.mp3",
|
||||
f"{audio_base_path}-vbr3.aac",
|
||||
audio_base_path,
|
||||
]
|
||||
assert f"{audio_base_path}.mp3" not in stat_paths
|
||||
assert stat_paths[0] == f"{audio_base_path}-vbr7.mp3"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue