Skip to content

Instantly share code, notes, and snippets.

@lrvick
Created January 28, 2015 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lrvick/fffb8f5c31468ac24c1f to your computer and use it in GitHub Desktop.
Save lrvick/fffb8f5c31468ac24c1f to your computer and use it in GitHub Desktop.
Youtube batch browserless search/autoplay script I wrote ages ago. Probably no longer works.
#!/bin/bash
#YouTubeSucker 0.9999999423ish
#your media player and args of choice, must have flv support, mplayer or vlc will do the job
mediap="mplayer -fs"
terms="$*"
if [ "$terms" = "" ] ; then
echo 'Usage: yts.sh [YouTube URL] [search terms]'
fi
if [[ `echo ${terms} | grep youtube.com` ]] ; then
echo "http://youtube.com/get_video.php?"`curl -s $1 | grep "watch_fullscreen" | sed "s;.*\(video_id.\+\)&title.*;\1;"`
exit
fi
terms=`echo ${terms}| tr ' ' '+'`
search=`curl -s "http://youtube.com/results?search_query=${terms}&search=Search"| grep watch?`
results=`for line in ${search} ;do echo $line| grep href | sed -e 's#href="/watch?v=##g;s#"##';done`
results=`echo ${results} | sed -e 's/ /\n/g' | uniq`
for id in ${results} ;
do
realid=`curl -s http://youtube.com/watch?v=${id} | grep "watch_fullscreen" | sed "s;.*\(video_id.\+\)&title.*;\1;"`
tubeline="$tubeline http://youtube.com/get_video.php?${realid}"
done
${mediap} \"${tubeline}\"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment