Skip to content

Instantly share code, notes, and snippets.

@lelandbatey
Last active December 29, 2015 01:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lelandbatey/7594106 to your computer and use it in GitHub Desktop.
Save lelandbatey/7594106 to your computer and use it in GitHub Desktop.
ytwatch.sh - For when you don't want to deal with the Youtube interface. Script to automatically download a Youtube video then open it in VLC media player.
#!/bin/bash
#This requires:
# youtube-dl (pip install youtube-dl)
# vlc (sudo apt-get install vlc)
#
# Usage:
#
# ytwatch http://www.youtube.com/watch?v=dMH0bHeiRNg
#
# Sets up a variable to track where we were at the start of all this
ORIGINAL_DIR=$(echo $PWD)
ORIGINAL_DIR+="/"
# Sets up temporary directory for the conversion process.
TEMPDIR=$(mktemp -d)
cd $TEMPDIR
youtube-dl -o "ytvideo.%(ext)s" $1
vlc ytvideo*
rm ytvideo*
cd $ORIGINAL_DIR
rm -rf $TEMPDIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment