Created
December 18, 2022 07:10
-
-
Save Ethorbit/580bd7e16d5f51e15e799b712126eb49 to your computer and use it in GitHub Desktop.
Personal wrapper script for yt-dlp with options
This file contains hidden or 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 | |
maxnum="99999999" | |
while getopts ":c:d:a:n:" opt; do | |
case "$opt" in | |
c) content=$OPTARG ;; | |
d) dest=$OPTARG ;; | |
a) audio=$OPTARG ;; | |
n) maxnum=$OPTARG ;; | |
esac | |
done | |
shift $(( OPTIND - 1 )) | |
if [ -z "$content" ]; then | |
echo "No content (-c) specified, there is nothing to download.." | |
fi | |
if [ -z "$dest" ]; then | |
echo "Destination (-d) not provided, setting to current directory." | |
dest=$PWD | |
fi | |
if [[ ! -z "$content" && ! -z "$dest" ]]; then | |
echo "Downloading $content to $dest..." | |
mkdir -p $dest | |
if [ $audio ]; then | |
yt-dlp "$content" -o "$dest/%(title)s.%(ext)s" \ | |
-x \ | |
--restrict-filenames \ | |
--audio-format best \ | |
--audio-quality 0 \ | |
--max-downloads $maxnum \ | |
--no-mtime \ | |
--verbose | |
else | |
yt-dlp "$content" -o "$dest/%(title)s/%(title)s.%(ext)s" \ | |
-o "thumbnail:$dest/%(title)s/thumbnails/" \ | |
-f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" \ | |
--restrict-filenames \ | |
--merge-output-format mp4 \ | |
--write-info-json \ | |
--write-annotations \ | |
--write-description \ | |
--write-all-thumbnails \ | |
--max-downloads $maxnum \ | |
--verbose | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment