Skip to content

Commit 7c5b5e6

Browse files
committed
Adding support for cookiefile for Youtube downloads (#988)
1 parent 99223bf commit 7c5b5e6

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

buzz/transcriber/file_transcriber.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,19 @@ def run(self):
3535
temp_output_path = tempfile.mktemp()
3636
wav_file = temp_output_path + ".wav"
3737

38-
ydl = YoutubeDL(
39-
{
40-
"format": "bestaudio/best",
41-
"progress_hooks": [self.on_download_progress],
42-
"outtmpl": temp_output_path,
43-
"logger": logging.getLogger()
44-
}
45-
)
38+
cookiefile = os.getenv("BUZZ_DOWNLOAD_COOKIEFILE")
39+
40+
options = {
41+
"format": "bestaudio/best",
42+
"progress_hooks": [self.on_download_progress],
43+
"outtmpl": temp_output_path,
44+
"logger": logging.getLogger(),
45+
}
46+
47+
if cookiefile:
48+
options["cookiefile"] = cookiefile
49+
50+
ydl = YoutubeDL(options)
4651

4752
try:
4853
logging.debug(f"Downloading audio file from URL: {self.transcription_task.url}")

docs/docs/preferences.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,5 @@ Defaults to [user_cache_dir](https://pypi.org/project/platformdirs/).
9292
**BUZZ_FAVORITE_LANGUAGES** - Coma separated list of supported language codes to show on top of language list.
9393

9494
**BUZZ_LOCALE** - Buzz UI locale to use. Defaults to one of supported system locales.
95+
96+
**BUZZ_DOWNLOAD_COOKIEFILE** - Location of a [cookiefile](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp) to use for downloading private videos or as workaround for anti-bot protection.

0 commit comments

Comments
 (0)