How to Make a Video Entry/FeedDumpScript

From LoadingReadyWiki
Jump to: navigation, search

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

#!/bin/bash

#Retrieve lrr homepage and extract link to latest feed dump
wget loadingreadyrun.com 2> /dev/null
#grep -A1 "latest_by_category feeddump" < index.html > buffer
#tail -1 < buffer > buffer2
#sed 's/^[ \t]*//' < buffer2 > buffer4
#sed 's/<a\ href=\"//' < buffer4 > buffer5
#sed 's/\".*//' < buffer5 > buffer6
echo "http://www.escapistmagazine.com/videos/view/feed-dump/5529-Commentary-All-Stars" > 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=27 2> /dev/null
grep "Posted: `cat buffer2`" viewforum.php\?f\=27 > 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\=27
rm WIKIPAGE

#Piece together the wikipage
echo ""`cat < BLURB` >> WIKIPAGE
echo "" >> WIKIPAGE
echo "==Vital Statistics==" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Date:''' "`cat DATE` >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Appearing:''' [[Graham Stark]], " >> WIKIPAGE
echo "" >> WIKIPAGE
echo "'''Editing:'''" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "==Synopsis==" >> WIKIPAGE
echo "* News Word of the Week: " >> WIKIPAGE
echo "" >> WIKIPAGE
echo "==Trivia==" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "===Hatistics===" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "" >> WIKIPAGE
echo "{{FeedDumpNavigation|"`cat PREVIOUS`"|-|"`cat VIDEOLINK`"|"`cat LRRFORUMNUMBER`"|"`cat ESCAPISTFORUMLINK`"}}" >> WIKIPAGE

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