SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac)

  Thread Rating:
  • 6 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Capt.Insano Offline
Member
Posts: 78
Joined: Mar 2010
Reputation: 0
Location: Dublin, Ireland
Post: #286
First of All, excuse me for thinking out loud here;
I am a user of this Script since the beginning and I have some thoughts

Would it be possible to package this script as an xbmc add-on?

I think it would have many benefits: Easier distribution of updates + Large increase in users (more donations + developments!!), by making it available in the official xbmc repo.

Here were my thoughts:

People have been asking for a GUI for settings, well an XBMC GUI would be cross-compatible, would allow easy set up of SortTV and would allow easy access to Scheduling of Script + Instant execution of the script through XBMC itself.

Example: Trak.tv Addon Setting: (Start On Boot)
[Image: screenshot1.jpg]

Example: XBMC Auto-Updater: (Scheduled Execution)
[Image: screenshot2.jpg]

Example: Cinema Experience Script: (Easy Script Set-Up)
[Image: screenshot3.jpg]

I know that the script is written in perl and that XBMC addons are python, but there are two options that could make it work:

1. Calling the Perl Script from Python
some articles are around explaining methods for this (Google)

2. Changing Script language
a massive rewrite I know but it would leave possibly more options for developing the script to really tie in to XBMC.

Anyway I think it would be a great progression for an already great script.

Regards,
The Capt.
find quote
cliffe Offline
Senior Member
Posts: 185
Joined: Jun 2010
Reputation: 8
Post: #287
Capt.Insano Wrote:First of All, excuse me for thinking out loud here;
I am a user of this Script since the beginning and I have some thoughts

Would it be possible to package this script as an xbmc add-on?

I think it would have many benefits: Easier distribution of updates + Large increase in users (more donations + developments!!), by making it available in the official xbmc repo.

Here were my thoughts:

People have been asking for a GUI for settings, well an XBMC GUI would be cross-compatible, would allow easy set up of SortTV and would allow easy access to Scheduling of Script + Instant execution of the script through XBMC itself.

Example: Trak.tv Addon Setting: (Start On Boot)
[Image: screenshot1.jpg]

Example: XBMC Auto-Updater: (Scheduled Execution)
[Image: screenshot2.jpg]

Example: Cinema Experience Script: (Easy Script Set-Up)
[Image: screenshot3.jpg]

I know that the script is written in perl and that XBMC addons are python, but there are two options that could make it work:

1. Calling the Perl Script from Python
some articles are around explaining methods for this (Google)

2. Changing Script language
a massive rewrite I know but it would leave possibly more options for developing the script to really tie in to XBMC.

Anyway I think it would be a great progression for an already great script.

Regards,
The Capt.

Development on an xbmc front-end has started, developed thus far by foe83. The Python front-end calls the Perl script (1). Once the core features are working, the two scripts will be bundled together in SortTV releases. Perhaps some Python developers would like to get involved?
find quote
carmenm Offline
Senior Member
Posts: 226
Joined: Jul 2008
Reputation: 0
Post: #288
What a great idea to do an XBMC plugin!
Cant wait to see that.
But if i may add my stone. The XBMC plugin should be able to connect to an already running SortTV addon.
For example for me the computer running sortTV(file/download server) is not the same as the one running XBMC. And i dont want sorttv to run my XBMC machine as it would use CPU and mostly because moving files would be so much longer (over network)

That s only my point of view anyway Wink
find quote
cliffe Offline
Senior Member
Posts: 185
Joined: Jun 2010
Reputation: 8
Post: #289
carmenm Wrote:What a great idea to do an XBMC plugin!
Cant wait to see that.
But if i may add my stone. The XBMC plugin should be able to connect to an already running SortTV addon.
For example for me the computer running sortTV(file/download server) is not the same as the one running XBMC. And i dont want sorttv to run my XBMC machine as it would use CPU and mostly because moving files would be so much longer (over network)

That s only my point of view anyway Wink

Thanks to foe83 for taking the initiative to start working on the front-end.

I imagine the first version will be straightforward: it will act as a place to start the script using a graphical interface, and configuration will still be manual editing of the config, although hopefully via a text-edit box on the front-end.

