mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-03-09 12:50:23 -05:00
Some fixes
This commit is contained in:
parent
ae117ac598
commit
a36d6df3f6
2 changed files with 8 additions and 4 deletions
|
@ -597,7 +597,7 @@ def __init__(self, downloader=None, already_have_subtitle=False):
|
||||||
|
|
||||||
@PostProcessor._restrict_to(images=False)
|
@PostProcessor._restrict_to(images=False)
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
filename, ext = info['filepath'], info['ext']
|
ext = info['ext']
|
||||||
if ext not in self.SUPPORTED_EXTS:
|
if ext not in self.SUPPORTED_EXTS:
|
||||||
self.to_screen(f'Subtitles can only be embedded in {", ".join(self.SUPPORTED_EXTS)} files')
|
self.to_screen(f'Subtitles can only be embedded in {", ".join(self.SUPPORTED_EXTS)} files')
|
||||||
return [], info
|
return [], info
|
||||||
|
@ -607,6 +607,8 @@ def run(self, info):
|
||||||
self.to_screen('There aren\'t any subtitles to embed')
|
self.to_screen('There aren\'t any subtitles to embed')
|
||||||
return [], info
|
return [], info
|
||||||
|
|
||||||
|
filename = info['filepath']
|
||||||
|
|
||||||
# Disabled temporarily. There needs to be a way to override this
|
# Disabled temporarily. There needs to be a way to override this
|
||||||
# in case of duration actually mismatching in extractor
|
# in case of duration actually mismatching in extractor
|
||||||
# See: https://github.com/yt-dlp/yt-dlp/issues/1870, https://github.com/yt-dlp/yt-dlp/issues/1385
|
# See: https://github.com/yt-dlp/yt-dlp/issues/1870, https://github.com/yt-dlp/yt-dlp/issues/1385
|
||||||
|
@ -677,9 +679,9 @@ def _embed_lyrics(self, subtitles, filename, ext):
|
||||||
self.to_screen(f'Embedding lyrics in "{filename}"')
|
self.to_screen(f'Embedding lyrics in "{filename}"')
|
||||||
if len(subtitles) > 1:
|
if len(subtitles) > 1:
|
||||||
self.report_warning(
|
self.report_warning(
|
||||||
f'Your media player may be unable to display multiple subtitles in {ext}')
|
f'Your media player may be unable to display multiple subtitles in {ext}', only_once=True)
|
||||||
|
|
||||||
for lang, sub in subtitles.items():
|
for sub in subtitles.values():
|
||||||
if not sub.get('data'):
|
if not sub.get('data'):
|
||||||
with open(sub['filepath'], encoding='utf-8') as f:
|
with open(sub['filepath'], encoding='utf-8') as f:
|
||||||
sub['data'] = f.read()
|
sub['data'] = f.read()
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
@ -14,7 +16,7 @@ class Metadata:
|
||||||
class Subtitle:
|
class Subtitle:
|
||||||
text: str
|
text: str
|
||||||
start: Seconds
|
start: Seconds
|
||||||
end: Seconds = None
|
end: Seconds | None = None
|
||||||
|
|
||||||
|
|
||||||
def parse_lrc(text):
|
def parse_lrc(text):
|
||||||
|
|
Loading…
Reference in a new issue