Skip to content

Instantly share code, notes, and snippets.

@HouCoder
Last active March 2, 2022 16:37
Show Gist options
  • Save HouCoder/453f53fedaf6b729b92b2fce369c5e41 to your computer and use it in GitHub Desktop.
Save HouCoder/453f53fedaf6b729b92b2fce369c5e41 to your computer and use it in GitHub Desktop.
A shell script for automatic downloading your YouTube playlist.
#!/bin/bash
# Use $ which youtube-dl to get the path.
youtube_dl_path=/usr/local/bin/youtube-dl
# https://askubuntu.com/a/157787
if ps aux | grep -v grep | grep $youtube_dl_path > /dev/null
then
echo "youtube-dl is running"
exit 1
fi
# Change these settings accordingly.
base_folder_video=/home/tonni/Videos/
base_folder_archive=/home/tonni/youtube-dl/
download_playlist () {
# https://stackoverflow.com/a/1401495/4480674
current_date=`date +%Y-%m-%d--%H-%M`
$youtube_dl_path \
$1 \
--output "${base_folder_video}${2}/${current_date}__%(uploader)s__%(title)s.%(ext)s" \
--download-archive ${base_folder_archive}download_arachive_${2} \
--ignore-errors \
--write-sub \
--format best \
--proxy socks5://127.0.0.1:1080
}
# Change
download_playlist "Your_unlisted_playlist_url_1" "playlist_name_1"
download_playlist "Your_unlisted_playlist_url_2" "playlist_name_2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment