[Linux, MacOSX, Windows] Media Sorting + XBMC Updater

Come up with a useful post-processing script? Share it here!
Post Reply
tret
Full Member
Full Member
Posts: 148
Joined: August 2nd, 2008, 2:07 pm

[Linux, MacOSX, Windows] Media Sorting + XBMC Updater

Post by tret »

Features:
- Use category specific settings to handle cleaning up and moving SABnzbd downloads
- Define up to 2 secondary destinations to be used when the primary destination is full
- Detect failed downloads and delete them or move them to a user defined destination
- Search for and remove junk files and empty directories (Useful for removing sample video files)
- Send video or music library update requests to one or more XBMC htpc's
- Hand off processing of TV Shows to Sick Beard

Setup:
1. Copy the htpc_sort.py, settings.ini and excludes files to your SABnzbd scripts folder
2. In the SABnzbd categories settings, set the desired categories to launch htpc_sort.py after post-processing
3. In the SABnzbd sorting settings, Enable TV Show sorting and set the "Sort String" to: %sn/Season %0s/%sn - S%0sE%0e.%ext
4. Edit the settings.ini file to configure, DO NOT modify the htpc_sort.py file to change settings


settings.ini explanation:
NOTE: The 'SABnzbd' section of the ini file is required (The section name IS case sensitive)
[SABnzbd]
address = 192.168.1.2:8081
login = jdoe
password = pass1234
apikey = xxxxxxxxxxxxxxxxxxxxxxxxxxx

address  (Required): set to your sabnzbd address and port, use the address above as an example
login    (Required): set to your sabnzbd login name
password (Required): set to your sabnzbd password
apikey  (Required): set to your sabnzbd apikey (I have not tested this script w/ an apikey disabled SABnzbd installation)


NOTE: The 'SickBeard' section of the ini file is optional, leave blank or remove this section if Sick Beard won't be used
[SickBeard]
scriptPath = /home/tret/.sickbeard/autoProcessTV/sabToSickBeard.py
category = TV

scriptPath (Required): path to find the sabToSickBeard.py script provided w/ Sick Beard
category (Required): all downloads within this category will be handed off to Sick Beard during processing


NOTE: The 'XBMC' section of the ini file is optional, add additional addresses as needed (The section name IS case sensitive)
[XBMC]
xbmc = 192.168.1.2:8080
xbmc2 = 192.168.1.3:8080
xbmc3 = 192.168.1.13:8080

xbmc  (Required): set to your xbmc web server address and port
xbmc* (Optional): additional xbmc web server addresses and ports


NOTE: At least 1 category section is required, add additional category sections as needed (IMPORTANT: The section name must match the SABnzbd category name)
[Movies]
destPath = E:\Movies
destPath2 = D:\Movies
destPath3 = F:\Movies
failPath = C:\Users\tret\Downloads\SABnzbd\Failed
minDownloadSize = 500MB
minFileSize = 200MB
libraryType = video

destPath        (Required): set to your primary library location, finished downloads will be moved here
destPath*      (Optional): additional library locations, downloads will be moved here if 'destPath' is full (destPath2, destPath3)
failPath        (Optional): set to your fail location, failed downloads will be moved here (Remove option to delete failed downloads)
minDownloadSize (Optional): set a minimum download size, downloads below this value will be deleted (Remove option to ignore download size)
minFileSize    (Optional): set a minimum file size, files below this size will be deleted as junk (Remove option to skip junk file removal)
libraryType    (Optional): set the xbmc library type to be updated for this category e.g: video, music (Remove option to disable xbmc library updates)


excludes file: Add additional file types here to exclude them from junk file removal e.g: .nzb, .sfv, .m3u


HTPC Sort v2.61
v2.61 Download
v2.61 Release notes (8/11/2010)

Built and tested with Python 2.6.4 (download and install if you don't have python already or if you have an older version and the script isn't working)
Python 2.6.4 for Mac OS X
Python 2.6.4 for Windows

tret
Last edited by tret on August 11th, 2010, 6:36 pm, edited 1 time in total.
tret
Full Member
Full Member
Posts: 148
Joined: August 2nd, 2008, 2:07 pm

Re: [Linux] Media Processing + XBMC Updater

Post by tret »

[Removed]
revelation_22
Newbie
Newbie
Posts: 21
Joined: October 19th, 2008, 12:21 pm

Re: [Linux] Media Processing + XBMC Updater

Post by revelation_22 »

Installed this new version and it is working great.  I have multiple instances of XBMC that I would like the library update command sent to. What would I need to edit to accomplish this with this new version?

Thanks for the great script,
revelation22
tret
Full Member
Full Member
Posts: 148
Joined: August 2nd, 2008, 2:07 pm

Re: [Linux] Media Processing + XBMC Updater

Post by tret »

revelation_22 wrote: Installed this new version and it is working great.  I have multiple instances of XBMC that I would like the library update command sent to. What would I need to edit to accomplish this with this new version?

Thanks for the great script,
revelation22
Hey rev,

Glad to hear that it's working out!

I think this functionality should be pretty easy to add, I have a couple of ideas. I'll post whatever I figure out.

Thanks,
tret
tret
Full Member
Full Member
Posts: 148
Joined: August 2nd, 2008, 2:07 pm

Re: [Linux] Media Processing + XBMC Updater

Post by tret »

revelation_22 wrote: Installed this new version and it is working great.  I have multiple instances of XBMC that I would like the library update command sent to. What would I need to edit to accomplish this with this new version?

Thanks for the great script,
revelation22
Rev,

Ok so here is how to add the ability to update multiple xbmc libraries.

Find these two lines, they are the last two lines in the media_process.py file

Code: Select all

        if str.lower(categoriesList[i+4]) == 'y':
          urllib.urlopen("http://" + settingsList[3] + "/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.updatelibrary(video)", proxies={})
And replace them with these three lines. Remember in python indents are important so be sure to maintin the proper indentation. This code change will be included with my next release.

Code: Select all

        if str.lower(categoriesList[i+4]) == 'y':
          for y in range(3, len(settingsList)):
            urllib.urlopen("http://" + settingsList[y] + "/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.updatelibrary(video)", proxies={})
Then all you need to do is add the additional xbmc ip addresses to settings.conf. Example:

Code: Select all

 ## Media Process settings
   
SABNZBD Download Path = "/WD500/downloads/sabnzbd"
Failed Downloads Destination Path = "/WD500/downloads/sabnzbd/FAILED"
XBMC IP address and port = "192.168.1.3:8080"
XBMC 2 IP address and port = "192.168.1.10:8080"
XBMC 3 IP address and port = "192.168.1.101:8080"
That should take care of it. Let me know how it goes!

tret
revelation_22
Newbie
Newbie
Posts: 21
Joined: October 19th, 2008, 12:21 pm

Re: [Linux] Media Processing + XBMC Updater

Post by revelation_22 »

tret wrote:
revelation_22 wrote: Installed this new version and it is working great.  I have multiple instances of XBMC that I would like the library update command sent to. What would I need to edit to accomplish this with this new version?

Thanks for the great script,
revelation22
Rev,

Ok so here is how to add the ability to update multiple xbmc libraries.

Find these two lines, they are the last two lines in the media_process.py file

Code: Select all

        if str.lower(categoriesList[i+4]) == 'y':
          urllib.urlopen("http://" + settingsList[3] + "/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.updatelibrary(video)", proxies={})
And replace them with these three lines. Remember in python indents are important so be sure to maintin the proper indentation. This code change will be included with my next release.

Code: Select all

        if str.lower(categoriesList[i+4]) == 'y':
          for y in range(3, len(settingsList)):
            urllib.urlopen("http://" + settingsList[y] + "/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.updatelibrary(video)", proxies={})
Then all you need to do is add the additional xbmc ip addresses to settings.conf. Example:

Code: Select all

 ## Media Process settings
   
SABNZBD Download Path = "/WD500/downloads/sabnzbd"
Failed Downloads Destination Path = "/WD500/downloads/sabnzbd/FAILED"
XBMC IP address and port = "192.168.1.3:8080"
XBMC 2 IP address and port = "192.168.1.10:8080"
XBMC 3 IP address and port = "192.168.1.101:8080"
That should take care of it. Let me know how it goes!

tret
That did the trick! Thank you. Have you considered scraping imdb for movies and creating a Movie.nfo and using the movie name for the folder name? I think I need to learn python  ;D
tret
Full Member
Full Member
Posts: 148
Joined: August 2nd, 2008, 2:07 pm

Re: [Linux] Media Processing + XBMC Updater

Post by tret »

revelation_22 wrote:
That did the trick! Thank you. Have you considered scraping imdb for movies and creating a Movie.nfo and using the movie name for the folder name? I think I need to learn python  ;D
Haha funny you should ask. I am working on that right now in fact. I am trying to decide how flexible I want to make it. For instance, if I have a download waiting and my script picks it up. The folder is named No Country for Old Men (2007) and that name and year format exactly matches the title and year on IMDB, so I get a positive match and everything is great. Now say I have Bill and Ted's excellent adventure with no year. The IMDB match for that movie is Bill & Ted's Excellent Adventure (1989) so my script wouldn't get an exact match.

IMDB will give you popular results for your search, so if I search for Bill and Ted's excellent adventure with no year the #1 link in the popular results is the link to the correct movie. But say the title is something more obscure, or even something that is titled way off, if I let the script just take the #1 popular result and run with it, we could have a link to the wrong movie entirely.

