working directory getting cleaned
This commit is contained in:
parent
deb6de56b7
commit
959c5dfc9d
3 changed files with 24 additions and 9 deletions
|
|
@ -209,6 +209,8 @@ class SubtitlesPlugin(Plugin[SubtitleOptions]):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Delete any possible original subtitle files before conversion
|
# Delete any possible original subtitle files before conversion
|
||||||
|
# Can happen for both file and embedded subs
|
||||||
|
for lang in langs:
|
||||||
for possible_ext in SUBTITLE_EXTENSIONS:
|
for possible_ext in SUBTITLE_EXTENSIONS:
|
||||||
possible_subs_file = (
|
possible_subs_file = (
|
||||||
Path(self.working_directory) / f"{entry.uid}.{lang}.{possible_ext}"
|
Path(self.working_directory) / f"{entry.uid}.{lang}.{possible_ext}"
|
||||||
|
|
|
||||||
|
|
@ -166,6 +166,12 @@ class SubscriptionDownload(BaseSubscription, ABC):
|
||||||
|
|
||||||
return plugins
|
return plugins
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _cleanup_entry_files(cls, entry: Entry):
|
||||||
|
FileHandler.delete(entry.get_download_file_path())
|
||||||
|
FileHandler.delete(entry.get_download_thumbnail_path())
|
||||||
|
FileHandler.delete(entry.get_download_info_json_path())
|
||||||
|
|
||||||
def _post_process_entry(
|
def _post_process_entry(
|
||||||
self, plugins: List[Plugin], dry_run: bool, entry: Entry, entry_metadata: FileMetadata
|
self, plugins: List[Plugin], dry_run: bool, entry: Entry, entry_metadata: FileMetadata
|
||||||
):
|
):
|
||||||
|
|
@ -184,6 +190,9 @@ class SubscriptionDownload(BaseSubscription, ABC):
|
||||||
if self.maintain_download_archive:
|
if self.maintain_download_archive:
|
||||||
self._enhanced_download_archive.save_download_mappings()
|
self._enhanced_download_archive.save_download_mappings()
|
||||||
|
|
||||||
|
# Clean up any files that remain
|
||||||
|
self._cleanup_entry_files(entry=entry)
|
||||||
|
|
||||||
def _process_entry(
|
def _process_entry(
|
||||||
self, plugins: List[Plugin], dry_run: bool, entry: Entry, entry_metadata: FileMetadata
|
self, plugins: List[Plugin], dry_run: bool, entry: Entry, entry_metadata: FileMetadata
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -278,9 +287,7 @@ class SubscriptionDownload(BaseSubscription, ABC):
|
||||||
plugins=plugins, dry_run=dry_run, entry=entry, entry_metadata=entry_metadata
|
plugins=plugins, dry_run=dry_run, entry=entry, entry_metadata=entry_metadata
|
||||||
)
|
)
|
||||||
|
|
||||||
FileHandler.delete(entry.get_download_file_path())
|
self._cleanup_entry_files(entry=entry)
|
||||||
FileHandler.delete(entry.get_download_thumbnail_path())
|
|
||||||
FileHandler.delete(entry.get_download_info_json_path())
|
|
||||||
|
|
||||||
for plugin in plugins:
|
for plugin in plugins:
|
||||||
plugin.post_process_subscription()
|
plugin.post_process_subscription()
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,12 @@ from ytdl_sub.entries.variables.kwargs import UPLOAD_DATE
|
||||||
from ytdl_sub.entries.variables.kwargs import WEBPAGE_URL
|
from ytdl_sub.entries.variables.kwargs import WEBPAGE_URL
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def working_directory() -> str:
|
||||||
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
|
yield temp_dir
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def subscription_name(working_directory) -> str:
|
def subscription_name(working_directory) -> str:
|
||||||
name = "subscription_test"
|
name = "subscription_test"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue