Skip to content

Instantly share code, notes, and snippets.

@Felix-Kyun
Last active May 4, 2022 12:51
Show Gist options
  • Save Felix-Kyun/e71356f2f19b3946c2226fbabfa63b0f to your computer and use it in GitHub Desktop.
Save Felix-Kyun/e71356f2f19b3946c2226fbabfa63b0f to your computer and use it in GitHub Desktop.
simple script to downlad music using yt-dl
#!/bin/bash
# usage
# dl.sh link sub-directory(optional)
# by default it uses yt-dlp change the $BIN to change it.
# script stores cache in .cache dir
# and keeps a archive just to prevent duplicate downloads
# archive is located in Music directory named ".download.txt"
# it also downloads thumbnails by default
# def variable
BASE_DIR=/home/felix/
MUSIC_DIR=Music/
CACHE_DIR=$BASE_DIR$MUSIC_DIR$2/.cache
DOWNLOAD_BAK_FILE=$BASE_DIR$MUSIC_DIR.download.txt
FLAGS=" --download-archive $DOWNLOAD_BAK_FILE \
--no-post-overwrites \
-cwix \
--audio-format m4a \
-o \"%(title)s.%(ext)s\" \
--embed-thumbnail \
--cache-dir=$CACHE_DIR \
--format bestaudio \
--audio-quality 0 \
--add-metadata
"
BIN=yt-dlp
## exec cmd
cd $BASE_DIR$MUSIC_DIR$2
$BIN $1 $FLAGS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment