Last active
September 28, 2023 15:42
-
-
Save manero6/f11437a3a267b6b8e68476e6334c4cdc to your computer and use it in GitHub Desktop.
download with yt-dlp in a new directory that gets its name from the last part of the given URL
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
#!/bin/bash | |
ROOT_DIRECTORY=`basename "$(pwd)"` | |
ARGUMENTS_NR=$# | |
ARGUMENTS=$@ | |
yt-dlp-mkdir () { | |
for i in $ARGUMENTS | |
do | |
declare -a DIRECTORY="(`basename $i | tr "-" " "`)" | |
DIRECTORY="${DIRECTORY[@]^}" | |
mkdir "$DIRECTORY" && echo "=> Folder '$DIRECTORY' created under '$ROOT_DIRECTORY'" | |
cd "$DIRECTORY" && echo "=> Moved to '$DIRECTORY'" | |
yt-dlp -o '%(playlist_index)02d %(title)s.%(ext)s' $i && echo "=> '$DIRECTORY' downloaded!" | |
cd .. && echo "=> Moved back to '$ROOT_DIRECTORY'" | |
done && echo "=> Done!" | |
} | |
main () { | |
if test $ARGUMENTS_NR != 0 | |
then yt-dlp-mkdir | |
else echo "=> Please provide at least 1 URL!" | |
fi | |
} | |
main |
Author
manero6
commented
Sep 1, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment