How to Make a Video Entry/UnSkippableScript

From LoadingReadyWiki
Jump to: navigation, search

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

#!/bin/bash

#Retrieve lrr homepage and extract link to latest unskippable episode
wget loadingreadyrun.com 2> /dev/null
grep -A1 "latest_by_category unskip" < index.html > buffer
rm index.html
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 link to the escapist forum
rm buffer*
grep "comment_link" < videopage > buffer
tail -1 < buffer > buffer2
sed 's/.*\href=\"//' < buffer2 > buffer3
sed 's/\".*//' < buffer3 > ESCAPISTFORUMLINK

#Extract the name of the previous video
rm buffer*
grep "<< Prev" < videopage > buffer
sed 's/.*<< Prev: //' < buffer > buffer3
sed 's/<\/a>.*//' < buffer3 > PREVIOUS

#Extract the date
rm buffer*
grep -m1 "utc_timestamp" < videopage > buffer
sed 's/\(.*>\)\([0-9][0-9]*\) \([A-Z][a-z][a-z]\) \([0-9][0-9][0-9][0-9]\).*/\3 \2 \4/' < buffer > 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=23 2> /dev/null
grep "Posted: `cat buffer2`" viewforum.php\?f\=23 > buffer3
sed 's/.*t=\([0-9]*\).*/\1/' < buffer3 > LRRFORUMNUMBER

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

#Piece together the wikipage
cat < BLURB >> WIKIPAGE
echo "" >> WIKIPAGE
echo "==Vital Statistics==" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Date:''' "`cat DATE` >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Category:''' Unskippable" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Written And Performed By:''' [[Graham Stark]] and [[Paul Saunders]]" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "{{UnskippableNavigation|"`cat PREVIOUS`"|-|"`cat VIDEOLINK`"|"`cat LRRFORUMNUMBER`"|"`cat ESCAPISTFORUMLINK`"}}" >> WIKIPAGE

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