Skip to content

Commit

Permalink
use the file extension given by yt-dlp instead of assuming mp4
Browse files Browse the repository at this point in the history
  • Loading branch information
kytpbs committed Aug 11, 2024
1 parent c72cd1b commit 9a39085
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,13 @@ def download_video_from_link(url: str, path: str | None = None) -> VIDEO_RETURN_

info = ydt.get("entries", [None])[0] or ydt
video_id = info["id"]
video_extension = info["ext"]
if video_id is None:
return []

file_path = os.path.join(path, f"{video_id}.mp4")
if video_extension != "mp4":
logging.error("Got a non-mp4 file that is %s from this link: %s", video_extension, url)

file_path = os.path.join(path, f"{video_id}.{video_extension}")

return [VideoFile(file_path, info.get("title", None))]

0 comments on commit 9a39085

Please sign in to comment.