How r0oth3x49/udemy-dl works
This is a Python 3 CLI utility (not a service) that:
• Authenticates to Udemy (username/password or cookie/access_token).
• Fetches course metadata + curriculum structure (chapters/lectures).
• Resolves video streams (direct MP4 and/or HLS/m3u8) + assets + subtitles.
• Downloads to local disk with resume/progress/logging.
• Optionally runs FFmpeg for HLS handling and VTT→SRT conversion.
Read the repo structure as architecture boundaries
Top level:
• udemy-dl.py → entrypoint / CLI (argument parsing and orchestration).
• requirements.txt → runtime deps (requests, cloudscraper, etc.).
• udemy/ package → the real “application” split into modules:
• udemy/auth.py → login/auth flows
• udemy/session.py → session + cookie/token persistence (“proper session management”, --cache)
• udemy/extract.py → extract course structure, lecture info, stream URLs, subtitles/assets links
• udemy/udemy.py → likely a facade/service layer that coordinates auth/session/extract/download
• udemy/ffmpeg.py → integration with external FFmpeg binary (HLS downloads)
• udemy/vtt2srt.py → subtitles conversion
• udemy/progress.py → progress indicators / resume support
• udemy/logger.py → logging errors/warnings
• udemy/sanitize.py → safe filenames/path handling
• udemy/utils.py, udemy/shared.py, udemy/internal.py, udemy/compat.py → shared helpers, compatibility glue, constants, internal APIs
This implies a single-process layered CLI:
CLI → Core orchestrator → Session/Auth + Extract → Download pipeline → Post-processing → Filesystem output.
Auth
• cookies token path (-k cookies.txt) OR username/password (-u/-p)
• session caching (--cache)
Extraction
• fetch course page/metadata
• build curriculum list (chapters/lectures)
• resolve per-lecture:
• stream type (MP4 vs HLS)
• subtitles list (VTT)
• assets list
Download loop
• sanitize filenames
• for each lecture:
• download video (direct HTTP) OR invoke FFmpeg for HLS
• resume support / progress updates
• download subtitles/assets depending on flags
• convert VTT→SRT if configured (and keep VTT if --keep-vtt)
Logging + final summary
• HLS vs non-HLS (--skip-hls)
• subtitles only / skip subtitles (--sub-only, --skip-sub)
• assets only / skip assets (--assets-only, --skip-assets)
• info-only mode (--info)
Architectural patterns/design principles to explicitly call out
• Facade/orchestrator: udemy/udemy.py coordinating modules.
• Session management: single persistent session object reused across requests (resume/login stability).
• Pipeline: Extract → Select (chapters/lectures/quality) → Download → Post-process.
• Adapter pattern for external tool: ffmpeg.py wraps FFmpeg invocation.
• Cross-cutting concerns: logging, progress, sanitization.
Context: User ↔ CLI ↔ Udemy; CLI ↔ Filesystem; CLI ↔ FFmpeg.
4. decision annotations for flags (--info, --skip-hls, --sub-only, --cache, etc.).