Autodownload script

Come up with a useful post-processing script? Share it here!
Post Reply
minimad
Release Testers
Release Testers
Posts: 62
Joined: January 11th, 2009, 5:45 pm

Re: Autodownload script

Post by minimad »

Hi All,

Updated Script:

http://pastebin.com/m4d8b4b8a

Fixed a bug in my branch of DoubleDrat's script.  Nows sends the correct nzb name to the isInQueue function, it was sending the modifed name which of course didn't match when SABnzbd downloaded the nzb.

minimad

minimad
Release Testers
Release Testers
Posts: 62
Joined: January 11th, 2009, 5:45 pm

Re: Autodownload script

Post by minimad »

Updated Script:

http://pastebin.com/f31a31e8e


Important changes:

New Queue check - Looks for the series, episode rather than the filename of the NZB.
theTVDB intergration - Now requires tvdb_api, gets the correct series name from theTVDB.

markus101
Release Testers
Release Testers
Posts: 413
Joined: August 13th, 2008, 2:51 am

Re: Autodownload script

Post by markus101 »

Hi,

I've got a quick Question on how to get this working for me. I'm using Linux (unRAID 0.4.4 - based on Slackware 12.1) my TV shows are all located in "/mnt/user/tv" the full path for example would be "/mnt/user/tv/House/Season 1/House - S01E01 - Example"

My problem is that when I run rss_tv.py it grabs the RSS feed properly (Newzbin) but says Format Not Wanted: (I tried testing with something that was currently on the RSS Feed "Psych"), but I get the same message.

I'm just wondering if I need to make any changes to the py file (outside of the "normal" config changes to set my directories, to use Newzbin and my SAB Address).

Please let me know, I'd love to not have to delete dupes that I get almost daily due to the normal SAB RSS Feed reader finding a new NZB file in the feed.

EDIT: I'm using a XVid Specific feed, and looking for XVid only.
video_formats="[xX][vV][iI][dD]"

Thanks,

Markus101
Last edited by markus101 on January 20th, 2009, 7:12 pm, edited 1 time in total.
Co-developer of NzbDrone (.Net NNTP PVR) - http://www.nzbdrone.com

pilGrim
Full Member
Full Member
Posts: 116
Joined: January 9th, 2009, 7:28 pm
Location: Hong Kong, SAR China

Re: Autodownload script

Post by pilGrim »

markus101 wrote: Hi,

I've got a quick Question on how to get this working for me. I'm using Linux (unRAID 0.4.4 - based on Slackware 12.1) my TV shows are all located in "/mnt/user/tv" the full path for example would be "/mnt/user/tv/House/Season 1/House - S01E01 - Example"

My problem is that when I run rss_tv.py it grabs the RSS feed properly (Newzbin) but says Format Not Wanted: (I tried testing with something that was currently on the RSS Feed "Psych"), but I get the same message.

I'm just wondering if I need to make any changes to the py file (outside of the "normal" config changes to set my directories, to use Newzbin and my SAB Address).

Please let me know, I'd love to not have to delete dupes that I get almost daily due to the normal SAB RSS Feed reader finding a new NZB file in the feed.

EDIT: I'm using a XVid Specific feed, and looking for XVid only.
video_formats="[xX][vV][iI][dD]"

Thanks,

Markus101

Markus, does newzbin have the xvid in the title for the show in the RSS feed?  I don't know how newzbind feeds work, but this feature works well with TVBINZ.net  I tested it last night.

markus101
Release Testers
Release Testers
Posts: 413
Joined: August 13th, 2008, 2:51 am

Re: Autodownload script

Post by markus101 »

No, it doesn't, which makes perfect sense - It's a nice clean title without the format listed, which would explain everything and why the initial script by popcorn works... I'll see what I can do to strip the format from the script, because I really like the idea of using TheTVDB to grab info, albeit I run tvrename (http://tvrename.com) to rename shows/keep track of what I'm missing, but it also uses TheTVDB for its backend database.

Thanks for your input pilGrim - I guess it's time to 'learn' python, or at least enough to stumble through this...

EDIT: Looks like a minor change to the python file :) After a few minutes of Trial and Error, all that was needed, was to comment out the following:
#        if not isFormatWanted(report):
#            if debug:
#                print("Format Not Wanted: " + report)
#            raise FormatNotWanted

Thanks for the push in the right direction pilGrim, and minimad for the excellent script.

EDIT2: It's now attempting to process the RSS feed, it also finds missing files, but it doesn't download the nzb/send the report to SAB...
It says its missing the file, but never downloads it (nor a mention of it goign to be downloaded). Any suggestions?

EDIT3: Issue also happens where it says missing, but fails to start the download of the file for my nzbs.org TV feed (which contains xvid in teh title and uses the unmodified script).
Last edited by markus101 on January 21st, 2009, 2:52 am, edited 1 time in total.
Co-developer of NzbDrone (.Net NNTP PVR) - http://www.nzbdrone.com

pilGrim
Full Member
Full Member
Posts: 116
Joined: January 9th, 2009, 7:28 pm
Location: Hong Kong, SAR China

Re: Autodownload script

Post by pilGrim »

markus101 wrote: EDIT2: It's now attempting to process the RSS feed, it also finds missing files, but it doesn't download the nzb/send the report to SAB...
It says its missing the file, but never downloads it (nor a mention of it going to be downloaded). Any suggestions?
Minimad has done the heavy lifting on the script changes and I have done a lot of testing and bug checks.  the problem is that neither of us are members to newzbin to ensure the newzbin compatibility works.  My understanding of newzbin was that you can create a custom RSS feed that would only give you xvid or HD so the check is probably not needed?  if your RSS feed already sorts out to xvid only I would set the variable at the top to =""  that way you can leave the main section remed so when it is called it does not cause other issues in the code

For not queue issue, when testing I normally put SAB up and pause it so I can see what stacks up in the queue.  The section of code that actually puts the file into the queue is here:

Code: Select all

#
def download(report_id):

    print "Adding to QUEUE: " + time.strftime("%Y-%m-%d %H:%M:%S")+": "+ report

    #put your address for the api stuff here

    if NewzBin:

        #NewzBin Style

        urllib.urlopen(my_SAB+"/sabnzbd/api?mode=addid&name="+report_id+my_SAB_params)

    else:

        #'Other' NZB RSS

        urllib.urlopen(my_SAB+"/sabnzbd/api?mode=addurl&name="+report_id+my_SAB_params)

    #end if NewzBin
If you use an editor like ActiveState Komodo you can put a stop on the code to ensure it is branching to the newzbin line.  I would think this line is taken directly from one of the earlier versions that was newzbin only, so should work. 

markus101
Release Testers
Release Testers
Posts: 413
Joined: August 13th, 2008, 2:51 am

Re: Autodownload script

Post by markus101 »

Doh, Why didn't i think of that...I was thinking it would have to be a * in the quotes, which breaks everything - Okay started with a base script again and running though works (without any other changes to the script). It takes a bit to run through, but when it finishes it still hasn't added anything to the Queue. Nor do I get the output:

Code: Select all

print "Adding to QUEUE: " + time.strftime("%Y-%m-%d %H:%M:%S")+": "+ report
Which should get displayed if a report is getting added to the queue, which would point to an issue actually calling the download definition.
Which to my knowledge is this portion of the script:

Code: Select all

        #if isWanted(series) and isMissing(series, season, episode) and (not isInQueue(report_original)):
        if isWanted(series) and isMissing(series, season, episode) and (not isInQueueSmart(series, season, episode)):
            msgid=node.getElementsByTagName("link")[0].childNodes[0].data
            msgid=urllib.quote(msgid)
            download(msgid)
        #end if isWanted(series)
Any suggestions would be great - I'm willing to be a test dummy for the Newzbin portion if wanted/needed.
Co-developer of NzbDrone (.Net NNTP PVR) - http://www.nzbdrone.com

minimad
Release Testers
Release Testers
Posts: 62
Joined: January 11th, 2009, 5:45 pm

Re: Autodownload script

Post by minimad »

well,

looks like I broke something in the script.  As pilGrim said, we both don't have access to newzbin so its good to get someone trying my script out that does.

Be warned, not all my versions I post will work, as i mostly code between 10pm and 1am and anything after midnight tends to get a bit fuzzy :-), missing varibles, spelling mistakes and such like.

pilGrim uses Windows, your on Linux and I use both :-).  You may have noticed the win32 specific bit for the directory path, I got fed up with changing it each time i was testing.

possible the 'Smart' queue check doesn't like the Newzbin feed.  Sounds like the script is just 'bugging' out in the queue check, I had this happen on me last night, put a load of '24' nzbs in the queue and as it was trying to get the file the queue has 'Trying to get file xxxxxx' or something similar, this caused the code to to bomb out.  If the filename from the queue doesn't match the format expected the script just quits the bit its doing then carries on as if it did it.

OK,  here's my plan of action

1,  Make the format check dependant on the 'Newzbin' option in user config (false uses the format check, true doesn't use it). This one's Easy

2,  Make the 'Smart' queue check a user config option.

3,  markus101, if possible can you post me (via pastebin.com) a copy of a newzbin feed with the shows you are interest in, in it.  I'm flying sort of blind when it comes to the newzbin feed, never seen one, just made assumptions based on the code.

4,  Fix the 'Smart' queue, as to not quit if it gets something unexpected.

markus101,

Where are you based?  I'm in the UK, pilGrim is in Hong Kong so time differences make things interesting :-)

minimad
Release Testers
Release Testers
Posts: 62
Joined: January 11th, 2009, 5:45 pm

Re: Autodownload script

Post by minimad »

Ok,

Modified Script:

http://pastebin.com/f4f9b11bd

Major Changes:

Format check is now dependant on if you are using NewzBin or not
'Smart' queue check is now optional
'Smart' queue shouldn't exit if it finds something 'odd'
new Known Issues section
moved change log to top of script
added additional debug statement (controled by the debug option)
cleaned up the code and made it 'style' consistant.

Needs someone with a NewzBin account to test that side of things

Please test and PM me if anything odd.

markus101
Release Testers
Release Testers
Posts: 413
Joined: August 13th, 2008, 2:51 am

Re: Autodownload script

Post by markus101 »

Oooh sounds good, I'll try to test it out tonight and get you some feedback.

I'm based in BC, Canada, so I'm PST, it's only 5pm now, so I should have an opportunity to test this out before the night's over.

EDIT: Did some testing, looks good, came back to an error with newzbin, saying the server is having issues (500) blah blah blah. It then wouldn't add files to the queue...anyone else have issues with Newzbin tonight? or do they just hate me today?:(

Cheers,

markus101
Last edited by markus101 on January 22nd, 2009, 3:50 am, edited 1 time in total.
Co-developer of NzbDrone (.Net NNTP PVR) - http://www.nzbdrone.com

Nesousx
Newbie
Newbie
Posts: 9
Joined: January 22nd, 2009, 7:39 am
Contact:

Re: Autodownload script

Post by Nesousx »

Hi guys,

I'm trying the last Minimad script but have the following error :

Code: Select all

D:\Docs>TV_Dler.py
Traceback (most recent call last):
  File "D:\Docs\TV_Dler.py", line 12, in <module>
    from tvdb_api import (tvdb_error, tvdb_shownotfound, tvdb_seasonnotfound,
ImportError: No module named tvdb_api
I'm running Win Vista 32 bits. I just copied / pasted the script into a txt file, edited it to my needs, installed python 2.5.4 and launched the edited /renamed script (from .txt to .py) in commandline.
I never installed any tvdb_api, and found something on google named tvdb_api, but I can't seem to be able to download it (the page doesn't exists or so).

Any help would be very appreciated, thanks in advance.

pilGrim
Full Member
Full Member
Posts: 116
Joined: January 9th, 2009, 7:28 pm
Location: Hong Kong, SAR China

Re: Autodownload script

Post by pilGrim »

Nesousx wrote: Hi guys,

I'm trying the last Minimad script but have the following error :

Code: Select all

D:\Docs>TV_Dler.py
Traceback (most recent call last):
  File "D:\Docs\TV_Dler.py", line 12, in <module>
    from tvdb_api import (tvdb_error, tvdb_shownotfound, tvdb_seasonnotfound,
ImportError: No module named tvdb_api
I'm running Win Vista 32 bits. I just copied / pasted the script into a txt file, edited it to my needs, installed python 2.5.4 and launched the edited /renamed script (from .txt to .py) in commandline.
I never installed any tvdb_api, and found something on google named tvdb_api, but I can't seem to be able to download it (the page doesn't exists or so).

Any help would be very appreciated, thanks in advance.
You need all the TVDP_api files.  Just dl them and put them in the same directory.  You can find them here: http://github.com/dbr/tvdb_api/tree/master

Nesousx
Newbie
Newbie
Posts: 9
Joined: January 22nd, 2009, 7:39 am
Contact:

Re: Autodownload script

Post by Nesousx »

pilGrim wrote:
You need all the TVDP_api files.  Just dl them and put them in the same directory.  You can find them here: http://github.com/dbr/tvdb_api/tree/master

I'have got a new error now :p

Code: Select all

D:\Docs\Scripts>TV_Dler.py
Traceback (most recent call last):
  File "D:\Docs\Scripts\TV_Dler.py", line 12, in <module>
    from tvdb_api import (tvdb_error, tvdb_shownotfound, tvdb_seasonnotfound,
  File "D:\Docs\Scripts\tvdb_api.py", line 5
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    ^
SyntaxError: invalid syntax
Do I need to edit anything in the files I just DLed?  Thanks

nm, got it working !!

Thanks much :)
Last edited by Nesousx on January 22nd, 2009, 8:21 am, edited 1 time in total.

Nesousx
Newbie
Newbie
Posts: 9
Joined: January 22nd, 2009, 7:39 am
Contact:

Re: Autodownload script

Post by Nesousx »

Well actually, it doesn't really work.

I got the following :

Code: Select all

D:\Docs\Scripts>TV_Dler.py
Processing :Lost.S05E02.720p.HDTV.x264-2HD
2009-01-22 14:47:12,375) DEBUG Retriving URL http://www.thetvdb.com/api/0629B785
CE550C8D/mirrors.xml
2009-01-22 14:47:12,378) DEBUG Found mirror <mirror>
<id>1</id>
<mirrorpath>http://thetvdb.com</mirrorpath>
<typemask>7</typemask>
</mirror>
2009-01-22 14:47:12,380) DEBUG Found total of 1 mirrors
ORIG:  Lost
2009-01-22 14:47:12,381) DEBUG Getting show lost
2009-01-22 14:47:12,381) DEBUG Retriving URL http://thetvdb.com/api/GetSeries.ph
p?seriesname=lost
2009-01-22 14:47:12,461) DEBUG Found series Lost (id: 73739)
2009-01-22 14:47:12,463) DEBUG Found series Lost Universe (id: 73181)
2009-01-22 14:47:12,464) DEBUG Found series Lost (2001) (id: 72906)
2009-01-22 14:47:12,466) DEBUG Found series Lost in Space (id: 72923)
2009-01-22 14:47:12,467) DEBUG Found series Lost in Austen (id: 82934)
2009-01-22 14:47:12,469) DEBUG Found series Lost Civilizations (id: 80525)
2009-01-22 14:47:12,470) DEBUG Found series Lost Highway (id: 74729)
2009-01-22 14:47:12,470) DEBUG Found series Lost at Home (id: 71150)
2009-01-22 14:47:12,473) DEBUG Found series Lost on Earth (id: 71225)
2009-01-22 14:47:12,473) DEBUG Found series Lost Cities of the Ancients (id: 837
41)
2009-01-22 14:47:12,474) DEBUG Found series Lost Land of the Jaguar (id: 82715)
2009-01-22 14:47:12,476) DEBUG Found series Lost Treasures of NFL Films (id: 738
31)
2009-01-22 14:47:12,477) DEBUG Found series Land of the Lost (id: 71177)
2009-01-22 14:47:12,479) DEBUG Found series Lost Worlds (id: 80685)
2009-01-22 14:47:12,480) DEBUG Found series Lost Worlds, Vanished Lives (id: 796
16)
2009-01-22 14:47:12,482) DEBUG Found series Lost (UK) (id: 80595)
2009-01-22 14:47:12,483) DEBUG Found series The Lost Tomb of Jesus (id: 81028)
2009-01-22 14:47:12,483) DEBUG Found series Secrets of Lost Empires (id: 83797)
2009-01-22 14:47:12,484) DEBUG Found series The Secret Of Lost Creek (id: 73162)

2009-01-22 14:47:12,486) DEBUG Found series Xam`d: Lost Memories (id: 82834)
2009-01-22 14:47:12,489) DEBUG Found series The Lost Room (id: 79637)
2009-01-22 14:47:12,490) DEBUG Found series The Lost Tribes (id: 80333)
2009-01-22 14:47:12,490) DEBUG Found series The Lost Saucer (id: 73549)
2009-01-22 14:47:12,492) DEBUG Found series The Lost Gods (id: 82275)
2009-01-22 14:47:12,493) DEBUG Found series WWII: The Lost Color Archives (id: 8
2250)
2009-01-22 14:47:12,494) DEBUG Found series History's Lost and Found (id: 83333)

2009-01-22 14:47:12,496) DEBUG Found series Brats of the Lost Nebula (id: 78687)

2009-01-22 14:47:12,497) DEBUG Found series The Lost World (id: 78457)
2009-01-22 14:47:12,499) DEBUG Found series The Man who Lost his Head (id: 81313
)
2009-01-22 14:47:12,500) DEBUG Found series The Lost Prince (id: 84482)
2009-01-22 14:47:12,502) DEBUG Found series Land of the Lost (1991) (id: 76861)
2009-01-22 14:47:12,503) DEBUG Found series Finder of Lost Loves (id: 73420)
2009-01-22 14:47:12,503) DEBUG Auto-selecting first search result
2009-01-22 14:47:12,503) DEBUG Got Lost, sid 73739
2009-01-22 14:47:12,503) DEBUG Getting all episodes of 73739
2009-01-22 14:47:12,505) DEBUG Retriving URL http://thetvdb.com/api/0629B785CE55
0C8D/series/73739/all/
2009-01-22 14:47:13,773) DEBUG Got series id 73739
Processing :CSI.Miami.S07E13.720p.HDTV.X264-DIMENSION
2009-01-22 14:47:13,775) DEBUG Retriving URL http://www.thetvdb.com/api/0629B785
CE550C8D/mirrors.xml
2009-01-22 14:47:13,775) DEBUG Retriving URL http://www.thetvdb.com/api/0629B785
CE550C8D/mirrors.xml
2009-01-22 14:47:13,778) DEBUG Found mirror <mirror>
<id>1</id>
<mirrorpath>http://thetvdb.com</mirrorpath>
<typemask>7</typemask>
</mirror>
2009-01-22 14:47:13,778) DEBUG Found mirror <mirror>
<id>1</id>
<mirrorpath>http://thetvdb.com</mirrorpath>
<typemask>7</typemask>
</mirror>
2009-01-22 14:47:13,779) DEBUG Found total of 1 mirrors
2009-01-22 14:47:13,779) DEBUG Found total of 1 mirrors
ORIG:  CSI Miami
2009-01-22 14:47:13,782) DEBUG Getting show csi miami
2009-01-22 14:47:13,782) DEBUG Getting show csi miami
2009-01-22 14:47:13,782) DEBUG Retriving URL http://thetvdb.com/api/GetSeries.ph
p?seriesname=csi+miami
2009-01-22 14:47:13,782) DEBUG Retriving URL http://thetvdb.com/api/GetSeries.ph
p?seriesname=csi+miami
2009-01-22 14:47:13,789) DEBUG Found series CSI: Miami (id: 78310)
2009-01-22 14:47:13,789) DEBUG Found series CSI: Miami (id: 78310)
2009-01-22 14:47:13,789) DEBUG Auto-selecting first search result
2009-01-22 14:47:13,789) DEBUG Auto-selecting first search result
2009-01-22 14:47:13,789) DEBUG Got CSI: Miami, sid 78310
2009-01-22 14:47:13,789) DEBUG Got CSI: Miami, sid 78310
2009-01-22 14:47:13,790) DEBUG Getting all episodes of 78310
2009-01-22 14:47:13,790) DEBUG Getting all episodes of 78310
2009-01-22 14:47:13,792) DEBUG Retriving URL http://thetvdb.com/api/0629B785CE55
0C8D/series/78310/all/
2009-01-22 14:47:13,792) DEBUG Retriving URL http://thetvdb.com/api/0629B785CE55
0C8D/series/78310/all/
2009-01-22 14:47:15,493) DEBUG Got series id 78310
2009-01-22 14:47:15,493) DEBUG Got series id 78310

D:\Docs\Scripts>
But it doesn't load anything into sabnzd queue / actual download.

Any idea?

EDIT : edited with the debug output.
Last edited by Nesousx on January 22nd, 2009, 8:49 am, edited 1 time in total.

pilGrim
Full Member
Full Member
Posts: 116
Joined: January 9th, 2009, 7:28 pm
Location: Hong Kong, SAR China

Re: Autodownload script

Post by pilGrim »

Nesousx wrote: Well actually, it doesn't really work.


But it doesn't load anything into sabnzd queue / actual download.

Any idea?

EDIT : edited with the debug output.
Did you download the TVDB files from the download package?  Oddly I had to refresh those files today and the zip file I downloaded was corrupt.  I clicked on each which shows the code, then click the "raw" button or link, this gives you a clean version in your browser, basically save as to get each file one by one.  I was getting all kinds of errors on the TVDB calls until I got one by one clean files

Post Reply