Tests for music video (vid + playlist) download (#48)
This commit is contained in:
parent
a80a834924
commit
56cc17e13c
4 changed files with 157 additions and 10 deletions
|
|
@ -33,7 +33,7 @@ presets:
|
||||||
# We set both with {music_video_name}, which is a variable we define in
|
# We set both with {music_video_name}, which is a variable we define in
|
||||||
# the overrides section further below to represent consistent naming format.
|
# the overrides section further below to represent consistent naming format.
|
||||||
output_options:
|
output_options:
|
||||||
output_directory: "{music_video_directory}/{artist_sanitized}"
|
output_directory: "{music_video_directory}"
|
||||||
file_name: "{music_video_name}.{ext}"
|
file_name: "{music_video_name}.{ext}"
|
||||||
thumbnail_name: "{music_video_name}.jpg"
|
thumbnail_name: "{music_video_name}.jpg"
|
||||||
|
|
||||||
|
|
@ -50,7 +50,7 @@ presets:
|
||||||
nfo_root: "musicvideo"
|
nfo_root: "musicvideo"
|
||||||
tags:
|
tags:
|
||||||
artist: "{artist}"
|
artist: "{artist}"
|
||||||
title: "{title}"
|
title: "{track_title}"
|
||||||
album: "Music Videos"
|
album: "Music Videos"
|
||||||
year: "{upload_year}"
|
year: "{upload_year}"
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ presets:
|
||||||
# here, which gets reused above for the video, thumbnail, and NFO file.
|
# here, which gets reused above for the video, thumbnail, and NFO file.
|
||||||
overrides:
|
overrides:
|
||||||
music_video_directory: "path/to/Music Videos"
|
music_video_directory: "path/to/Music Videos"
|
||||||
music_video_name: "{artist_sanitized} - {title_sanitized}"
|
music_video_name: "{artist_sanitized} - {track_title_sanitized}"
|
||||||
|
|
||||||
# It is not always ideal to download all of an artist's music videos.
|
# It is not always ideal to download all of an artist's music videos.
|
||||||
# Maybe you only like one song of theirs. We can reuse our preset above
|
# Maybe you only like one song of theirs. We can reuse our preset above
|
||||||
|
|
|
||||||
9
tests/e2e/conftest.py
Normal file
9
tests/e2e/conftest.py
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture()
|
||||||
|
def output_directory():
|
||||||
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
|
yield temp_dir
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import tempfile
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import mergedeep
|
import mergedeep
|
||||||
|
|
@ -10,12 +9,6 @@ from ytdl_sub.config.preset import Preset
|
||||||
from ytdl_sub.subscriptions.subscription import Subscription
|
from ytdl_sub.subscriptions.subscription import Subscription
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
|
||||||
def output_directory():
|
|
||||||
with tempfile.TemporaryDirectory() as temp_dir:
|
|
||||||
yield temp_dir
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def config_path():
|
def config_path():
|
||||||
return "examples/kodi_tv_shows_config.yaml"
|
return "examples/kodi_tv_shows_config.yaml"
|
||||||
|
|
|
||||||
145
tests/e2e/youtube/test_playlist_as_kodi_music_videos.py
Normal file
145
tests/e2e/youtube/test_playlist_as_kodi_music_videos.py
Normal file
|
|
@ -0,0 +1,145 @@
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import mergedeep
|
||||||
|
import pytest
|
||||||
|
from e2e.expected_download import ExpectedDownload
|
||||||
|
|
||||||
|
from ytdl_sub.config.config_file import ConfigFile
|
||||||
|
from ytdl_sub.config.preset import Preset
|
||||||
|
from ytdl_sub.subscriptions.subscription import Subscription
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def config_path():
|
||||||
|
return "examples/kodi_music_videos_config.yaml"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def subscription_name():
|
||||||
|
return "jmc"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def config(config_path):
|
||||||
|
return ConfigFile.from_file_path(config_path=config_path)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def subscription_dict(output_directory, subscription_name):
|
||||||
|
return {
|
||||||
|
"preset": "yt_music_video_playlist",
|
||||||
|
"youtube": {"playlist_id": "PL5BC0FC26BECA5A35"},
|
||||||
|
# override the output directory with our fixture-generated dir
|
||||||
|
"output_options": {"output_directory": output_directory},
|
||||||
|
# download the worst format so it is fast
|
||||||
|
"ytdl_options": {
|
||||||
|
"format": "worst[ext=mp4]",
|
||||||
|
},
|
||||||
|
"overrides": {"artist": "JMC"},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
####################################################################################################
|
||||||
|
# PLAYLIST FIXTURES
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def playlist_subscription(config, subscription_name, subscription_dict):
|
||||||
|
playlist_preset = Preset.from_dict(
|
||||||
|
config=config,
|
||||||
|
preset_name=subscription_name,
|
||||||
|
preset_dict=subscription_dict,
|
||||||
|
)
|
||||||
|
|
||||||
|
return Subscription.from_preset(
|
||||||
|
preset=playlist_preset,
|
||||||
|
config=config,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def expected_playlist_download():
|
||||||
|
# turn off black formatter here for readability
|
||||||
|
# fmt: off
|
||||||
|
return ExpectedDownload(
|
||||||
|
expected_md5_file_hashes={
|
||||||
|
# Download mapping
|
||||||
|
Path(".ytdl-sub-jmc-download-archive.json"): "4c368c5a12dc3ddb4c9d68fd9a782f24",
|
||||||
|
|
||||||
|
# Entry files
|
||||||
|
Path("JMC - Jesse's Minecraft Server [Trailer - Feb.1].jpg"): "048a19cf0f674437351872c3f312ebf1",
|
||||||
|
Path("JMC - Jesse's Minecraft Server [Trailer - Feb.1].mp4"): "e66287b9832277b6a4d1554e29d9fdcc",
|
||||||
|
Path("JMC - Jesse's Minecraft Server [Trailer - Feb.1].nfo"): "3d272fe58487b6011ad049b6000b046f",
|
||||||
|
|
||||||
|
Path("JMC - Given to Fly.jpg"): "2e58e4d5f06ce5d1c3336fa493470135",
|
||||||
|
Path("JMC - Given to Fly.mp4"): "04ab5cb3cc12325d0c96a7cd04a8b91d",
|
||||||
|
Path("JMC - Given to Fly.nfo"): "0dc578bf5f1ceb6e069a57d329894f35",
|
||||||
|
|
||||||
|
Path("JMC - Indifference (Remastered).jpg"): "9baaddc6b62f5b9ae3781eb4eef0e3b3",
|
||||||
|
Path("JMC - Indifference (Remastered).mp4"): "025de6099a5c98e6397153c7a62d517d",
|
||||||
|
Path("JMC - Indifference (Remastered).nfo"): "061b86d9dc8fb39d39feab3292dafeb0",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
|
|
||||||
|
####################################################################################################
|
||||||
|
# SINGLE VIDEO FIXTURES
|
||||||
|
@pytest.fixture
|
||||||
|
def single_video_subscription_dict(subscription_dict):
|
||||||
|
del subscription_dict["youtube"]
|
||||||
|
|
||||||
|
return mergedeep.merge(
|
||||||
|
subscription_dict,
|
||||||
|
{
|
||||||
|
"preset": "yt_music_video",
|
||||||
|
"youtube": {"video_id": "HKTNxEqsN3Q"},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def single_video_subscription(config, subscription_name, single_video_subscription_dict):
|
||||||
|
single_video_preset = Preset.from_dict(
|
||||||
|
config=config,
|
||||||
|
preset_name=subscription_name,
|
||||||
|
preset_dict=single_video_subscription_dict,
|
||||||
|
)
|
||||||
|
|
||||||
|
return Subscription.from_preset(
|
||||||
|
preset=single_video_preset,
|
||||||
|
config=config,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def expected_single_video_download():
|
||||||
|
# turn off black formatter here for readability
|
||||||
|
# fmt: off
|
||||||
|
return ExpectedDownload(
|
||||||
|
expected_md5_file_hashes={
|
||||||
|
Path("JMC - Whale & Wasp.jpg"): "b58377dfe7c39527e1990a24b36bbd77",
|
||||||
|
Path("JMC - Whale & Wasp.mp4"): "931a705864c57d21d6fedebed4af6bbc",
|
||||||
|
Path("JMC - Whale & Wasp.nfo"): "6c2f085adb847c1dcc47c19514c454d8",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
|
|
||||||
|
class TestPlaylistAsKodiMusicVideo:
|
||||||
|
"""
|
||||||
|
Downloads my old minecraft youtube channel, pretends they are music videos. Ensure the above
|
||||||
|
files exist and have the expected md5 file hashes.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def test_playlist_download(
|
||||||
|
self, playlist_subscription, expected_playlist_download, output_directory
|
||||||
|
):
|
||||||
|
playlist_subscription.download()
|
||||||
|
expected_playlist_download.assert_files_exist(relative_directory=output_directory)
|
||||||
|
|
||||||
|
def test_single_video_download(
|
||||||
|
self, single_video_subscription, expected_single_video_download, output_directory
|
||||||
|
):
|
||||||
|
single_video_subscription.download()
|
||||||
|
expected_single_video_download.assert_files_exist(relative_directory=output_directory)
|
||||||
Loading…
Reference in a new issue