script to check your NZBTV is up to date.

Come up with a useful post-processing script? Share it here!
Post Reply
relman
Release Testers
Release Testers
Posts: 46
Joined: September 30th, 2008, 2:42 am

script to check your NZBTV is up to date.

Post by relman »

Hi all, I don't know if anyone would be interested, but i've written a script which will read the Titles.XML from NZB-TV and check which season and episode you have entered and then check TVrage.com to see if you match it. It will then email you either telling you everything is ok or tell you there is a problem and list all the mismatches.

You can then run the vbscript as a scheduled task in windows.

For example. If you have Glee in NZBTV as season 1 with 4 episodes. It will email you now telling you there is season 1 epsidoes 10.

I like to keep my list clean so that searches run faster and I'm not hammering newzbin for episodes which don't exist. The reason I have written this is that when I iniitially setup a tv series on NZBTV i'll use tvrage to know what season and how many episodes but I have found this can change over the season where more are added or some are taken away.

Its easy to setup all you have to do is put in the path to your Titles.xml from NZBTV. If anyone is interested I'll post it.
User avatar
rascalli
Moderator
Moderator
Posts: 656
Joined: January 18th, 2008, 12:30 am
Location: Bossche bollen land

Re: script to check your NZBTV is up to date.

Post by rascalli »

i am interested
relman
Release Testers
Release Testers
Posts: 46
Joined: September 30th, 2008, 2:42 am

Re: script to check your NZBTV is up to date.

Post by relman »

Here it is. People can prob do better, but it works. I have added some comments to it if you feel you need to refine it. My VB skills are limited but I tried my best.

Code: Select all

on error resume next

'# NZB-TV checker VB Script  v1.02
'# 
'# Created by:   Relman
'# Last changed: 2009-06-15
'#
'#	SETUP
'#	-----
'#
'#	All you should need to do is edit the below items and thats all, then double click to run
'#	Or use Windows scheduler to automatically run.
'#	
'#	Any questions please PM me on the boards.
'#
'#############################
'
' Location of NZB-TV Titles.XML file
'	E.g. "C:\TV stuff\NZB-TV\Titles.xml"
'
NZBTVXML="C:\TV stuff\NZB-TV\Titles.xml"
'
'
' Enter in SMTP server and port settings.
'
Mailserver="test.email.com"
MailServerPort=25
'
'#############################
'
' Enter in Mailing addresses.
'
MailFrom="[email protected]"
MailTo="[email protected]"
MailCC="[email protected]"
'
'#############################



dim objectitem2temp
Set xmlDoc77 = CreateObject("Microsoft.XMLDOM")
xmlDoc77.Async = "False"
xmlDoc77.Load(NZBTVXML)


strQuery77 = "/root/A1[0]/A2" 'Show name
strQuery78 = "/root/A1[0]/A2/A3" 'Season
strQuery79 = "/root/A1[0]/A2/A3/A4" 'Episode

Set colItem77 = xmlDoc77.selectNodes("/root/A1[0]/A2")

'### This will go through each one for the looping, length = max record then minus one as number starts from zero ###
FOR i = 0 to (colItem77.length-1)

'### changed number to string so I could get it in the query ###

Number = CStr(i)

strQuery78 = "/root/A1[0]/A2[" + Number + "]/A3" 'Season
strQuery79 = "/root/A1[0]/A2[" + Number + "]/A3/A4" 'Episode
Set colItem78 = xmlDoc77.selectNodes(strQuery78)
Set colItem79 = xmlDoc77.selectNodes(strQuery79)
set objItem77 = colItem77(i)
set objItem78 = colItem78(colItem78.length-1)
set objItem79 = colItem79(colItem79.length-1)


Epnumbertemp1 = right(objItem79.Attributes.getNamedItem("Text").text, 2)
Epnumbertemp2 = CInt(Epnumbertemp1)
Epnumbertemp3 = Epnumbertemp2

'## Added this as in NZBTV there is no leading zero ##

If Epnumbertemp2 < 10 Then
	Epnumbertemp2 = CStr(Epnumbertemp2)
	Epnumbertemp3 = "0" + Epnumbertemp2 
End IF

'## Converts it back to a string so there is no mismatches
Epnumbertemp3 = CStr(Epnumbertemp3)

'## String used to compare with TVRage String

nzbtvsetting = "TV Show: " + objItem77.Attributes.getNamedItem("Text").text + " " + objItem78.Attributes.getNamedItem("Text").text + " Episodes: " + Epnumbertemp3

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@ End of NZB-TV Checking section
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

'#####################################

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@ Start of TV RAGE Checking section
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = "False"
xmlDoc.Load("http://services.tvrage.com/feeds/search.php?show=" + objItem77.Attributes.getNamedItem("Text").text)
strQuery = "/Results/show/showid"
Set colItem = xmlDoc.selectNodes(strQuery)
set objItem = colItem(0)
showid = objItem.text


'############# Had to add this as for some reason TVRage likes to use the sigma symbol rather then E's #########
'############# This basically just forces a showid rather then having to lookup the showid.            #########

If objItem77.Attributes.getNamedItem("Text").text = "Greek" then
showid = "16432"
end if

'@	## Put this in case you need to force any other names through if lookup doesn't work ##	
'@
'@	If objItem77.Attributes.getNamedItem("Text").text = "<text to match nzbtv title>" then
'@	showid = "<showid number>"
'@	end if



'############# End of forced value ###########

Set xmlDoc1 = CreateObject("Microsoft.XMLDOM")
xmlDoc1.Async = "False"
xmlDoc1.Load("http://services.tvrage.com/feeds/full_show_info.php?sid=" + showid)

strQuery1 = "/Show/totalseasons"
Set colItem1 = xmlDoc1.selectNodes(strQuery1)
set objItem1 = colItem1(0)

strQuery2 = "/Show/Episodelist/Season"
Set colItem2 = xmlDoc1.selectNodes(strQuery2)
set objItem2 = colItem2(colItem2.length-1)

strQuery3 = "/Show/Episodelist/Season/episode/seasonnum"
Set colItem3 = xmlDoc1.selectNodes(strQuery3)
set objItem3 = colItem3(colItem3.length-1)






tvragesetting = "TV Show: " + objItem77.Attributes.getNamedItem("Text").text + " Season " + objItem2.Attributes.getNamedItem("no").text + " Episodes: " + objItem3.text

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@ End of TV RAGE Checking section
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


'## This Part checks to see if there is a mismatch and if so will add it to the email body. ##

If nzbtvsetting = tvragesetting then

	'## Nothing needs to be here ##
Else
	EmailBody = Emailbody + vbCrLf + " NZBTV: " + nzbtvsetting + vbCrLf + "TVRage: " + tvragesetting + vbCrLf  + "sort it out!"
end If

Next
EmailSubject = "You need to sort out this man." 
temptext = left(EmailBody, 5)
temptext = right(temptext, 2)

'## crude way of checking if the body is empty so we know everything is ok ##

If temptext <> "NZ" then

Emailbody = "Everything is looking good"
EmailSubject = "Everything is looking good"
end if


'## Email sending section ##

Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = EmailSubject
objMessage.From = MailFrom 
objMessage.To = MailTo
objMessage.Cc = MailCC
objMessage.TextBody = EmailBody

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = Mailserver

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = MailServerPort

objMessage.Configuration.Fields.Update
objMessage.Send

'## END OF FILE ##
Post Reply