Skip to content

Commit

Permalink
[BUGFIX] Find ext when info.json wrong (#1045)
Browse files Browse the repository at this point in the history
Fixes a bug where YouTube's info.json sometimes say ext: mkv but download is not mkv. Thanks @0xBLERKO for the contribution!
  • Loading branch information
0xBLERKO authored Sep 8, 2024
1 parent c44b985 commit 941fa43
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/ytdl_sub/entries/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,15 @@ def add_injected_variables(
@property
def ext(self) -> str:
"""
With ffmpeg installed, yt-dlp will sometimes merge the file into an mkv file.
This is not reflected in the entry. See if the mkv file exists and return "mkv" if so,
otherwise, return the original extension.
With ffmpeg installed, yt-dlp will sometimes merge the file into an mkv file or
info.json states mkv when it is not. This is not reflected in the entry. See
if the expected file exists and return it if so, otherwise, search for present ext.
Fall back to expected ext but this will fail.
"""
ext = self.try_get(v.ext, str) or self._kwargs[v.ext.metadata_key]
for possible_ext in [ext, "mkv"]:
for possible_ext in [
ext,
] + list(VIDEO_CODEC_EXTS):
file_name = self.base_filename(ext=possible_ext)
file_path = str(Path(self.working_directory()) / file_name)
if os.path.isfile(file_path):
Expand Down

0 comments on commit 941fa43

Please sign in to comment.