How to Make a Video Entry/LRRCastScript

From LoadingReadyWiki
Jump to: navigation, search

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

#!/bin/bash

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

grep -A1 "latest_by_category vidcast" < 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 page for the video
videopage=`cat buffer6`
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/\".*//' < 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=13 2> /dev/null
grep "Posted: `cat buffer2`" viewforum.php\?f\=13 > buffer3
sed 's/.*t=\([0-9][0-9]*\).*/\1/' < buffer3 > LRRFORUMNUMBER

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

#Piece together the wikipage
echo ""`cat < BLURB` >> WIKIPAGE
echo "" >> WIKIPAGE
echo "==Vital Statistics==" >> WIKIPAGE
echo "'''Date released:''' "`cat DATE` >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Featured Videos:''' " >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''LRRcasters:''' " >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Runtime:''' " >> WIKIPAGE
echo "" >> WIKIPAGE
echo "==Synopsis==" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "==AskLRR==" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "==Trivia==" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "{{LRRCastNavigation|"`cat PREVIOUS`"|-|"`cat VIDEOLINK`"|"`cat AUDIOLINK`"||"`cat LRRFORUMNUMBER`"}}" >> WIKIPAGE
echo "[[Category:Season Nine]]" >> WIKIPAGE

#remove info files
rm BLURB
rm DATE
rm PREVIOUS
rm VIDEOLINK
rm LRRFORUMNUMBER
rm AUDIOLINK