fix sub tests
This commit is contained in:
parent
4bc1284c57
commit
0d4a17c3e1
5 changed files with 55 additions and 39 deletions
|
|
@ -9,6 +9,7 @@ from ytdl_sub.config.preset import Preset
|
||||||
from ytdl_sub.config.preset_options import OutputOptions
|
from ytdl_sub.config.preset_options import OutputOptions
|
||||||
from ytdl_sub.config.preset_options import YTDLOptions
|
from ytdl_sub.config.preset_options import YTDLOptions
|
||||||
from ytdl_sub.downloaders.url.validators import MultiUrlValidator
|
from ytdl_sub.downloaders.url.validators import MultiUrlValidator
|
||||||
|
from ytdl_sub.entries.variables.override_variables import SubscriptionVariables
|
||||||
from ytdl_sub.utils.file_handler import FileHandlerTransactionLog
|
from ytdl_sub.utils.file_handler import FileHandlerTransactionLog
|
||||||
from ytdl_sub.utils.logger import Logger
|
from ytdl_sub.utils.logger import Logger
|
||||||
from ytdl_sub.ytdl_additions.enhanced_download_archive import EnhancedDownloadArchive
|
from ytdl_sub.ytdl_additions.enhanced_download_archive import EnhancedDownloadArchive
|
||||||
|
|
@ -16,6 +17,24 @@ from ytdl_sub.ytdl_additions.enhanced_download_archive import EnhancedDownloadAr
|
||||||
logger = Logger.get("subscription")
|
logger = Logger.get("subscription")
|
||||||
|
|
||||||
|
|
||||||
|
def _initialize_download_archive(
|
||||||
|
output_options: OutputOptions,
|
||||||
|
overrides: Overrides,
|
||||||
|
working_directory: str,
|
||||||
|
output_directory: str,
|
||||||
|
) -> EnhancedDownloadArchive:
|
||||||
|
migrated_file_name: Optional[str] = None
|
||||||
|
if migrated_file_name_option := output_options.migrated_download_archive_name:
|
||||||
|
migrated_file_name = overrides.apply_formatter(migrated_file_name_option)
|
||||||
|
|
||||||
|
return EnhancedDownloadArchive(
|
||||||
|
file_name=overrides.apply_formatter(output_options.download_archive_name),
|
||||||
|
working_directory=working_directory,
|
||||||
|
output_directory=output_directory,
|
||||||
|
migrated_file_name=migrated_file_name,
|
||||||
|
).reinitialize(dry_run=True)
|
||||||
|
|
||||||
|
|
||||||
class BaseSubscription(ABC):
|
class BaseSubscription(ABC):
|
||||||
"""
|
"""
|
||||||
Subscription classes are the 'controllers' that perform...
|
Subscription classes are the 'controllers' that perform...
|
||||||
|
|
@ -47,7 +66,32 @@ class BaseSubscription(ABC):
|
||||||
self.name = name
|
self.name = name
|
||||||
self._config_options = config_options
|
self._config_options = config_options
|
||||||
self._preset_options = preset_options
|
self._preset_options = preset_options
|
||||||
self._enhanced_download_archive: Optional[EnhancedDownloadArchive] = None
|
|
||||||
|
# Add overrides pre-archive
|
||||||
|
self.overrides.add(
|
||||||
|
{
|
||||||
|
SubscriptionVariables.subscription_name(): self.name,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
self._enhanced_download_archive: Optional[
|
||||||
|
EnhancedDownloadArchive
|
||||||
|
] = _initialize_download_archive(
|
||||||
|
output_options=self.output_options,
|
||||||
|
overrides=self.overrides,
|
||||||
|
working_directory=self.working_directory,
|
||||||
|
output_directory=self.output_directory,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add post-archive variables
|
||||||
|
self.overrides.add(
|
||||||
|
{
|
||||||
|
SubscriptionVariables.subscription_has_download_archive(): f"""{{
|
||||||
|
%bool({self.download_archive.num_entries > 0})
|
||||||
|
}}""",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
self._exception: Optional[Exception] = None
|
self._exception: Optional[Exception] = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ from ytdl_sub.downloaders.source_plugin import SourcePlugin
|
||||||
from ytdl_sub.downloaders.url.downloader import MultiUrlDownloader
|
from ytdl_sub.downloaders.url.downloader import MultiUrlDownloader
|
||||||
from ytdl_sub.downloaders.ytdl_options_builder import YTDLOptionsBuilder
|
from ytdl_sub.downloaders.ytdl_options_builder import YTDLOptionsBuilder
|
||||||
from ytdl_sub.entries.entry import Entry
|
from ytdl_sub.entries.entry import Entry
|
||||||
from ytdl_sub.entries.variables.override_variables import SubscriptionVariables
|
|
||||||
from ytdl_sub.subscriptions.base_subscription import BaseSubscription
|
from ytdl_sub.subscriptions.base_subscription import BaseSubscription
|
||||||
from ytdl_sub.subscriptions.subscription_ytdl_options import SubscriptionYTDLOptions
|
from ytdl_sub.subscriptions.subscription_ytdl_options import SubscriptionYTDLOptions
|
||||||
from ytdl_sub.utils.datetime import to_date_range
|
from ytdl_sub.utils.datetime import to_date_range
|
||||||
|
|
@ -26,7 +25,6 @@ from ytdl_sub.utils.file_handler import FileHandler
|
||||||
from ytdl_sub.utils.file_handler import FileHandlerTransactionLog
|
from ytdl_sub.utils.file_handler import FileHandlerTransactionLog
|
||||||
from ytdl_sub.utils.file_handler import FileMetadata
|
from ytdl_sub.utils.file_handler import FileMetadata
|
||||||
from ytdl_sub.utils.logger import Logger
|
from ytdl_sub.utils.logger import Logger
|
||||||
from ytdl_sub.ytdl_additions.enhanced_download_archive import EnhancedDownloadArchive
|
|
||||||
|
|
||||||
logger: logging.Logger = Logger.get()
|
logger: logging.Logger = Logger.get()
|
||||||
|
|
||||||
|
|
@ -327,34 +325,6 @@ class SubscriptionDownload(BaseSubscription, ABC):
|
||||||
|
|
||||||
return self.download_archive.get_file_handler_transaction_log()
|
return self.download_archive.get_file_handler_transaction_log()
|
||||||
|
|
||||||
def _initialize_subscription_overrides_pre_archive(self) -> None:
|
|
||||||
self.overrides.add(
|
|
||||||
{
|
|
||||||
SubscriptionVariables.subscription_name(): self.name,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
def _initialize_subscription_overrides_post_archive(self) -> None:
|
|
||||||
self.overrides.add(
|
|
||||||
{
|
|
||||||
SubscriptionVariables.subscription_has_download_archive(): f"""{{
|
|
||||||
%bool({self.download_archive.num_entries > 0})
|
|
||||||
}}""",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
def _initialize_download_archive(self, dry_run: bool) -> None:
|
|
||||||
migrated_file_name: Optional[str] = None
|
|
||||||
if migrated_file_name_option := self.output_options.migrated_download_archive_name:
|
|
||||||
migrated_file_name = self.overrides.apply_formatter(migrated_file_name_option)
|
|
||||||
|
|
||||||
self._enhanced_download_archive = EnhancedDownloadArchive(
|
|
||||||
file_name=self.overrides.apply_formatter(self.output_options.download_archive_name),
|
|
||||||
working_directory=self.working_directory,
|
|
||||||
output_directory=self.output_directory,
|
|
||||||
migrated_file_name=migrated_file_name,
|
|
||||||
).reinitialize(dry_run=dry_run)
|
|
||||||
|
|
||||||
def download(self, dry_run: bool = False) -> FileHandlerTransactionLog:
|
def download(self, dry_run: bool = False) -> FileHandlerTransactionLog:
|
||||||
"""
|
"""
|
||||||
Performs the subscription download
|
Performs the subscription download
|
||||||
|
|
@ -366,10 +336,7 @@ class SubscriptionDownload(BaseSubscription, ABC):
|
||||||
directory.
|
directory.
|
||||||
"""
|
"""
|
||||||
self._exception = None
|
self._exception = None
|
||||||
|
self.download_archive.reinitialize(dry_run=dry_run)
|
||||||
self._initialize_subscription_overrides_pre_archive()
|
|
||||||
self._initialize_download_archive(dry_run=dry_run)
|
|
||||||
self._initialize_subscription_overrides_post_archive()
|
|
||||||
|
|
||||||
plugins = self._initialize_plugins()
|
plugins = self._initialize_plugins()
|
||||||
|
|
||||||
|
|
@ -422,10 +389,7 @@ class SubscriptionDownload(BaseSubscription, ABC):
|
||||||
If true, do not modify any video/audio files or move anything to the output directory.
|
If true, do not modify any video/audio files or move anything to the output directory.
|
||||||
"""
|
"""
|
||||||
self._exception = None
|
self._exception = None
|
||||||
|
self.download_archive.reinitialize(dry_run=dry_run)
|
||||||
self._initialize_subscription_overrides_pre_archive()
|
|
||||||
self._initialize_download_archive(dry_run=dry_run)
|
|
||||||
self._initialize_subscription_overrides_post_archive()
|
|
||||||
|
|
||||||
plugins = self._initialize_plugins()
|
plugins = self._initialize_plugins()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,11 @@ def playlist_bilateral_dict(output_directory):
|
||||||
"url": "https://www.youtube.com/playlist?list=PLd4Q7G88JqoekF0b30NYQcOTnTiIe9Ali",
|
"url": "https://www.youtube.com/playlist?list=PLd4Q7G88JqoekF0b30NYQcOTnTiIe9Ali",
|
||||||
"tv_show_directory": output_directory,
|
"tv_show_directory": output_directory,
|
||||||
},
|
},
|
||||||
|
"nfo_tags": {
|
||||||
|
"tags": {
|
||||||
|
"subscription_has_download_archive": "{subscription_has_download_archive}",
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,5 +50,6 @@ Files created:
|
||||||
Texture Pack I Use:
|
Texture Pack I Use:
|
||||||
http://www.minecraftforum.net/viewtopic.php?f=25&t=29164
|
http://www.minecraftforum.net/viewtopic.php?f=25&t=29164
|
||||||
season: 2011
|
season: 2011
|
||||||
|
subscription_has_download_archive: false
|
||||||
title: 2011-02-01 - Jesse's Minecraft Server [Trailer - Feb.1]
|
title: 2011-02-01 - Jesse's Minecraft Server [Trailer - Feb.1]
|
||||||
year: 2011
|
year: 2011
|
||||||
|
|
@ -78,6 +78,7 @@ Files created:
|
||||||
|
|
||||||
I claim no ownership of this song, all the credit goes to Pearl Jam and their producers.
|
I claim no ownership of this song, all the credit goes to Pearl Jam and their producers.
|
||||||
season: 2011
|
season: 2011
|
||||||
|
subscription_has_download_archive: true
|
||||||
title: 2011-02-27 - Jesse's Minecraft Server [Trailer - Feb.27]
|
title: 2011-02-27 - Jesse's Minecraft Server [Trailer - Feb.27]
|
||||||
year: 2011
|
year: 2011
|
||||||
s2011.e032101 - Jesse's Minecraft Server [Trailer - Mar.21]-thumb.jpg
|
s2011.e032101 - Jesse's Minecraft Server [Trailer - Mar.21]-thumb.jpg
|
||||||
|
|
@ -157,6 +158,7 @@ Files created:
|
||||||
|
|
||||||
I claim no ownership of this song, all the credit goes to Pearl Jam and their producers.
|
I claim no ownership of this song, all the credit goes to Pearl Jam and their producers.
|
||||||
season: 2011
|
season: 2011
|
||||||
|
subscription_has_download_archive: true
|
||||||
title: 2011-03-21 - Jesse's Minecraft Server [Trailer - Mar.21]
|
title: 2011-03-21 - Jesse's Minecraft Server [Trailer - Mar.21]
|
||||||
year: 2011
|
year: 2011
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue