Skip to content

Instantly share code, notes, and snippets.

@skoenig
Last active May 17, 2022 06:42
Show Gist options
  • Save skoenig/d4a67764d5b653bef06574fa5cc63ef3 to your computer and use it in GitHub Desktop.
Save skoenig/d4a67764d5b653bef06574fa5cc63ef3 to your computer and use it in GitHub Desktop.
youtube-dl + podget = youget
#!/usr/bin/env bash
# Small wrapper around https://youtube-dl.org/ for downloading audio contents
# from Youtube videos / playlists / channels. Inspired by https://github.com/dvehrs/podget.
# You can either list playlists and channels you want to download in CHANNELS
# below, or pass exactly one URL as a parameter.
set -euo pipefail
# ------------------------------------------------------------------------------
# some config, could be extended and moved to external file
CHANNELS=(
https://www.youtube.com/c/Freecodecamp
)
LIBRARY=$HOME/media-local/podcast
CACHE_DIR=$HOME/.local/share/youget
# ------------------------------------------------------------------------------
[ ! -d "$CACHE_DIR" ] || mkdir -p "$CACHE_DIR"
if [ "$#" -eq 1 ]
then
CHANNELS=("${1}")
fi
for url in "${CHANNELS[@]}"
do
youtube-dl \
--download-archive "$CACHE_DIR/downloaded.txt" \
--output "$LIBRARY/%(uploader)s/%(uploader)s_%(title)s-%(id)s.%(ext)s" \
--continue \
--ignore-errors \
--no-overwrites \
--embed-thumbnail \
--extract-audio \
--format 'bestaudio[ext=m4a]' \
--add-metadata \
--yes-playlist \
"${url}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment