Skip to content

Commit

Permalink
Adding support for cookiefile for Youtube downloads (#988)
Browse files Browse the repository at this point in the history
  • Loading branch information
raivisdejus authored Nov 10, 2024
1 parent 73a052e commit 3069512
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 13 additions & 8 deletions buzz/transcriber/file_transcriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,19 @@ def run(self):
temp_output_path = tempfile.mktemp()
wav_file = temp_output_path + ".wav"

ydl = YoutubeDL(
{
"format": "bestaudio/best",
"progress_hooks": [self.on_download_progress],
"outtmpl": temp_output_path,
"logger": logging.getLogger()
}
)
cookiefile = os.getenv("BUZZ_DOWNLOAD_COOKIEFILE")

options = {
"format": "bestaudio/best",
"progress_hooks": [self.on_download_progress],
"outtmpl": temp_output_path,
"logger": logging.getLogger(),
}

if cookiefile:
options["cookiefile"] = cookiefile

ydl = YoutubeDL(options)

try:
logging.debug(f"Downloading audio file from URL: {self.transcription_task.url}")
Expand Down
2 changes: 2 additions & 0 deletions docs/docs/preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,5 @@ Defaults to [user_cache_dir](https://pypi.org/project/platformdirs/).
**BUZZ_FAVORITE_LANGUAGES** - Coma separated list of supported language codes to show on top of language list.

**BUZZ_LOCALE** - Buzz UI locale to use. Defaults to one of supported system locales.

**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 comments on commit 3069512

Please sign in to comment.