Skip to content

YouTube โ€” Content Tools & Automation

Last reviewed: 2026-05-29

This folder contains tools and scripts for interacting with YouTube content programmatically โ€” downloading videos, extracting audio, and automating content pipelines.


Overview

YouTube offers no official download API, but open-source tools like pytube and yt-dlp enable programmatic downloading. This training covers a Python YouTube downloader and the supporting configuration.


Training Content

YouTube Downloader (youtubeDowloader.py)

A Python script providing multiple download functions for YouTube videos using two libraries: pytube (legacy) and yt-dlp (modern/recommended).

Functions:

Function Library Description
download_youtube_videoDL(url, audio_only, output) yt-dlp Primary downloader. Downloads video or audio with format/progress options
download_youtube_video(url, audio_only, output) pytube Fallback method using the pytube library
download_video(video_url) pytube Simplified download function (audio-only)

Key features: - Configurable: download video (best quality) OR audio-only (MP3 at 192 kbps) - Saves files with original video title as filename - Audio-only mode uses FFmpeg extraction for MP3 conversion - Uses python-dotenv for configuration via .env file - Error handling with try/except blocks

Configuration (.env file):

Variable Description
VIDEO URL of the YouTube video to download
ONLY_AUDIO TRUE for audio-only, FALSE for full video

Usage:

# Set VIDEO and ONLY_AUDIO in .env, then run:
python youtubeDowloader.py

Libraries used: pytube, yt-dlp, python-dotenv


Library Comparison

Feature pytube yt-dlp
Maintenance Archived/limited Active development
Format support Basic Advanced (HLS, DASH, subtitles, chapters)
Post-processing None FFmpeg integration (merge, convert, thumbnail)
Reliability Moderate (breaks with YouTube changes) High (frequently updated)
Audio extraction Manual rename hack Native FFmpeg integration

Recommendation: Use yt-dlp for new projects. It's actively maintained, more reliable, and handles more edge cases.


Audio-Only Workflow

YouTube URL
    โ†“
yt-dlp downloads best audio stream
    โ†“
FFmpeg extracts audio
    โ†“
Converts to MP3 (192 kbps)
    โ†“
Saves as "title.mp3"

.env Configuration

VIDEO=https://www.youtube.com/watch?v=example
ONLY_AUDIO=TRUE

Resources