subtitles almost ready

This commit is contained in:
jbannon 2022-08-10 23:52:32 +00:00
parent 3b3c23963e
commit baae5ff72d
6 changed files with 17 additions and 3 deletions

View file

@ -56,6 +56,7 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT, DownloaderEntryT]
downloader_entry_type: Type[Entry] = Entry
supports_download_archive: bool = True
supports_subtitles: bool = True
_extract_entry_num_retries: int = 5
_extract_entry_retry_wait_sec: int = 3

View file

@ -51,6 +51,7 @@ class SoundcloudAlbumsAndSinglesDownloader(
SoundcloudDownloader[SoundcloudAlbumsAndSinglesDownloadOptions]
):
downloader_options_type = SoundcloudAlbumsAndSinglesDownloadOptions
supports_subtitles = False
@classmethod
def ytdl_option_defaults(cls) -> Dict:

View file

@ -64,6 +64,7 @@ class YoutubeMergePlaylistDownloader(
downloader_options_type = YoutubeMergePlaylistDownloaderOptions
downloader_entry_type = YoutubeVideo
supports_download_archive = False
supports_subtitles = False
@classmethod
def ytdl_option_defaults(cls) -> Dict:

View file

@ -107,6 +107,9 @@ class YoutubeSplitVideoDownloader(
downloader_options_type = YoutubeSplitVideoDownloaderOptions
downloader_entry_type = YoutubePlaylistVideo
supports_download_archive = False
supports_subtitles = False
@classmethod
def ytdl_option_defaults(cls) -> Dict:
"""

View file

@ -204,8 +204,7 @@ class Subscription:
entry=entry,
)
# # TODO: see if entry even has subtitles
# if self.output_options.subtitles_name and (
# if self.downloader_class.supports_subtitles and self.subtitle_options.subtitles_name and (
# entry.kwargs_contains("subtitles") or entry.kwargs_contains("automatic_captions")
# ):
# output_subtitles_name = self.overrides.apply_formatter(

View file

@ -1,7 +1,9 @@
from pathlib import Path
from typing import Dict
from typing import Type
from ytdl_sub.config.preset import Preset
from ytdl_sub.downloaders.downloader import Downloader
from ytdl_sub.downloaders.ytdl_options_builder import YTDLOptionsBuilder
from ytdl_sub.ytdl_additions.enhanced_download_archive import EnhancedDownloadArchive
@ -19,6 +21,10 @@ class SubscriptionYTDLOptions:
self._working_directory = working_directory
self._dry_run = dry_run
@property
def _downloader(self) -> Type[Downloader]:
return self._preset.downloader
@property
def _global_options(self) -> Dict:
"""
@ -32,7 +38,7 @@ class SubscriptionYTDLOptions:
}
if (
self._preset.downloader.supports_download_archive
self._downloader.supports_download_archive
and self._preset.output_options.maintain_download_archive
):
ytdl_options["download_archive"] = str(
@ -61,6 +67,9 @@ class SubscriptionYTDLOptions:
@property
def _subtitle_options(self) -> Dict:
if not self._downloader.supports_subtitles:
return {}
ytdl_options: Dict = {}
subtitle_options = self._preset.subtitle_options