mirror of
https://github.com/alexta69/metube.git
synced 2026-03-18 22:43:51 +00:00
fix: for 'text only' subs now download .txt instead of an intermediate .srt
This commit is contained in:
committed by
Alex Shnitman
parent
8dff6448b2
commit
77da359234
11
app/ytdl.py
11
app/ytdl.py
@@ -337,7 +337,11 @@ class Download:
|
|||||||
rel_name = os.path.relpath(fileName, self.download_dir)
|
rel_name = os.path.relpath(fileName, self.download_dir)
|
||||||
# For captions mode, ignore media-like placeholders and let subtitle_file
|
# For captions mode, ignore media-like placeholders and let subtitle_file
|
||||||
# statuses define the final file shown in the UI.
|
# statuses define the final file shown in the UI.
|
||||||
if not (self.info.format == 'captions' and not rel_name.endswith(('.vtt', '.srt', '.ttml', '.txt'))):
|
if self.info.format == 'captions':
|
||||||
|
requested_subtitle_format = str(getattr(self.info, 'subtitle_format', '')).lower()
|
||||||
|
allowed_caption_exts = ('.txt',) if requested_subtitle_format == 'txt' else ('.vtt', '.srt', '.sbv', '.scc', '.ttml', '.dfxp')
|
||||||
|
if not rel_name.lower().endswith(allowed_caption_exts):
|
||||||
|
continue
|
||||||
self.info.filename = rel_name
|
self.info.filename = rel_name
|
||||||
self.info.size = os.path.getsize(fileName) if os.path.exists(fileName) else None
|
self.info.size = os.path.getsize(fileName) if os.path.exists(fileName) else None
|
||||||
if self.info.format == 'thumbnail':
|
if self.info.format == 'thumbnail':
|
||||||
@@ -383,7 +387,10 @@ class Download:
|
|||||||
if not existing:
|
if not existing:
|
||||||
self.info.subtitle_files.append({'filename': rel_path, 'size': file_size})
|
self.info.subtitle_files.append({'filename': rel_path, 'size': file_size})
|
||||||
# Prefer first subtitle file as the primary result link in captions mode.
|
# Prefer first subtitle file as the primary result link in captions mode.
|
||||||
if self.info.format == 'captions' and (not getattr(self.info, 'filename', None)):
|
if self.info.format == 'captions' and (
|
||||||
|
not getattr(self.info, 'filename', None) or
|
||||||
|
str(getattr(self.info, 'subtitle_format', '')).lower() == 'txt'
|
||||||
|
):
|
||||||
self.info.filename = rel_path
|
self.info.filename = rel_path
|
||||||
self.info.size = file_size
|
self.info.size = file_size
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user