Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for cookiefile for Youtube downloads #988

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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

Check warning on line 48 in buzz/transcriber/file_transcriber.py

View check run for this annotation

Codecov / codecov/patch

buzz/transcriber/file_transcriber.py#L48

Added line #L48 was not covered by tests

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.