Later versions will hopefully have nicer configuration via widgets (dropdown boxes etc). At that stage it might make sense to configure files for SortTV stored remotely, as you suggest, but I don't think that will be a high priority.

If anyone has any experience with Python at all, please speak up and contribute some lines of code Smile I expect foe83 will post the code that is in development soon.
(This post was last modified: 2011-03-14 10:43 by cliffe.)
find quote
foe83 Offline
Junior Member
Posts: 8
Joined: Mar 2011
Reputation: 0
Post: #290
Hi All,
I am indeed working on plugin for xbmc! Unfortunately, being new to python, the progress is quite slow.
That said, the plugin has already almost all the basic features implemented (run the script locally, importing old script and configure script using virtual keyboard) but some bugs prevent them from functioning correctly.
I am looking for people (preferably python developers, but also people whom might have dev experience and want to have a look at python) willing to help with the code, test, debug etc. If you are one, please pm me and I'll send you the code!
find quote
Gfei Offline
Junior Member
Posts: 3
Joined: Mar 2011
Reputation: 0
Post: #291
Everything is working now, I think one of my video files was causing a problem.

Just a thought: is there any way for SortTV to search the download location recursively at this time?
find quote
carmenm Offline
Senior Member
Posts: 226
Joined: Jul 2008
Reputation: 0
Post: #292
@foe83. I can help you. and would love to test the XBMC plugin Wink. Can you share the code?
find quote
newphreak Offline
Donor
Posts: 181
Joined: Oct 2010
Reputation: 0
Location: sofa @ Norway
Post: #293
Hmm, at the moment non-episodes are moved, this does not work well for me, as i use place-symlink. Would it be possible to throw symlinks to the non-episodes specified dir instead?

And, this line bugs me, even tho it doesn't seem to affect the script:
could not find ParserDetails.ini in /usr/local/share/perl/5.10.1/XML/SAX

How could i fix it? Smile

Samsung ES7005 55" led tv - Denon AVR-3313 - NAD C275BEE - B&W DM683 - B&W HTM61 - B&W 686
Asus EB1501P ION2 - OCZ Vertex 2 64gb ssd - Built in IR Receiver
And a Logitech Harmony Touch to control it all. http://www.OpenELEC.tv
find quote
cliffe Offline
Senior Member
Posts: 185
Joined: Jun 2010
Reputation: 8
Smile  New version available
Post: #294
Announcing SortTV version 1.25!

This is a pretty big update.
  • Compressed files are now extracted to a separate clearly marked directory.
  • Lots of improvements to the pattern matching. Including some bug fixes.
  • --music-directory=dir
    [INDENT]Where to sort music into
    If not specified, music is not moved[/INDENT]
  • Log file now has a default location (in preparation for an undo script), although the location can still be configured.
  • Option processing is now handled differently (thanks to code from farfromrefug). This means that command arguments are more flexible.
  • The arguments and config file now use "=" rather than ":" for assignments, although the old format still works.
  • Some of the option names have changed. For example: --tv-directory and --misc-directory, although the old names still work for now: --directory-to-sort-into and --non-episode-dir.
  • Files moved into the misc-directory sort as configured (for example, via move, copy or symlink), rather than just via move.
  • JSON-RPC for library updates for newer versions of XBMC. This is via the argument:
    --xbmc-remote-control=host
    [INDENT]host for the new xbmc communication, to automatically update library when new episodes arrive
    You probably want to set this to "localhost"[/INDENT]
    The old web interface is still available via:
    --xbmc-old-web-server=host:port
    [INDENT]host:port for the xbmc webserver on older versions of xbmc, to automatically update library when new episodes arrive
    Remember to enable the webserver within xbmc, and "set the content" of your TV directory in xbmc.
    If not specified, xbmc is not updated[/INDENT]
    The new interface does not yet support notifications, so that feature does not yet work with newer versions of xbmc.
  • --polling-time:{X}
    [INDENT]Tell the script to check for new files to sort every X seconds, minutes, hours, or days
    You could set the script to start on system startup with polling, rather than using scheduling to start the script.
    Valid values include "2secs", "2days", "1min", "3hrs", "30s" etc.
    If not specified, polling is disabled and the script will only sort the directory once.[/INDENT]
  • --check-for-updates=[TRUE|FALSE]
    [INDENT]Check for newer versions of SortTV
    If not specified, TRUE[/INDENT]

I recommend everyone updates to the new version.

You can download the new version from:
https://sourceforge.net/projects/sorttv/

A lot of time has gone into developing SortTV. Remember this is free open source software. I welcome and really appreciate donations.

Please consider a $5 paypal donation. Click for more information:
http://sourceforge.net/donate/index.php?group_id=330009

Thanks again to farfromrefug for the GetOpt code.

--

Justcop Wrote:My first go at using the script for a show called californication,
Unzipped folders were called Californication - Season 1 etc
For some reason this tried to match the show "Californication season" which obviously doesn't exist

This is fixed in the current version.

Justcop Wrote:1. This file did not match

How.I.Met.Your.Mother.S06E01.720p.HDTV.X264-DIMENSION.avi

Should "." other than the final one be ignored?

2. What happens to archive files after they have been unzipped, I would like them to be deleted as long as it has been successful.

Great script though, thank you for all the hard work and hopefully my feedback can help improve it.

This is also fixed.

Justcop Wrote:When a file is unzipped can it be added to a folder?

For example I just downloaded a couple of albums which were not recognised by the TV episode finder obviously so were moved to the place for other downloads.

Because they weren't in their own folders the 2 albums just got merged together as loose MP3s in the destination folder.

SortTV now includes a music directory, so that music is moved there. Also compressed archives are extracted to separate directories now.

Justcop Wrote:an MP3 named

11. 5-15.mp3

was left in the completed folder and not moved to where non sorted downloads go.

Shouldn't everything that is not recognised be moved there?

Music can now be sorted to a specific directory.

newphreak Wrote:Hmm, at the moment non-episodes are moved, this does not work well for me, as i use place-symlink. Would it be possible to throw symlinks to the non-episodes specified dir instead?

And, this line bugs me, even tho it doesn't seem to affect the script:
could not find ParserDetails.ini in /usr/local/share/perl/5.10.1/XML/SAX

How could i fix it? :)

Miscellaneous files are now sorted as configured (copy, symlink etc), rather than just moved.

--

Enjoy! :)
find quote
gardz Offline
Junior Member
Posts: 6
Joined: Feb 2011
Reputation: 0
Post: #295
First up, congrats on the new release!! Looking forward to testing some of the new features.

I found a bit of a bug in the new getopts portion which assumes floating point numbers are being passed in for the filesize-range values, when it should be a string since the format is 150MB-350MB, etc. As such the file size checks don't occur.

For reference to anybody who hits this issue in 1.25, if you enable the filesize-range checks you will hit an error such as this:

Code:
$ ./sorttv.pl
SortTV
~~~~~~
Value "170MB-400MB" invalid for option filesize-range (real number expected)
Value "1.05GB-1.15GB" invalid for option filesize-range (real number expected)
Value "697MB-700MB" invalid for option filesize-range (real number expected)


I've put a fix in my local copy as below. I'm not sure if this is the correct "getopt" way to do it, but it seems to work well:

Code:
$ diff -u default-files/sorttv.pl sorttv.pl
--- default-files/sorttv.pl     2011-03-21 04:23:03.000000000 +1100
+++ sorttv.pl   2011-03-21 14:43:07.120152341 +1100
@@ -149,11 +149,15 @@
        "match-files-based-on-tvdb-lookups|tlookup=s" => \$lookupseasonep,
        "season-title|st=s" => \$seasontitle,
        "verbose|v" => \$verbose,
-       "filesize-range|fsrange=f{2}" =>
+       "filesize-range|fsrange=s" =>
                sub {
                        # Extract the min & max values, can mix and match postfixes
-                       my $minfilesize = $_[1];
-                       my $maxfilesize = $_[2];
+                       if ($_[1] !~ /(.*)-(.*)/) {
+                               out ("warn", "WARN: invalid filesize range format. Must be 125MB-350MB, etc. Received: $_[1]");
+                       }
+
+                       my $minfilesize = $1;
+                       my $maxfilesize = $2;
                        $minfilesize =~ s/MB//;
                        $maxfilesize =~ s/MB//;
                        # Fix filesizes passed in to all MB
find quote
cliffe Offline
Senior Member
Posts: 185
Joined: Jun 2010
Reputation: 8
Post: #296
gardz Wrote:First up, congrats on the new release!! Looking forward to testing some of the new features.

I found a bit of a bug in the new getopts portion which assumes floating point numbers are being passed in for the filesize-range values, when it should be a string since the format is 150MB-350MB, etc. As such the file size checks don't occur.

For reference to anybody who hits this issue in 1.25, if you enable the filesize-range checks you will hit an error such as this:

Thanks for noticing, reporting and fixing! Smile

Version 1.26 fixes this issue.
https://sourceforge.net/projects/sorttv/
find quote
foe83 Offline
Junior Member
Posts: 8
Joined: Mar 2011
Reputation: 0
Post: #297
Hi everyone!

We have an early preview version of the xbmc script up on github, and I need some people to test it and/or help with the development!

NOTE: this is a very early dev version, it will most probably hang your xbmc machine during run and it may delete your sorttv.conf file. Please use only if you know what you are doing and have backed up everything! I highly suggest to read the README-XBMC-Script file first. That said, I have tested on my machine and beside freezing my machine while trying to run the script, it has not caused any demage, and seems to be able to import/edit the configuration correctly.

Get it here: https://github.com/foe83/sorttv/tree/xbmc_frontend

Click on the big "download" button and save it as a .zip file. Then use the addon installer on xbmc to find the file and install it. If installation fails, try to extract the content and chuck it in a folder named "script.sorttv" in your addons forder.

Enjoy!
find quote
newphreak Offline
Donor
Posts: 181
Joined: Oct 2010
Reputation: 0
Location: sofa @ Norway
Post: #298
cliffe Wrote:Glad you got it working. I notice that you were trying to install modules that SortTV doesn’t use any more (capitalize). Check the README file for an up-to-date list.

ahem.
From the newest readme from .26:
Quote:sudo cpan File::Copy::Recursive File::Glob LWP::Simple TVDB::API Text::Capitalize

Samsung ES7005 55" led tv - Denon AVR-3313 - NAD C275BEE - B&W DM683 - B&W HTM61 - B&W 686
Asus EB1501P ION2 - OCZ Vertex 2 64gb ssd - Built in IR Receiver
And a Logitech Harmony Touch to control it all. http://www.OpenELEC.tv
find quote
compcentral Offline
Fan
Posts: 626
Joined: Apr 2010
Reputation: 2
Post: #299
Forgive my ignorance, but doesn't SickBeard already serve the same purpose as this app? I haven't had a chance to read all 30 pages yet, but I'm just curious how this compares to SickBeard.
find quote
cliffe Offline
Senior Member
Posts: 185
Joined: Jun 2010
Reputation: 8
Post: #300
compcentral Wrote:Forgive my ignorance, but doesn't SickBeard already serve the same purpose as this app? I haven't had a chance to read all 30 pages yet, but I'm just curious how this compares to SickBeard.

There is some overlap in features. SortTV has more options for sorting, and I suspect detects more naming schemes (more episode naming formats, music etc).

SortTV doesn't actually download anything, but can be used with any of the plethora of applications that does that. For example, it can be used with Vuze's built in subscriptions, or with torrent episode downloader (TED), or any of the downloaders and schedulers that others have mentioned in this thread. (You could even combine SortTV with Sick Beard, although that might be overkill.)

Once SortTV is setup you can just have any file transfer programs place new files in a directory SortTV sorts, and it will all happen automatically, the files will be moved/copied/symlinked and renamed into a very organised directory structure, images will be downloaded, and xbmc will be notified of the new files.

Development of SortTV has progressed by adding the features requested by its users. There is a lot of control available through the options to specify exactly how SortTV behaves. (Although, hopefully the default behaviour is perfect for most users.) Development of an xbmc front-end has started, which will make configuration easier.

Anyway, if you want lots of control over what happens to your files try out SortTV.
find quote
Post Reply