channel working
This commit is contained in:
parent
396447a8ad
commit
deb6de56b7
3 changed files with 14 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
from pathlib import Path
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from typing import List
|
from typing import List
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
@ -7,6 +8,7 @@ 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.plugins.plugin import Plugin
|
from ytdl_sub.plugins.plugin import Plugin
|
||||||
from ytdl_sub.plugins.plugin import PluginOptions
|
from ytdl_sub.plugins.plugin import PluginOptions
|
||||||
|
from ytdl_sub.utils.file_handler import FileHandler
|
||||||
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.validators.string_formatter_validators import StringFormatterValidator
|
from ytdl_sub.validators.string_formatter_validators import StringFormatterValidator
|
||||||
|
|
@ -206,4 +208,11 @@ class SubtitlesPlugin(Plugin[SubtitleOptions]):
|
||||||
entry=entry,
|
entry=entry,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Delete any possible original subtitle files before conversion
|
||||||
|
for possible_ext in SUBTITLE_EXTENSIONS:
|
||||||
|
possible_subs_file = (
|
||||||
|
Path(self.working_directory) / f"{entry.uid}.{lang}.{possible_ext}"
|
||||||
|
)
|
||||||
|
FileHandler.delete(possible_subs_file)
|
||||||
|
|
||||||
return file_metadata
|
return file_metadata
|
||||||
|
|
|
||||||
|
|
@ -414,6 +414,9 @@ class FileHandler:
|
||||||
self.copy(src_file_path=source_file_path, dst_file_path=output_file_path)
|
self.copy(src_file_path=source_file_path, dst_file_path=output_file_path)
|
||||||
else:
|
else:
|
||||||
self.move(src_file_path=source_file_path, dst_file_path=output_file_path)
|
self.move(src_file_path=source_file_path, dst_file_path=output_file_path)
|
||||||
|
# Simulate the file being moved during dry run by deleting it
|
||||||
|
elif self.dry_run and not copy_file:
|
||||||
|
FileHandler.delete(source_file_path)
|
||||||
|
|
||||||
def delete_file_from_output_directory(self, file_name: str):
|
def delete_file_from_output_directory(self, file_name: str):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ from urllib.request import urlopen
|
||||||
|
|
||||||
from ytdl_sub.entries.entry import Entry
|
from ytdl_sub.entries.entry import Entry
|
||||||
from ytdl_sub.utils.ffmpeg import FFMPEG
|
from ytdl_sub.utils.ffmpeg import FFMPEG
|
||||||
|
from ytdl_sub.utils.file_handler import FileHandler
|
||||||
from ytdl_sub.utils.retry import retry
|
from ytdl_sub.utils.retry import retry
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -42,6 +43,7 @@ def convert_download_thumbnail(entry: Entry, error_if_not_found: bool = True) ->
|
||||||
|
|
||||||
if not download_thumbnail_path == download_thumbnail_path_as_jpg:
|
if not download_thumbnail_path == download_thumbnail_path_as_jpg:
|
||||||
FFMPEG.run(["-bitexact", "-i", download_thumbnail_path, download_thumbnail_path_as_jpg])
|
FFMPEG.run(["-bitexact", "-i", download_thumbnail_path, download_thumbnail_path_as_jpg])
|
||||||
|
FileHandler.delete(download_thumbnail_path)
|
||||||
|
|
||||||
|
|
||||||
@retry(times=5, exceptions=(Exception,))
|
@retry(times=5, exceptions=(Exception,))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue