How to Make a Video Entry/CheckPointScript

From LoadingReadyWiki
Jump to: navigation, search

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

#!/bin/bash

#Retrieve lrr homepage and extract link to latest checkpoint episode
wget loadingreadyrun.com 2> /dev/null
grep -A1 "latest_by_category CPt" < 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 patv page for the video
videopage=`cat buffer6`
wget $videopage 2> /dev/null
videopage=`basename $videopage`
mv $videopage videopage

#Extract blurb
grep -A1 "Episode Notes" < videopage > buffer7
tail -1 < buffer7 > buffer8
sed 's/^[ \t]*//' < buffer8 > BLURB

#Extract the name of the previous video
rm buffer*
grep "Previous Episode" < videopage > buffer
sed 's/.*href=\"\(.*\)\">.*/\1/' < buffer > buffer3
prevvideopage=`cat buffer3`
wget $prevvideopage 2> /dev/null
prevvideopage=`basename $prevvideopage`
mv $prevvideopage prevvideopage
grep -A1 "pageTitleMid" < prevvideopage > buffer4
tail -1 < buffer4 > buffer5
sed 's/.*<\/strong> \(.*\)<\/h2>/\1/' < buffer5 > PREVIOUS

#GENERATE the date (Only works when done on the same day the video is posted)
date +"%d %b %Y" > buffer2
date +"%B %d, %Y" > DATE
#GENERATE a previous date (comment out when not in use)
#echo "26 Mar 2012" > buffer2
#echo "Mar 26, 2012" > DATE

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

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

#Piece together the wikipage

cat < BLURB >> WIKIPAGE
echo "" >> WIKIPAGE
echo "==Vital Statistics==" >> WIKIPAGE
echo "'''Date:''' "`cat DATE` >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Written and Performed By:''' [[Graham Stark]], [[Kathleen De Vere]], [[Paul Saunders]]" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Story Graphics:''' Paul Saunders" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''CheckPoint Graphics:''' Graham Stark" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Boom!''' [[Kate Stark]]" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Music:''' [[Bradley Rains]]" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Produced By:''' Graham Stark, Paul Saunders" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "==Stories==" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "==Feature Story==" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "{{CheckpointNavigation|"`cat PREVIOUS`"|-|"`cat VIDEOLINK`"|"`cat LRRFORUMNUMBER`"}}" >> WIKIPAGE

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