From 6bce8b92dc209e34b2399d6740f9a9f429cfef19 Mon Sep 17 00:00:00 2001 From: Sanuja Seneviratne <66342986+SanujaNS@users.noreply.github.com> Date: Sun, 15 Oct 2023 18:13:59 +0530 Subject: [PATCH] Always use the `source` format for Google Drive URLs (#300) Always using the `source` format for Google Drive URLs will ensure getting original file, without any modifications. --- ytdlbot/downloader.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ytdlbot/downloader.py b/ytdlbot/downloader.py index 965b3ab..33b2ff8 100644 --- a/ytdlbot/downloader.py +++ b/ytdlbot/downloader.py @@ -169,12 +169,17 @@ def ytdl_download(url: str, tempdir: str, bm, **kwargs) -> list: "--max-concurrent-downloads=16", "--split=16", ] - formats = [ - # webm , vp9 and av01 are not streamable on telegram, so we'll extract mp4 and not av01 codec - "bestvideo[ext=mp4][vcodec!*=av01][vcodec!*=vp09]+bestaudio[ext=m4a]/bestvideo+bestaudio", - "bestvideo[vcodec^=avc]+bestaudio[acodec^=mp4a]/best[vcodec^=avc]/best", - None, - ] + if url.startswith("https://drive.google.com"): + # Always use the `source` format for Google Drive URLs. + formats = ["source"] + else: + # Use the default formats for other URLs. + formats = [ + # webm , vp9 and av01 are not streamable on telegram, so we'll extract only mp4 + "bestvideo[ext=mp4][vcodec!*=av01][vcodec!*=vp09]+bestaudio[ext=m4a]/bestvideo+bestaudio", + "bestvideo[vcodec^=avc]+bestaudio[acodec^=mp4a]/best[vcodec^=avc]/best", + None, + ] adjust_formats(chat_id, url, formats, hijack) if download_instagram(url, tempdir): return list(pathlib.Path(tempdir).glob("*"))