How to Make a Video Entry/LoadingTimeScript

From LoadingReadyWiki
Jump to: navigation, search

This is a script that generates a barebones wiki page for the latest Loading Time. It was created on Ubuntu Linux, but should run on any unix-like system.

#!/bin/bash

#Retrieve lrr homepage and extract link to latest loading time
wget loadingreadyrun.com 2> /dev/null
grep -A1 "latest_by_category bonus" < index.html > buffer
tail -1 < buffer > buffer2
sed 's/^[ \t]*//' < buffer2 > buffer4
sed 's/<a\ href=\"//' < buffer4 > buffer5
sed 's/\".*//' < buffer5 > buffer6
cat buffer6 > VIDEOLINK

#Retrieve escapist article page and forumlink for the video
wget http://www.escapistmagazine.com/articles/view/columns/loading-time 2> /dev/null
grep -m1 -A2 article_footer < loading-time > buffer
tail -2 < buffer > buffer2
tail -1 < buffer2 > buffer3
sed 's/.*\href=\"//' < buffer3 > buffer4
sed 's/\".*//' < buffer4 > ARTICLELINK
head -1 < buffer2 > buffer3
sed 's/.*\href=\"//' < buffer3 > buffer4
sed 's/\".*//' < buffer4 > ESCAPISTFORUMLINK

videopage=`cat VIDEOLINK`
wget $videopage 2> /dev/null
videopage=`basename $videopage`
mv $videopage videopage

#Extract blurb
grep -m1 "description" < videopage > buffer7
sed 's/^[ \t]*//' < buffer7 > buffer8
sed 's/<meta name=\"description\" content=\"//' < buffer8 > buffer9
sed 's/Read.*//' < buffer9 > BLURB

#Extract the name of the previous video
rm buffer*
grep -m1 -A10 "size_recent" < videopage > buffer
grep -m1 -A1 "video_info" < buffer > buffer2
tail -1 < buffer2 > buffer3
sed 's/.*\">//' < buffer3 > buffer5
sed 's/<\/a>.*//' < buffer5 > PREVIOUS

#Extract the date
rm buffer*
grep -A1 "video_header" < videopage > buffer
tail -1 buffer > buffer2
sed 's/\(.*>\)\([A-Z][a-z][a-z]*\) \([0-9][0-9]\), \([0-9][0-9][0-9][0-9]\).*/\2 \3 \4/' < buffer2 > buffer3 
date -d "`cat buffer3`" +"%d %b %Y" > buffer2
date -d "`cat buffer3`" +"%B %d, %Y" > DATE

#Extract lrrforumnumber
wget http://loadingreadyrun.com/forum/viewforum.php?f=15 2> /dev/null
grep "Posted: `cat buffer2`" viewforum.php\?f\=15 > buffer3
sed 's/.*t=\([0-9][0-9]*\).*/\1/' < buffer3 > LRRFORUMNUMBER

#remove superfluous files and existing wikipage
rm buffer*
rm videopage
rm loading-time
rm index.html
rm viewforum.php\?f\=15
rm WIKIPAGE

#Piece together the wikipage
echo ""`cat < BLURB` >> WIKIPAGE
echo "" >> WIKIPAGE
echo "==Vital Statistics==" >> WIKIPAGE
echo "'''Date:''' "`cat DATE` >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Category:'''  Loading Time" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Appearing:'''  " >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Shooting:''' [[Raymond Steacy]]" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Editing:'''  Raymond Steacy" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "==Synopsis== " >> WIKIPAGE
echo "A behind-the-scenes look at [[]]" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "==Trivia==" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "{{LoadingTimeNavigation|"`cat PREVIOUS`"|-|"`cat VIDEOLINK`"|"`cat LRRFORUMNUMBER`"|"`cat ARTICLELINK`"|"`cat ESCAPISTFORUMLINK`"}}" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "[[Category:Season Nine]]" >> WIKIPAGE

#remove info files
rm BLURB
rm DATE
rm PREVIOUS
rm VIDEOLINK
rm LRRFORUMNUMBER
rm ESCAPISTFORUMLINK
rm ARTICLELINK