integration almost there
This commit is contained in:
parent
6515a619d9
commit
252aa36f1a
6 changed files with 132 additions and 30 deletions
|
|
@ -86,6 +86,11 @@ class ConfigFile(ConfigValidator):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def default(cls) -> "ConfigFile":
|
def default(cls) -> "ConfigFile":
|
||||||
|
"""
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
Config initialized with all defaults
|
||||||
|
"""
|
||||||
return ConfigFile(name="default_config", value={})
|
return ConfigFile(name="default_config", value={})
|
||||||
|
|
||||||
def as_dict(self) -> Dict[str, Any]:
|
def as_dict(self) -> Dict[str, Any]:
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
from ytdl_sub.prebuilt_presets import _, PrebuiltPresets
|
from ytdl_sub.prebuilt_presets import PrebuiltPresets
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MusicPresets(PrebuiltPresets):
|
class MusicPresets(PrebuiltPresets):
|
||||||
|
preset_names = {
|
||||||
kodi_tv_show_by_date = _
|
"Single",
|
||||||
jellyfin_tv_show_by_date = _
|
"SoundCloud Discography",
|
||||||
plex_tv_show_by_date = _
|
"YouTube Releases",
|
||||||
|
"YouTube Full Albums",
|
||||||
|
"Bandcamp",
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ class TvShowByDatePresets(PrebuiltPresets):
|
||||||
TV Show by Date presets create a TV show from a single URL using upload dates as season/episode
|
TV Show by Date presets create a TV show from a single URL using upload dates as season/episode
|
||||||
numbers.
|
numbers.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
preset_names = {
|
preset_names = {
|
||||||
"kodi_tv_show_by_date",
|
"kodi_tv_show_by_date",
|
||||||
"jellyfin_tv_show_by_date",
|
"jellyfin_tv_show_by_date",
|
||||||
|
|
|
||||||
|
|
@ -186,6 +186,4 @@ def tv_show_subscriptions_path() -> Path:
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def music_audio_config(working_directory) -> ConfigFile:
|
def music_audio_config(working_directory) -> ConfigFile:
|
||||||
return ConfigFile.from_dict(
|
return ConfigFile.from_dict({"configuration": {"working_directory": working_directory}})
|
||||||
{"configuration": {"working_directory": working_directory}}
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ from expected_transaction_log import assert_transaction_log_matches
|
||||||
from ytdl_sub.downloaders.ytdlp import YTDLP
|
from ytdl_sub.downloaders.ytdlp import YTDLP
|
||||||
from ytdl_sub.subscriptions.subscription import Subscription
|
from ytdl_sub.subscriptions.subscription import Subscription
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def subscription_dict(output_directory):
|
def subscription_dict(output_directory):
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,11 @@ import pytest
|
||||||
from expected_download import assert_expected_downloads
|
from expected_download import assert_expected_downloads
|
||||||
from expected_transaction_log import assert_transaction_log_matches
|
from expected_transaction_log import assert_transaction_log_matches
|
||||||
|
|
||||||
from ytdl_sub.prebuilt_presets.tv_show import TvShowByDatePresets
|
from ytdl_sub.prebuilt_presets.music import MusicPresets
|
||||||
from ytdl_sub.prebuilt_presets.tv_show import TvShowCollectionPresets
|
|
||||||
from ytdl_sub.prebuilt_presets.tv_show import TvShowByDateEpisodeFormattingPresets
|
from ytdl_sub.prebuilt_presets.tv_show import TvShowByDateEpisodeFormattingPresets
|
||||||
|
from ytdl_sub.prebuilt_presets.tv_show import TvShowByDatePresets
|
||||||
from ytdl_sub.prebuilt_presets.tv_show import TvShowCollectionEpisodeFormattingPresets
|
from ytdl_sub.prebuilt_presets.tv_show import TvShowCollectionEpisodeFormattingPresets
|
||||||
|
from ytdl_sub.prebuilt_presets.tv_show import TvShowCollectionPresets
|
||||||
from ytdl_sub.prebuilt_presets.tv_show import TvShowCollectionSeasonPresets
|
from ytdl_sub.prebuilt_presets.tv_show import TvShowCollectionSeasonPresets
|
||||||
from ytdl_sub.subscriptions.subscription import Subscription
|
from ytdl_sub.subscriptions.subscription import Subscription
|
||||||
from ytdl_sub.utils.exceptions import ValidationException
|
from ytdl_sub.utils.exceptions import ValidationException
|
||||||
|
|
@ -342,3 +343,97 @@ class TestPrebuiltTvShowCollectionPresets:
|
||||||
dry_run=False,
|
dry_run=False,
|
||||||
expected_download_summary_file_name=f"{reformatted_expected_summary_name}_migrated.json",
|
expected_download_summary_file_name=f"{reformatted_expected_summary_name}_migrated.json",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("music_preset", MusicPresets.preset_names)
|
||||||
|
class TestPrebuiltMusicPresets:
|
||||||
|
def test_compilation(
|
||||||
|
self,
|
||||||
|
config,
|
||||||
|
music_preset: str,
|
||||||
|
):
|
||||||
|
_ = Subscription.from_dict(
|
||||||
|
config=config,
|
||||||
|
preset_name="preset_test",
|
||||||
|
preset_dict={
|
||||||
|
"preset": [
|
||||||
|
music_preset,
|
||||||
|
],
|
||||||
|
"overrides": {
|
||||||
|
"subscription_value": "https://your.name.here",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_presets_run(
|
||||||
|
self,
|
||||||
|
config,
|
||||||
|
subscription_name,
|
||||||
|
output_directory,
|
||||||
|
mock_download_collection_entries,
|
||||||
|
music_preset: str,
|
||||||
|
):
|
||||||
|
expected_summary_name = f"unit/music/{music_preset}"
|
||||||
|
|
||||||
|
preset_dict = {
|
||||||
|
"preset": [
|
||||||
|
music_preset,
|
||||||
|
],
|
||||||
|
"overrides": {
|
||||||
|
"url": "https://your.name.here",
|
||||||
|
"music_directory": output_directory,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
subscription = Subscription.from_dict(
|
||||||
|
config=config,
|
||||||
|
preset_name=subscription_name,
|
||||||
|
preset_dict=preset_dict,
|
||||||
|
)
|
||||||
|
|
||||||
|
num_urls = 1
|
||||||
|
if music_preset == "SoundCloud Discography":
|
||||||
|
num_urls = 2 # simulate /albums and /tracks
|
||||||
|
|
||||||
|
with mock_download_collection_entries(is_youtube_channel=False, num_urls=num_urls):
|
||||||
|
transaction_log = subscription.download(dry_run=False)
|
||||||
|
|
||||||
|
assert_transaction_log_matches(
|
||||||
|
output_directory=output_directory,
|
||||||
|
transaction_log=transaction_log,
|
||||||
|
transaction_log_summary_file_name=f"{expected_summary_name}.txt",
|
||||||
|
)
|
||||||
|
assert_expected_downloads(
|
||||||
|
output_directory=output_directory,
|
||||||
|
dry_run=False,
|
||||||
|
expected_download_summary_file_name=f"{expected_summary_name}.json",
|
||||||
|
)
|
||||||
|
|
||||||
|
###################################### Perform reformat
|
||||||
|
reformatted_expected_summary_name = f"unit/music/{music_preset}_updated_tags"
|
||||||
|
|
||||||
|
reformatted_subscription = Subscription.from_dict(
|
||||||
|
config=config,
|
||||||
|
preset_name=subscription_name,
|
||||||
|
preset_dict={
|
||||||
|
"preset": [music_preset],
|
||||||
|
"music_tags": {"mood": "tired"},
|
||||||
|
"overrides": {
|
||||||
|
"url": "https://your.name.here",
|
||||||
|
"music_directory": output_directory,
|
||||||
|
"genre": "Rock N ROLL!",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
reformatted_transaction_log = reformatted_subscription.update_with_info_json(dry_run=False)
|
||||||
|
assert_transaction_log_matches(
|
||||||
|
output_directory=output_directory,
|
||||||
|
transaction_log=reformatted_transaction_log,
|
||||||
|
transaction_log_summary_file_name=(f"{reformatted_expected_summary_name}.txt"),
|
||||||
|
)
|
||||||
|
assert_expected_downloads(
|
||||||
|
output_directory=output_directory,
|
||||||
|
dry_run=False,
|
||||||
|
expected_download_summary_file_name=f"{reformatted_expected_summary_name}.json",
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue