-
-
Save shredthaGNAR/f966753a429f6c7f8a5465aff1d87c3e to your computer and use it in GitHub Desktop.
Download a video from a URL in clipboard automatically (bind to keyboard shortcut) (Mac/Linux)
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 | |
dir="$HOME/Videos" | |
opts="--add-metadata --no-mtime" | |
if [ -f /usr/local/bin/youtube-dl ]; then | |
youtube_dl="/usr/local/bin/youtube-dl" | |
else | |
youtube_dl="$(which youtube-dl)" | |
fi | |
if [[ "$(uname -a | awk '{print $1}')" == "Darwin" ]]; then | |
paste="pbpaste" | |
opts="${opts} --ffmpeg-location /usr/local/bin/ffmpeg" | |
else | |
paste="xsel -ob" | |
fi | |
cd "${dir}" | |
# Try downloading normally | |
if ! $youtube_dl $opts -o "${dir}/%(title)s.%(ext)s" "$($paste)"; then | |
# If the title is too long, use the id | |
$youtube_dl $opts -o "${dir}/%(id)s.%(ext)s" "$($paste)" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment