Building a yt-dlp GUI Application with Tkinter and Python

VideoDownloader is a desktop application built around the yt-dlp Python library, offering a graphical interface for downloading videos and audio from thousands of supported platforms. Unlike the command-line-only yt-dlp, this tool wraps its functionality in a tkinter-based UI to simplify usage—elimintaing the need to memorize or type complex CLI flags.

Authentication for premium content (e.g., member-only videos) requires valid session credentials. Users can supply cookies via browser export or a cookie file, then enable the corresponding option in the GUI.

Environment Setup

Windows (Recommended)

  • Python 3.8+
  • FFmpeg binary (not the PyPI package), added to PATH (e.g., D:\ffmpeg\bin)
  1. Clone the repository:
git clone https://github.com/CQUPTLei/VideoDownloader.git
  1. Create and activate a Conda environment:
conda create -n vdl python=3.12
conda activate vdl
  1. Install dependencies:
pip install yt-dlp

Linux (Ubuntu 24.04 Example)

  1. Clone the repo:
git clone https://github.com/CQUPTLei/VideoDownloader.git
  1. Set up a virtual environment:
python3 -m venv downloader
source downloader/bin/activate
  1. Install required packages:
pip install yt-dlp prettytable
sudo apt install python3-tk ffmpeg
  1. Launch the app:
python main.py

Note: If loading cookies from a browser, verify the file path in the configuration—defaults may vary across systems.

Packaging as Standalone Executable

Use PyInstaller to bundle the application:

Windows:

pyinstaller -F --noconsole --icon=icon/1.ico --name=VideoDL main.py

Linux:

pyinstaller -F --noconsole --icon=icon/1.ico --name=VideoDL main.py

The resulting binary includes all dependencies and runs without requiring Python or yt-dlp to be installed system-wide.

Core Configuration Options

The underlying yt_dlp.YoutubeDL class accepts a dictionary of options. Below are key categories with representative parameters:

Authentication & Access Control

  • username, password: Credentials for sites requiring login.
  • cookiefile: Path to Netscape-format cookie file.
  • cookiesfrombrowser: Tuple specifying browser name and profile (e.g., ('chrome', 'Default')).
  • age_limit: Integer age threshold to filter age-restricted content.

Format & Output Behavior

  • format: Format selection string (e.g., 'bestvideo[height<=1080]+bestaudio/best').
  • outtmpl: Template for output filenames (e.g., '%(title)s.%(ext)s').
  • paths: Dictionary mapping output types ('home', 'temp') to directories.
  • restrictfilenames: Enforces safe filename characters (ASCII-only, no spaces).

Download Workflow

  • simulate: Skip actual download; useful for testing.
  • skip_download: Skip video file writing but retain metadata extraction.
  • ignoreerrors: Continue on individual failures (True, 'only_download', or False).
  • retries: Number of retry attempts per fragment or file access.
  • concurrent_fragment_downloads: Max parallel fragment requests (default: 10).

Postprocessing

  • postprocessors: List of dictionaries defining actions like merging streams or converting formats. Example:
[
    {
        'key': 'FFmpegVideoConvertor',
        'preferedformat': 'mp4'
    }
]
  • ffmpeg_location: Explicit path to ffmpeg binary if not in PATH.

Metadata & Subtitles

  • writesubtitles, writeautomaticsub: Enable subtitle downloads.
  • subtitleslangs: Language list (e.g., ['en', 'zh-Hans']); prefix with - to exclude.
  • writeinfojson: Save extracted metadata as JSON.

Network & Reliability

  • proxy: HTTP/HTTPS proxy URL (e.g., 'http://127.0.0.1:8080').
  • socket_timeout: Seconds before aborting unresponsive connections.
  • sleep_interval: Minimum delay between downloads (supports jitter with max_sleep_interval).

Deprecated Parameters (Avoid in New Code)

  • playliststart / playlistend → replaced by playlist_items=['1-5']
  • allsubtitles → use subtitleslangs=['all']
  • no_overwrites → use overwrites=False
  • forceurl, forcetitle, etc. → consolidated under forceprint

For exhaustive documentation, refer directly to the yt-dlp source — particularly the YoutubeDL.__init__() docstring and DEFAULT_PARAMS.

Tags: yt-dlp python gui tkinter video-downloader

Posted on Mon, 27 Jul 2026 16:47:38 +0000 by illuz1on