Skip to content

Commit

Permalink
[DEV] Custom ffmpeg unit test (#1076)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbannon authored Oct 1, 2024
1 parent 01e1f46 commit 481ced3
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 61 deletions.
37 changes: 0 additions & 37 deletions tests/e2e/plugins/test_file_convert.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -46,39 +45,3 @@ def test_file_convert(
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",
)
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -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

This file was deleted.

62 changes: 62 additions & 0 deletions tests/unit/plugins/test_file_convert.py
Original file line number Diff line number Diff line change
@@ -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",
)

0 comments on commit 481ced3

Please sign in to comment.