How leandjb/python-yt-downloader works
Project type and purpose
• This is a small desktop GUI application written in Python.
• Purpose: allow users to download progressive (video+audio) YouTube streams up to 720p via a simple GUI built with CustomTkinter and Pytube.
Top-level file structure and architectural hints
• src/main.py – entry point, spins up the CustomTkinter window, handles UI events.
• src/test_main.py – unit tests for main.py logic.
• README.md – describes GUI flow and external dependencies (CustomTkinter, Pytube).
Core components
A. Presentation Layer (CustomTkinter GUI)
• Input field for URL
• “Download” button
• Progress bar + status label
B. Application Logic / Service Layer
• DownloadManager (in main.py)
• URL validation, error handling
• Progress-update callbacks
C. External Libraries and Services
• Pytube (network client fetching YouTube streams)
• YouTube servers (HTTP requests/responses)
D. Local File System
• Storage of downloaded .mp4 files
Data flow and relationships
1. User pastes URL → GUI component
2. GUI calls DownloadManager.download(url)
3. DownloadManager uses Pytube API → sends HTTP request to YouTube
4. YouTube responds with stream data → Pytube streams to memory or tempfile
5. DownloadManager writes bytes to local disk
6. Progress updates flow back via callback → GUI progress bar
7. On success/failure → GUI displays message
Architectural patterns and separation of concerns
• MVC-lite:
• View = CustomTkinter widgets
• Controller/Service = DownloadManager logic in main.py
• Single process, event-driven GUI
• Clear boundary between UI and download logic