Created
March 3, 2011 17:23
-
-
Save guanix/853132 to your computer and use it in GitHub Desktop.
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/sh | |
# | |
# GRAPEFRUIT: Given a user, downloads all that user's videos. | |
# | |
USER=$1 | |
PAGE=$2 | |
if [ ! -d videos ] | |
then | |
mkdir videos | |
fi | |
if [ ! -d videos/$USER ] | |
then | |
mkdir videos/$USER | |
fi | |
# Using the PAGE attribution, know how many times we've been called. | |
if [ "$PAGE" ] | |
then | |
KEEPINGUPAPPEARANCES=$(($PAGE + 1)) | |
echo "[!] $USER Page $KEEPINGUPAPPEARANCES." | |
cd videos/$USER | |
VICTIM=$USER-$PAGE.html | |
SKIP=$(($PAGE * 10)) | |
wget -q -O $USER-$PAGE.html "http://video.yahoo.com/mypage/video?s=$USER&o=$SKIP" | |
else | |
echo "[!] $USER" | |
cd videos/$USER | |
wget -q -O $USER.html -q "http://video.yahoo.com/mypage/video?s=$USER" | |
VICTIM=$USER.html | |
PAGE=0 | |
fi | |
# extract URLs. | |
for fruitmeat in `grep \.com/watch $VICTIM | sed 's/.*href=\"//g' | cut -f1 -d'"' | sort -u` | |
do | |
CUTESY="`echo $fruitmeat | sed 's/.*watch\///g' | sed 's/\//-/g'`" | |
VNUM="`echo $CUTESY|tr "-" " "|awk '{print $2}'`" | |
if [ -f *-$VNUM.flv ] && [ -f *-$VNUM.html ]; then | |
echo "EXISTS: `ls *-$VNUM.flv`" | |
continue | |
fi | |
wget -q -O $CUTESY.html $fruitmeat | |
../../youtube-dl -l $fruitmeat | |
sleep 2 | |
done | |
# If there's a link for "Older", then call myself again, but this time add a page. | |
OLDIECHECK=`grep ">Older >" $VICTIM | grep href` | |
if [ "$OLDIECHECK" ] | |
then | |
echo "Yep! Another page of this!" | |
cd ../.. | |
PAGE=$(($PAGE+1)) | |
exec ./grapefruit $USER $PAGE | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment