#!/bin/bash # youtube-watchvideo - auto-fetch and play youtube video, using youtube-dl (and opt. klipper) # Licensed under the terms of the GNU GPLv3 or later # Proprietary Software Must Perish! # AUTHOR: Johannes Truschnigg ( johannes.truschnigg@gmx.at || http://johannes.truschnigg.info ) # specify full path to youtube-dl ( http://www.arrakis.es/~rggi3/youtube-dl/ ) executeable here export YOUTUBEDL="${HOME}/youtube-dl"; # do not touch anything below this line unless you know what you're doing export URLREGEX='^http://[^./]*\.?youtube\.com/.*'; export VIDEOURL="${1}"; [[ ${VIDEOURL} =~ $URLREGEX ]] || exit 1; (exec 1>/dev/null; which kdialog && which mplayer && which sed) || exit 1; kdialog --passivepopup "youtube-watchvideo started in background." 3 & export FLVFILE="$(${YOUTUBEDL:-youtube-dl} -t "${VIDEOURL}" | sed -n 's/^Video data saved to //p')"; kdialog --yesno "\"${FLVFILE}\" finished downloading. Play it now?" && \ ( mplayer "${FLVFILE}";\ kdialog --yesno "\"${FLVFILE}\" playback ended. Delete file?" &&\ rm -f "${FLVFILE}" )