So..... what to do? Be strict and perhaps 30% of the movies won't get a Movie.nfo file or be more relaxed and chance getting some wrong url's?

What do you think?

Rob
Usenet
Jr. Member
Jr. Member
Posts: 87
Joined: February 12th, 2008, 6:04 pm

Re: [Linux] Media Processing + XBMC Updater

Post by Usenet »

look for .nfo files with imdb links?
tret
Full Member
Full Member
Posts: 148
Joined: August 2nd, 2008, 2:07 pm

Re: [Linux] Media Processing + XBMC Updater

Post by tret »

Usenet wrote: look for .nfo files with imdb links?
Yeah that is the first option. I am planning to have a 3 step process for this.

1. use any imdb url's found in any .nfo files that came with the movie
2. search imdb for exact matches
3. use some kind of matching percentage to use likely imdb search results.

I have 1 and 2 figured out and working, I just need to work on #3

tret
revelation_22
Newbie
Newbie
Posts: 21
Joined: October 19th, 2008, 12:21 pm

Re: [Linux] Media Processing + XBMC Updater

Post by revelation_22 »


1. use any imdb url's found in any .nfo files that came with the movie
2. search imdb for exact matches
3. use some kind of matching percentage to use likely imdb search results.

I have 1 and 2 figured out and working, I just need to work on #3

tret
tret, do you have a working version with these features added that you would post? I would like to give it a try.
tret
Full Member
Full Member
Posts: 148
Joined: August 2nd, 2008, 2:07 pm

Re: [Linux] Media Processing + XBMC Updater

Post by tret »

revelation_22 wrote:

1. use any imdb url's found in any .nfo files that came with the movie
2. search imdb for exact matches
3. use some kind of matching percentage to use likely imdb search results.

I have 1 and 2 figured out and working, I just need to work on #3

tret
tret, do you have a working version with these features added that you would post? I would like to give it a try.
Hi rev, I am getting close to having this ready, I also have a couple of small bug fixes in the next release. Should have something ready for use in a couple of days.

tret
tret
Full Member
Full Member
Posts: 148
Joined: August 2nd, 2008, 2:07 pm

Re: [Linux] Media Processing + XBMC Updater

Post by tret »

version 1.10 (Use the link in the first post)

changes:

- bugfix: error reporting when URL couldn't be reached, errors handled properly now with normal script output
- bugfix: excludes.conf file types being deleted, no longer case sensitive when checking excludes against files below min size threshold
- added: IMDB scraping, If enabled a Movie.nfo file will be created with a URL to the matching IMDB page (helps XBMC scrape IMDB)
- added: More than 1 XBMC box can be updated if enabled in the settings
- change: thetvdb.com and imdb.com scraping is now percentage based (50% or higher if title contains 2 words and 66% or higher for 3 or more words will result in a match)
Last edited by tret on March 9th, 2009, 9:09 pm, edited 1 time in total.
Ozymandias
Newbie
Newbie
Posts: 1
Joined: March 11th, 2009, 5:15 am

Re: [Linux, MacOSX, Windows] Media Processing + XBMC Updater

Post by Ozymandias »

Hey tret

Thanks for the good work  :)

I installed it last night on OSX 10.5 and it seems work well, no issues yet.

I have a feature request though

Would it be possible to include episode information about TV shows kind of like media companion, http://billyad2000.co.uk? It'd speed up scanning of new episodes and would save having to download thumbs etc.
tret
Full Member
Full Member
Posts: 148
Joined: August 2nd, 2008, 2:07 pm

Re: [Linux, MacOSX, Windows] Media Processing + XBMC Updater

Post by tret »

For those of you who are having imdb and thetvdb matching issues:

I am planning to rework some of the imdb and thetvdb scraping code. Currently if there are special characters in the titles (' " ( & etc.) the matching can get messed up. I am planning to have the script temporarily remove all non alpha and numeric characters from the titles before comparing them. I think this should help things out a bit, we'll see.

I should have an update in a few days.

Thanks
tret
Full Member
Full Member
Posts: 148
Joined: August 2nd, 2008, 2:07 pm

Re: [Linux, MacOSX, Windows] Media Processing + XBMC Updater

Post by tret »

Ozymandias wrote: Hey tret

Thanks for the good work  :)

I installed it last night on OSX 10.5 and it seems work well, no issues yet.

I have a feature request though

Would it be possible to include episode information about TV shows kind of like media companion, http://billyad2000.co.uk? It'd speed up scanning of new episodes and would save having to download thumbs etc.
Nice, thanks for testing it out. I'll look into episode info, not sure about what would need to be done just yet.

tret
Post Reply