Last active
May 17, 2022 06:42
-
-
Save skoenig/d4a67764d5b653bef06574fa5cc63ef3 to your computer and use it in GitHub Desktop.
youtube-dl + podget = youget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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