[DEV] Custom ffmpeg unit test (#1076)

This commit is contained in:
Jesse Bannon 2024-09-30 22:04:52 -07:00 committed by GitHub
parent 01e1f46b86
commit 481ced34c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 162 additions and 61 deletions

View file

@ -1,7 +1,6 @@
import pytest
from expected_download import assert_expected_downloads
from expected_transaction_log import assert_transaction_log_matches
from mergedeep import mergedeep
from ytdl_sub.subscriptions.subscription import Subscription
@ -46,39 +45,3 @@ class TestFileConvert:
dry_run=dry_run,
expected_download_summary_file_name="plugins/file_convert/output.json",
)
@pytest.mark.parametrize("dry_run", [True, False])
def test_file_convert_custom_ffmpeg(
self,
default_config,
preset_dict,
output_directory,
dry_run,
):
mergedeep.merge(
preset_dict,
{
"file_convert": {
"convert_to": "mkv",
"convert_with": "ffmpeg",
"ffmpeg_post_process_args": "-bitexact -vcodec copy -acodec copy -scodec mov_text",
}
},
)
subscription = Subscription.from_dict(
config=default_config,
preset_name="file_convert_test",
preset_dict=preset_dict,
)
transaction_log = subscription.download(dry_run=dry_run)
assert_transaction_log_matches(
output_directory=output_directory,
transaction_log=transaction_log,
transaction_log_summary_file_name="plugins/file_convert/output_custom_ffmpeg.txt",
)
assert_expected_downloads(
output_directory=output_directory,
dry_run=dry_run,
expected_download_summary_file_name="plugins/file_convert/output_custom_ffmpeg.json",
)

View file

@ -0,0 +1,19 @@
{
".ytdl-sub-subscription_test-download-archive.json": "19cf39d57914ba9cbd1e57ba6f1e0683",
"JMC/Mock Entry 20-1.info.json": "INFO_JSON",
"JMC/Mock Entry 20-1.jpg": "e80c508c4818454300133fe1dc1a9cd7",
"JMC/Mock Entry 20-1.mkv": "1514f89a141f7b5ee3fdde9a70e63f57",
"JMC/Mock Entry 20-1.nfo": "fefcf0b3e4f4ff80ad636584d50dadec",
"JMC/Mock Entry 20-2.info.json": "INFO_JSON",
"JMC/Mock Entry 20-2.jpg": "e80c508c4818454300133fe1dc1a9cd7",
"JMC/Mock Entry 20-2.mkv": "da089645cc944fdb411ecc46facfe9f6",
"JMC/Mock Entry 20-2.nfo": "025c0b631da5ff5470382b38fce78d2d",
"JMC/Mock Entry 20-3.info.json": "INFO_JSON",
"JMC/Mock Entry 20-3.jpg": "e80c508c4818454300133fe1dc1a9cd7",
"JMC/Mock Entry 20-3.mkv": "5dbae183aa57c4062af9d5a2e0e0f8fe",
"JMC/Mock Entry 20-3.nfo": "618b0ff948d9de2e10cf1da8c0dd6615",
"JMC/Mock Entry 21-1.info.json": "INFO_JSON",
"JMC/Mock Entry 21-1.jpg": "e80c508c4818454300133fe1dc1a9cd7",
"JMC/Mock Entry 21-1.mkv": "61910bf74a0175fbdf595095109d1a1c",
"JMC/Mock Entry 21-1.nfo": "e5c715749efc1603a6e2f59244d87aba"
}

View file

@ -0,0 +1,81 @@
Files created:
----------------------------------------
{output_directory}
.ytdl-sub-subscription_test-download-archive.json
{output_directory}/JMC
Mock Entry 20-1.info.json
Mock Entry 20-1.jpg
Mock Entry 20-1.mkv
Converted from mp4
Video Tags:
album: Music Videos
artist: JMC
genre: ytdl-sub
premiered: 2020-08-08
title: Mock Entry 20-1
year: 2020
Mock Entry 20-1.nfo
NFO tags:
musicvideo:
album: Music Videos
artist: JMC
genre: ytdl-sub
premiered: 2020-08-08
title: Mock Entry 20-1
Mock Entry 20-2.info.json
Mock Entry 20-2.jpg
Mock Entry 20-2.mkv
Converted from mp4
Video Tags:
album: Music Videos
artist: JMC
genre: ytdl-sub
premiered: 2020-08-08
title: Mock Entry 20-2
year: 2020
Mock Entry 20-2.nfo
NFO tags:
musicvideo:
album: Music Videos
artist: JMC
genre: ytdl-sub
premiered: 2020-08-08
title: Mock Entry 20-2
Mock Entry 20-3.info.json
Mock Entry 20-3.jpg
Mock Entry 20-3.mkv
Converted from mp4
Video Tags:
album: Music Videos
artist: JMC
genre: ytdl-sub
premiered: 2020-08-07
title: Mock Entry 20-3
year: 2020
Mock Entry 20-3.nfo
NFO tags:
musicvideo:
album: Music Videos
artist: JMC
genre: ytdl-sub
premiered: 2020-08-07
title: Mock Entry 20-3
Mock Entry 21-1.info.json
Mock Entry 21-1.jpg
Mock Entry 21-1.mkv
Converted from mp4
Video Tags:
album: Music Videos
artist: JMC
genre: ytdl-sub
premiered: 2021-08-08
title: Mock Entry 21-1
year: 2021
Mock Entry 21-1.nfo
NFO tags:
musicvideo:
album: Music Videos
artist: JMC
genre: ytdl-sub
premiered: 2021-08-08
title: Mock Entry 21-1

View file

@ -1,24 +0,0 @@
Files created:
----------------------------------------
{output_directory}
.ytdl-sub-file_convert_test-download-archive.json
{output_directory}/file_convert_test
When you hear Hugh Jackman is returning as Wolverine in Deadpool 3.info.json
When you hear Hugh Jackman is returning as Wolverine in Deadpool 3.jpg
When you hear Hugh Jackman is returning as Wolverine in Deadpool 3.mkv
Converted from mp4
Video Tags:
album: Music Videos
artist: file_convert_test
genre: ytdl-sub
premiered: 2022-09-28
title: When you hear Hugh Jackman is returning as Wolverine in Deadpool 3
year: 2022
When you hear Hugh Jackman is returning as Wolverine in Deadpool 3.nfo
NFO tags:
musicvideo:
album: Music Videos
artist: file_convert_test
genre: ytdl-sub
premiered: 2022-09-28
title: When you hear Hugh Jackman is returning as Wolverine in Deadpool 3

View file

@ -0,0 +1,62 @@
from typing import Dict
import pytest
from expected_download import assert_expected_downloads
from expected_transaction_log import assert_transaction_log_matches
from ytdl_sub.entries.entry import ytdl_sub_chapters_from_comments
from ytdl_sub.subscriptions.subscription import Subscription
@pytest.fixture
def file_convert_subscription_dict(output_directory) -> Dict:
return {
"preset": "Jellyfin Music Videos",
"output_options": {"output_directory": output_directory},
"overrides": {
"music_video_artist": "JMC",
"url": "https://your.name.here",
},
"file_convert": {
"convert_to": "mkv",
"convert_with": "ffmpeg",
"ffmpeg_post_process_args": "-bitexact -vcodec copy -acodec copy -scodec mov_text",
},
}
class TestChapters:
@pytest.mark.parametrize("dry_run", [True, False])
def test_file_convert_custom_args(
self,
config,
subscription_name,
file_convert_subscription_dict,
output_directory,
mock_download_collection_entries,
dry_run,
):
subscription = Subscription.from_dict(
config=config,
preset_name=subscription_name,
preset_dict=file_convert_subscription_dict,
)
with mock_download_collection_entries(
is_youtube_channel=False,
num_urls=1,
is_extracted_audio=False,
is_dry_run=dry_run,
):
transaction_log = subscription.download(dry_run=dry_run)
assert_transaction_log_matches(
output_directory=output_directory,
transaction_log=transaction_log,
transaction_log_summary_file_name=f"plugins/file_convert/custom_ffmpeg_args.txt",
)
assert_expected_downloads(
output_directory=output_directory,
dry_run=dry_run,
expected_download_summary_file_name="plugins/file_convert/custom_ffmpeg_args.json",
)