diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 0535afbbc..bc320f7ad 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -597,7 +597,7 @@ def __init__(self, downloader=None, already_have_subtitle=False): @PostProcessor._restrict_to(images=False) def run(self, info): - filename, ext = info['filepath'], info['ext'] + ext = info['ext'] if ext not in self.SUPPORTED_EXTS: self.to_screen(f'Subtitles can only be embedded in {", ".join(self.SUPPORTED_EXTS)} files') return [], info @@ -607,6 +607,8 @@ def run(self, info): self.to_screen('There aren\'t any subtitles to embed') return [], info + filename = info['filepath'] + # Disabled temporarily. There needs to be a way to override this # 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 @@ -677,9 +679,9 @@ def _embed_lyrics(self, subtitles, filename, ext): self.to_screen(f'Embedding lyrics in "{filename}"') if len(subtitles) > 1: 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'): with open(sub['filepath'], encoding='utf-8') as f: sub['data'] = f.read() diff --git a/yt_dlp/utils/subtitles.py b/yt_dlp/utils/subtitles.py index 08040b202..663e3e6e9 100644 --- a/yt_dlp/utils/subtitles.py +++ b/yt_dlp/utils/subtitles.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import re from dataclasses import dataclass @@ -14,7 +16,7 @@ class Metadata: class Subtitle: text: str start: Seconds - end: Seconds = None + end: Seconds | None = None def parse_lrc(text):