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
|
||||
def default(cls) -> "ConfigFile":
|
||||
"""
|
||||
Returns
|
||||
-------
|
||||
Config initialized with all defaults
|
||||
"""
|
||||
return ConfigFile(name="default_config", value={})
|
||||
|
||||
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):
|
||||
|
||||
kodi_tv_show_by_date = _
|
||||
jellyfin_tv_show_by_date = _
|
||||
plex_tv_show_by_date = _
|
||||
preset_names = {
|
||||
"Single",
|
||||
"SoundCloud Discography",
|
||||
"YouTube Releases",
|
||||
"YouTube Full Albums",
|
||||
"Bandcamp",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,44 +6,45 @@ class TvShowByDatePresets(PrebuiltPresets):
|
|||
TV Show by Date presets create a TV show from a single URL using upload dates as season/episode
|
||||
numbers.
|
||||
"""
|
||||
|
||||
preset_names = {
|
||||
"kodi_tv_show_by_date",
|
||||
"jellyfin_tv_show_by_date",
|
||||
"plex_tv_show_by_date",
|
||||
"kodi_tv_show_by_date",
|
||||
"jellyfin_tv_show_by_date",
|
||||
"plex_tv_show_by_date",
|
||||
}
|
||||
|
||||
|
||||
class TvShowByDateEpisodeFormattingPresets(PrebuiltPresets):
|
||||
preset_names = {
|
||||
"season_by_year__episode_by_month_day",
|
||||
"season_by_year__episode_by_month_day_reversed",
|
||||
"season_by_year_month__episode_by_day",
|
||||
"season_by_year__episode_by_download_index",
|
||||
"season_by_year__episode_by_month_day",
|
||||
"season_by_year__episode_by_month_day_reversed",
|
||||
"season_by_year_month__episode_by_day",
|
||||
"season_by_year__episode_by_download_index",
|
||||
}
|
||||
|
||||
|
||||
class TvShowCollectionPresets(PrebuiltPresets):
|
||||
preset_names = {
|
||||
"kodi_tv_show_collection",
|
||||
"jellyfin_tv_show_collection",
|
||||
"plex_tv_show_collection",
|
||||
"kodi_tv_show_collection",
|
||||
"jellyfin_tv_show_collection",
|
||||
"plex_tv_show_collection",
|
||||
}
|
||||
|
||||
|
||||
class TvShowCollectionEpisodeFormattingPresets(PrebuiltPresets):
|
||||
preset_names = {
|
||||
"season_by_collection__episode_by_year_month_day",
|
||||
"season_by_collection__episode_by_year_month_day_reversed",
|
||||
"season_by_collection__episode_by_playlist_index",
|
||||
"season_by_collection__episode_by_playlist_index_reversed",
|
||||
"season_by_collection__episode_by_year_month_day",
|
||||
"season_by_collection__episode_by_year_month_day_reversed",
|
||||
"season_by_collection__episode_by_playlist_index",
|
||||
"season_by_collection__episode_by_playlist_index_reversed",
|
||||
}
|
||||
|
||||
|
||||
class TvShowCollectionSeasonPresets(PrebuiltPresets):
|
||||
preset_names = {
|
||||
"collection_season_1",
|
||||
"collection_season_2",
|
||||
"collection_season_3",
|
||||
"collection_season_4",
|
||||
"collection_season_5",
|
||||
"collection_season_1",
|
||||
"collection_season_2",
|
||||
"collection_season_3",
|
||||
"collection_season_4",
|
||||
"collection_season_5",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,6 +186,4 @@ def tv_show_subscriptions_path() -> Path:
|
|||
|
||||
@pytest.fixture()
|
||||
def music_audio_config(working_directory) -> ConfigFile:
|
||||
return ConfigFile.from_dict(
|
||||
{"configuration": {"working_directory": working_directory}}
|
||||
)
|
||||
return ConfigFile.from_dict({"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.subscriptions.subscription import Subscription
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def subscription_dict(output_directory):
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -6,10 +6,11 @@ import pytest
|
|||
from expected_download import assert_expected_downloads
|
||||
from expected_transaction_log import assert_transaction_log_matches
|
||||
|
||||
from ytdl_sub.prebuilt_presets.tv_show import TvShowByDatePresets
|
||||
from ytdl_sub.prebuilt_presets.tv_show import TvShowCollectionPresets
|
||||
from ytdl_sub.prebuilt_presets.music import MusicPresets
|
||||
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 TvShowCollectionPresets
|
||||
from ytdl_sub.prebuilt_presets.tv_show import TvShowCollectionSeasonPresets
|
||||
from ytdl_sub.subscriptions.subscription import Subscription
|
||||
from ytdl_sub.utils.exceptions import ValidationException
|
||||
|
|
@ -342,3 +343,97 @@ class TestPrebuiltTvShowCollectionPresets:
|
|||
dry_run=False,
|
||||
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