Skip to content

Instantly share code, notes, and snippets.

@kathawala
Created December 8, 2014 08:59
Show Gist options
  • Save kathawala/df8ccd5205a0b669c50f to your computer and use it in GitHub Desktop.
Save kathawala/df8ccd5205a0b669c50f to your computer and use it in GitHub Desktop.
A script to download a youtube video and play it in smplayer, good for flash-only videos or long videos which buffer
#!/bin/bash
#utility to play a youtube video after the url has been cut using ctrl-x
youtube-dl -o "/home/farhan/Downloads/frmyoutube.%(ext)s" "$(xclip -o)" | tee /home/farhan/bin/play.log
#make sure we don't have any errors
if [ $(grep -i "error" ~/bin/play.log) ]; then
echo "Error downloading video. Try again :("
exit 1
fi
#play the video we downloaded in smplayer
PLACE="$(youtube-dl -o "/home/farhan/Downloads/frmyoutube.%(ext)s" "$(xclip -o)" --get-filename)"
#Make sure we delete the video when done watching :)
function delete {
rm -f "$PLACE"
rm -f /home/farhan/bin/play.log
}
trap delete EXIT
smplayer "$PLACE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment