2012-10-29, 05:14
I was also able to use TVRage as a source, by modifying two functions downloadInfoAboutMatchedTitleAndCreateTxtFileTables () and searchTheTvDbAndReturnTxtFileTables(), TVRage doesn't have Zap2It IDs and doesn't track times for when their database is updated. I was able to leave those functions alone however and by just making the changes to the two functions mentioned, run mythicalLibrarian with TVRage as the datasource.
Sorry outleradam, I was going to try and make the changes to support TVRage as a second/backup source, but my bashfoo is weak. Hopefully this is enough for you to be able to add it in as a second/backup source.
The changes are actually really minor, but I'm just going to include the entirety of the two functions below.
The Zap2It parsing can probably be pulled out since TVRage doesn't include the Zap2It number in it's public listings, I left it in however, so zap2it.txt will get cleared in case it still exists from a previous run. (although I do believe that mythicalLibrarian cleans all that up after it's done anyway). Also the call to searchTheTvDbAndReturnTxtFileTables() has to be changed to this function if you're just doing a straight change from thetvdb to TVRage.
Sorry outleradam, I was going to try and make the changes to support TVRage as a second/backup source, but my bashfoo is weak. Hopefully this is enough for you to be able to add it in as a second/backup source.
The changes are actually really minor, but I'm just going to include the entirety of the two functions below.
Code:
#####GET EPISODE INFORMATION#####
downloadInfoAboutMatchedTitleAndCreateTxtFileTables () {
#Download information from server
echo -ne "Downloading Series: $SeriesID
" 1>&2
curl -L -s -m"$Timeout" "http://services.tvrage.com/feeds/episode_list.php?sid=$SeriesID"| sed -e s/\>\</\>\\\n\</g >"$mythicalLibrarian/$NewShowName/$NewShowName.xmlTest" && echo "$CurrentTime" > "$mythicalLibrarian/$NewShowName/lastupdated.time"
#Validate that the show has a EpisodeName tag and is a valid download before clobering our old download.
grepTest=""
grepTest=`grep "title" "$mythicalLibrarian/$NewShowName/$NewShowName.xmlTest"`
test "$grepTest" != "" && mv "$mythicalLibrarian/$NewShowName/$NewShowName.xmlTest" "$mythicalLibrarian/$NewShowName/$NewShowName.xml"
#create a folder/file "database" Strip XML tags. Series, Exx and Sxx are separated into different files
if [ -f "$mythicalLibrarian/$NewShowName/$NewShowName.xml" ]; then
Ename=""
actualEname=""
FAired=""
SeasonNr=""
EpisodeNr=""
recordNumber=0
echo "Parsing Downloaded information: $NewShowName.xml "
while read line
do
if [[ $line == \<\/episode\> ]]; then
(( ++recordNumber ))
echo -ne "Building Record:$recordNumber ${actualEname:0:20}
" 1>&2
echo "$actualEname" >> "$mythicalLibrarian/$NewShowName/$NewShowName.actualEname.txt"
echo "$Ename" >> "$mythicalLibrarian/$NewShowName/$NewShowName.Ename.txt"
echo "$FAired" >> "$mythicalLibrarian/$NewShowName/$NewShowName.FAired.txt"
echo "$SeasonNr" >> "$mythicalLibrarian/$NewShowName/$NewShowName.S.txt"
echo "$EpisodeNr" >> "$mythicalLibrarian/$NewShowName/$NewShowName.E.txt"
Ename=""
actualEname=""
FAired=""
SeasonNr=""
EpisodeNr=""
#Get actual show name
elif [[ $line == \<title\>* ]]; then
line=${line/<\/title>/}
line=${line/<title>/}
line=${line/</}
line=${line/>/}
line=${line/"/}
line=${line/&/&}
line=${line/|/}
line=${line/\?/}
line=${line/\*/}
line=${line/:/}
line=${line/+/}
line=${line/\/}
line=${line/\//}
line=${line/[/}
line=${line/]/}
line=${line/\'/}
line=${line/\"/}
actualEname=${line/–/-}
Ename=${actualEname/;*/}
#Get OriginalAirDate
elif [[ $line == \<airdate\>* ]]; then
line=${line/<\/airdate>/}
line=${line/<airdate>/}
FAired=$line
#Get Season number
elif [[ $line == \<seasonnum\>* ]]; then
line=${line/<\/seasonnum>/}
line=${line/<seasonnum>/}
SeasonNr=$line
#Get Episode number
elif [[ $line == \<epnum\>* ]]; then
line=${line/<\/epnum>/}
line=${line/<epnum>/}
EpisodeNr=$line
fi
done < "$mythicalLibrarian/$NewShowName/$NewShowName.xml"
chmod 666 "$mythicalLibrarian"/"$NewShowName"/"$NewShowName".actualEname.txt
chmod 666 "$mythicalLibrarian"/"$NewShowName"/"$NewShowName".Ename.txt
chmod 666 "$mythicalLibrarian/$NewShowName/$NewShowName".FAired.txt
chmod 666 "$mythicalLibrarian"/"$NewShowName"/"$NewShowName".S.txt
chmod 666 "$mythicalLibrarian/$NewShowName/$NewShowName".E.txt
GotNewInformation=1
elif [ ! -f "$mythicalLibrarian/$NewShowName/$NewShowName.xml" ]; then
echo "COULD NOT DOWNLOAD:services.tvrage.com/feeds/episode_list.php?sid=$SeriesID">>"$mythicalLibrarian"/output.log
fi
#check if files were created and generate message
if [ "$GotNewInformation" = "1" ]; then
return 0
echo $CurrentTime>"$mythicalLibrarian/$NewShowName/lastupdated.time" && chmod 666 $CurrentTime>"$mythicalLibrarian/$NewShowName/lastupdated.time"
echo "LOCAL DATABASE UPDATED:$mythicalLibrarian/$NewShowName">>"$mythicalLibrarian"/output.log
elif [ ! -f "$mythicalLibrarian/$NewShowName/$NewShowName.Ename.txt" ]; then
echo "*** PERMISSION ERROR $mythicalLibrarian/$NewShowName/">>"$mythicalLibrarian"/output.log
return 1
fi
return 1
}
The Zap2It parsing can probably be pulled out since TVRage doesn't include the Zap2It number in it's public listings, I left it in however, so zap2it.txt will get cleared in case it still exists from a previous run. (although I do believe that mythicalLibrarian cleans all that up after it's done anyway). Also the call to searchTheTvDbAndReturnTxtFileTables() has to be changed to this function if you're just doing a straight change from thetvdb to TVRage.
Code:
#####SEARCH TVRage AND CREATE DATA FILES#####
searchTVRageAndReturnTxtFileTables(){
#TODO Instance searching rather then global. Need to create an instance varible based on time and chanid.
#Search TheTvDb and return an XML file with results
curl -L -s -m"$Timeout" services.tvrage.com/feeds/search.php?show=$tvdbshowname>"$mythicalLibrarian/working.xml"
#Separate the XML into textual DBs conatining SeriesID, ShowName and Zap2it IDs
cat "$mythicalLibrarian/working.xml" | grep "<showid>"|sed -e s/"<showid>"/""/ -e s/"<\/showid>"/""/ -e s/'"'/'"'/ -e s/"&"/"\&"/ -e s/'–'/'-'/ -e s/"<"/"<"/ -e s/">"/">"/ >"$mythicalLibrarian/sid.txt"
cat "$mythicalLibrarian/working.xml" | grep "<name>"| sed -e s/"<name>"// -e s/"<\/name>"// -e s/'"'/'"'/ -e s/"&"/"\&"/ -e s/'–'/'-'/ -e s/"<"/"<"/ -e s/">"/">"/ >"$mythicalLibrarian/shn.txt"
#parse the XML for shows with Zap2ItIDs
test -f "$mythicalLibrarian/zap2it.txt" && rm -f "$mythicalLibrarian/zap2it.txt"
while read line
do
test "$line" = "<show>" && NextShow=1
test "$line" = "</show>" && test "$NextShow" = "1" && echo "" >>"$mythicalLibrarian/zap2it.txt" && NextShow=0
if [[ $line =~ '<zap2it_id>'* ]] ; then
echo $line| sed -e s/"<zap2it_id>"/""/ -e s/"<\/zap2it_id>"/""/ -e s/'"'/'"'/ -e s/"&"/"\&"/ -e s/'–'/'-'/ -e s/"<"/"<"/ -e s/">"/">"/ >>"$mythicalLibrarian/zap2it.txt"
NextShow=0
fi
done < "$mythicalLibrarian/working.xml"
}