How to Make a Video Entry/WeeklyScript

From LoadingReadyWiki
Jump to: navigation, search

This is a script that generates a barebones wiki page for the latest weekly update. 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 -A1 "latest_by_category lrr" < 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 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=6 2> /dev/null
grep "Posted: `cat buffer2`" viewforum.php\?f\=6 > 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\=6
rm WIKIPAGE

#Piece together the wikipage
echo "NAMES (To copy-paste into credits)" >> WIKIPAGE
echo "Graham Stark" >> WIKIPAGE
echo "Paul Saunders" >> WIKIPAGE
echo "Kathleen De Vere" >> WIKIPAGE
echo "James Turner" >> WIKIPAGE
echo "Matt Wiggins" >> WIKIPAGE
echo "Jeremy Petter" >> WIKIPAGE
echo "Tally Heilke" >> WIKIPAGE
echo "Dale Friesen" >> WIKIPAGE
echo "Jess Bell" >> WIKIPAGE
echo "Ryan Downing" >> WIKIPAGE
echo "Andrew Cownden" >> WIKIPAGE
echo "Cameron Lauder" >> WIKIPAGE
echo "Raymond Steacy" >> WIKIPAGE
echo "Alex Steacy" >> WIKIPAGE
echo ""`cat < BLURB` >> WIKIPAGE
echo "" >> WIKIPAGE
echo "==Vital Statistics==" >> WIKIPAGE
echo "'''Date:''' "`cat DATE` >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Category:'''  Shorts" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Appearing:'''" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Writing:'''" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Camera:'''" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Boom:'''" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Editing:'''" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "==Synopsis==" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "==Trivia==" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "{{EscapistShortsNavigation|Season Nine|"`cat PREVIOUS`"|-|"`cat VIDEOLINK`"|"`cat LRRFORUMNUMBER`"|"`cat ESCAPISTFORUMLINK`"}}" >> WIKIPAGE

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