Hash audio profile paths

This commit is contained in:
Abel Luck 2026-03-31 15:14:17 +02:00
parent 2ad0536bb0
commit 23d03cd9d5
4 changed files with 59 additions and 41 deletions

View file

@ -66,12 +66,13 @@ def test_rss_spider_rewrites_public_asset_urls_as_relative_paths() -> None:
spider.rewrite_image_url("https://example.com/media/photo.jpg")
== f"images/{local_image_path('https://example.com/media/photo.jpg')}"
)
assert (
spider.rewrite_file_url(
FileType.AUDIO,
"https://example.com/media/podcast.mp3",
)
== f"audio/{local_audio_path('https://example.com/media/podcast.mp3')}-vbr7.mp3"
assert spider.rewrite_file_url(
FileType.AUDIO,
"https://example.com/media/podcast.mp3",
) == (
"audio/"
f"{local_audio_path('https://example.com/media/podcast.mp3')}"
"-vbr7-3b2b0f13.mp3"
)
assert spider.rewrite_file_url(
FileType.VIDEO,
@ -83,17 +84,23 @@ def test_rss_spider_rewrites_public_asset_urls_as_relative_paths() -> None:
)
def test_published_video_path_changes_when_profile_args_change() -> None:
def test_published_media_path_changes_when_profile_args_change() -> None:
source_url = "https://example.com/media/clip.mp4"
audio_profile = repub_settings.REPUBLISHER_AUDIO[0]
base_profile = repub_settings.REPUBLISHER_VIDEO[0]
assert published_media_path(
FileType.AUDIO, source_url, repub_settings.REPUBLISHER_AUDIO[0]
) == (f"{local_audio_path(source_url)}-vbr7.mp3")
assert published_media_path(FileType.AUDIO, source_url, audio_profile) == (
f"{local_audio_path(source_url)}-vbr7-3b2b0f13.mp3"
)
assert published_media_path(FileType.VIDEO, source_url, base_profile) == (
f"{local_video_path(source_url)}-720-457f0928.mp4"
)
changed_audio_profile = {**audio_profile, "max_bitrate": 128000}
assert published_media_path(
FileType.AUDIO, source_url, changed_audio_profile
) != published_media_path(FileType.AUDIO, source_url, audio_profile)
changed_profile = {**base_profile, "max_height": 1080}
assert published_media_path(
FileType.VIDEO, source_url, changed_profile