Skip to content

Instantly share code, notes, and snippets.

@c-neto
Created May 19, 2024 00:42
Show Gist options
  • Save c-neto/f2c4a0e63ef69556bb6169eb2015c74d to your computer and use it in GitHub Desktop.
Save c-neto/f2c4a0e63ef69556bb6169eb2015c74d to your computer and use it in GitHub Desktop.
Bash Script to Download Entire YouTube Channels
#!/bin/bash
set -eu pipefail # Set options for the shell
IFS=$'\n' # Set the Internal Field Separator to newline
# Array containing URLs of YouTube channels
CHANNEL_URLS=(
'https://www.youtube.com/@foo'
'https://www.youtube.com/@bar'
)
# Loop through each channel URL
for CHANNEL_URL in "${CHANNEL_URLS[@]}"; do
# Extract channel name from URL
CHANNEL_NAME=$(cut -d@ -f2 <<< "$CHANNEL_URL")
# Create a directory with the channel name
mkdir "$CHANNEL_NAME"
# Download videos from the channel in MP4 format and save them in the directory
youtube-dl -i -f mp4 "$CHANNEL_URL" -o "$CHANNEL_NAME/%(title)s.%(ext)s" &
done
# Wait for all background jobs to finish
wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment