Autodownload script

Come up with a useful post-processing script? Share it here!
Post Reply
popcornarsonist
Newbie
Newbie
Posts: 13
Joined: January 28th, 2008, 6:53 pm

Autodownload script

Post by popcornarsonist »

I recently re-worked my automatic download system, writing it all in python this time. I don't like to use the default sabnzbd rss feeds, since it can't tell what I already have, so I worked up one that would only fill in episodes/movies that I'm missing. There are two ways of doing this:

Database
I don't like this, since it requires a full database of all your stuff, which is sometimes a bitch to populate, and it also requires that you add the database stuff into your post-processing script. This is why I went the route of:

Filesystem
I have all of my TV and Movies pretty well organized, so it's pretty easy to read straight from the file system. My TV is in the format
"BASE_DIRECTORY/SHOW_NAME/Season SEASON_NUMBER/SHOW_NAME - SEASON_NUMBERxEPSIODE_NUMBER - EPISODE_TITLE"
I imagine that a lot of you have your TV in the same format, so this script should be easily portable.

I'm uploading two scripts, here's a rundown on their functionality:

rss_tv.py:
http://pastebin.com/m7d0d3793
You'll need to update the script with some of your own information, namely:
-Your SABnzbd host:port info
-A newzbin RSS URL that will include all the TV you want (I just ran a search for shows in English, less than 450 MB, in divx or xvid.
-The path to your TV directory

With the correct information added, it will run through the feed, checking if you want any of the shows. This is decided based on wether you have a folder for that show, such as "BASE_TV_DIRECTORY/House". If the show is wanted, the script checks to see if you have that specific episode yet. If you don't, and the episode is not currently in the SABnzbd queue, it is added.

rss_movies:
http://pastebin.com/m24f8f3ab
You'll need to update the script with some of your own information, namely:
-Your SABnzbd host:port info
-A newzbin RSS URL that will include all the Movies you want (I just ran a search for movies in English, from 650-1600 MB, in divx or xvid.
-The path to your Movies directory

This script will run through the RSS feed and decide if the movie is "good". The logic I use is if the movie is over 8.0 on IMDB with over 1,000 votes, I won't mind downloading it. Of course, the script also checks to see if you have that movie yet, or if it's in the queue.

I set these to run on a schedule. The TV script runs every 10 minutes, while the movie script runs every few hours.

If anyone uses this, please let me know how it works for you, and if you have any recommendations. I just did this yesterday, so it's very much a work in progress, but it's worked great so far.
Last edited by popcornarsonist on December 22nd, 2008, 12:57 pm, edited 1 time in total.
rAf
Moderator
Moderator
Posts: 546
Joined: April 28th, 2008, 2:35 pm
Location: France
Contact:

Re: Autodownload script

Post by rAf »

Thanks for sharing, it's a great idea !
I'll test it as soon as i can.
zakharm
Release Testers
Release Testers
Posts: 56
Joined: September 29th, 2008, 1:08 pm

Re: Autodownload script

Post by zakharm »

As I've started to use the RSS feature of SABnzbd more and more I've found myself wanting more functionality. Your scripts provide a great method for doing this, nice work!

My method was to create a PHP script that outputs an RSS feed that I have SAB checking every 60 minutes, but I like your method a lot better.
Write album art post processing script
JayBird
Jr. Member
Jr. Member
Posts: 82
Joined: August 18th, 2008, 3:21 am

Re: Autodownload script

Post by JayBird »

This looks great, will test it out when i get a minute
Flambard
Newbie
Newbie
Posts: 23
Joined: November 4th, 2008, 12:21 pm

Re: Autodownload script

Post by Flambard »

This certainly looks like a good script, but would you mind explaining how to run it for those of us who are new here? I've done some browsing around, but can't seem to find how I'm supposed to make it work... I've changed all the entries I need to in the TV script, and have run the file using Python, but it seems to do nothing.

Any help would be appreciated  :)

Edit: for ease of testing, I have created a folder tvdir/House and confirmed there are episodes in the RSS link I put in the ini file...
Last edited by Flambard on November 4th, 2008, 12:31 pm, edited 1 time in total.
popcornarsonist
Newbie
Newbie
Posts: 13
Joined: January 28th, 2008, 6:53 pm

Re: Autodownload script

Post by popcornarsonist »

Well, that's strange. Are you getting any errors from the script? It will only give you commandline feedback if there's something added into the queue If you don't get anything back, I'd recommend putting in some additional logging statements, which I've added into the following parts of the script:

Code: Select all

print("Testing: " + report)
if (isWanted(series) == 1) and (isMissing(series, season, episode) == 1) and (isInQueue(report) == 0):
                        msgid=node.getElementsByTagName("report:id")[0].childNodes[0].data
                        download(msgid)

Code: Select all

def isWanted(series_title):
        series_path = tv_dir + "/" + series_title
        if os.path.exists(series_path):
                return 1
                print("Is wanted")
        else:
                print("Is not wanted")
                return 0

Code: Select all

def isMissing(series_title, season_number, episode_number):
        regex_episode = re.compile(series_title + " - " + season_number + "x" + episode_number)
        if os.path.exists(tv_dir + "/" + series_title + "/Season " + season_number):
                for tested_episode in os.listdir(tv_dir + "/" + series_title + "/Season " + season_number):
                        if re.match(regex_episode, tested_episode):
                                print("Is not missing")
                                return 0
        print("Is missing")
        return 1
That should give you a better idea of why the script is failing.
frankhuzzah
Newbie
Newbie
Posts: 6
Joined: November 8th, 2008, 8:10 pm

Re: Autodownload script

Post by frankhuzzah »

Thanks for making this, once I get it tweaked and running I think this is going to be exactly the type of solution I was looking for.  I do have a couple problems/questions though.

First, I normally have my sabnzbd setup to use the built in username/password fuction.  It doesn't appear your script is able to pass the report ids through that.  When I have the password enabled and run the script it shows the correct missing episodes, but it doesn't download anything.  When I disable the password protection, however, it works perfectly.  Am I missing a setting or will your script simply not pass the protection?

Secondly, I've been running the scripts manually, but you said you have yours set to run on a schedule, is that through Sabnzbd or some other software?  Obviously with something like this automating is key.

Thanks again for all the hard work!
zakharm
Release Testers
Release Testers
Posts: 56
Joined: September 29th, 2008, 1:08 pm

Re: Autodownload script

Post by zakharm »

frankhuzzah wrote: Secondly, I've been running the scripts manually, but you said you have yours set to run on a schedule, is that through Sabnzbd or some other software?  Obviously with something like this automating is key.
You can use cron to schedule the running of your scripts on Linux / Mac.  If you're on Windows, Windows Scheduler would do the trick.
Write album art post processing script
frankhuzzah
Newbie
Newbie
Posts: 6
Joined: November 8th, 2008, 8:10 pm

Re: Autodownload script

Post by frankhuzzah »

zakharm wrote:You can use cron to schedule the running of your scripts on Linux / Mac.  If you're on Windows, Windows Scheduler would do the trick.
Thanks, I was doing a bunch of research last night and found Cron and finally got it setup the way I wanted here just now.  Works great.
User avatar
interfacelift
Jr. Member
Jr. Member
Posts: 75
Joined: June 19th, 2008, 12:58 am
Location: Coruscant

Re: Autodownload script

Post by interfacelift »

I'm really impressed with the movies script. It's straightforward, yet very effective. I love how it uses the rating power of the masses to decide what to download.

I'd love to see one based on Rotten Tomatoes ratings instead of IMDB :-)
Flambard
Newbie
Newbie
Posts: 23
Joined: November 4th, 2008, 12:21 pm

Re: Autodownload script

Post by Flambard »

popcornarsonist wrote: Well, that's strange. Are you getting any errors from the script? It will only give you commandline feedback if there's something added into the queue If you don't get anything back, I'd recommend putting in some additional logging statements, which I've added into the following parts of the script:
Aha, thanks for the suggestion. I think I may know why it's failing now. I'm running this on a windows box, so the paths may not be resolving properly due to the "/" used as a folder seperator instead of the "" windows uses. Unfortunately when I changed these it broke the script with an error "EOL while scanning string literal" in this line:

Code: Select all

series_path = tv_dir + "" + series_title
As I know virtually nothing about Python, I have no idea how to resolve it...
Flambard
Newbie
Newbie
Posts: 23
Joined: November 4th, 2008, 12:21 pm

Re: Autodownload script

Post by Flambard »

I do however know how to use Google  ;)

I fixed my path issue with "\\" where necessary & the script now seems to be doing what it's supposed to (after fixing the other parts I needed to change to point to the correct IP address on my network...)

Thanks for your help!
popcornarsonist
Newbie
Newbie
Posts: 13
Joined: January 28th, 2008, 6:53 pm

Re: Autodownload script

Post by popcornarsonist »

First, I normally have my sabnzbd setup to use the built in username/password fuction.  It doesn't appear your script is able to pass the report ids through that.  When I have the password enabled and run the script it shows the correct missing episodes, but it doesn't download anything.  When I disable the password protection, however, it works perfectly.  Am I missing a setting or will your script simply not pass the protection?
Yeah, I don't have a username/password set up, but it's a simple change. You just need to ass another coupld of parameters to the download URL. So it should look something like this:

Code: Select all

http://host:port/sabnzbd/api?mode=addid&name="+report_id+"&cat="tv"&ma_username=USER&ma_password=PASSWORD
This stuff can be found in the manual: http://sabnzbd.wikidot.com/automation-support
frankhuzzah
Newbie
Newbie
Posts: 6
Joined: November 8th, 2008, 8:10 pm

Re: Autodownload script

Post by frankhuzzah »

popcornarsonist wrote:
Yeah, I don't have a username/password set up, but it's a simple change. You just need to ass another coupld of parameters to the download URL. So it should look something like this:

Code: Select all

http://host:port/sabnzbd/api?mode=addid&name="+report_id+"&cat="tv"&ma_username=USER&ma_password=PASSWORD
This stuff can be found in the manual: http://sabnzbd.wikidot.com/automation-support
Thanks a ton, I really love the TV show script.  It is exactly what I needed and works great.  I'll set the password portion back up when I get home from work.
Flambard
Newbie
Newbie
Posts: 23
Joined: November 4th, 2008, 12:21 pm

Re: Autodownload script

Post by Flambard »

Both the TV & Movies scripts are working great for me now, but I do have one small problem with them. If the any part of the title pulled from the Newzbin RSS feeds has a colon in it, the script translates it somehow to a semicolon when creating the queue item. This in itself isn't a problem, but if the same show/movie comes up again, the same item gets added back to the queue as the script doesn't "see" it as a duplicate.

Is someone here knowledgeable enough with Python to strip out any colons & replace with something like a hyphen which is allowed as a filename so this doesn't happen? I'd love to do it myself, but as I said above, my Python skills are next to non-existent... =)

Other than this little issue, great scripts!
Post Reply