Kodi Community Forum

Full Version: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
Version 1.30 is a minor update.

New in this version:
  • White and blacklists are now directory-aware. Just include a "/" at the end to specify that the rule applies to directories.
  • PLACE-HARDLINK is now a sort-by option:
    --sort-by=[MOVE|COPY|MOVE-AND-LEAVE-SYMLINK-BEHIND|PLACE-SYMLINK|PLACE-HARDLINK]
    Sort by moving or copying the file. If the file already exists because it was already copied it is silently skipped.
    The MOVE-AND-LEAVE-SYMLINK-BEHIND option may be handy if you want to continue to seed after sorting, this leaves a symlink in place of the newly moved file.
    PLACE-SYMLINK does not move the original file, but places a symlink in the sort-to directory (probably not what you want)
    PLACE-HARDLINK does not move the original file, but places a hardlink in the sort-to directory. This might be helpful if you use Linux and you want a sorted and unsorted version on the same partition.
    If not specified, MOVE


Donations welcome Smile

Get the new version from:
http://sourceforge.net/projects/sorttv/

red_five Wrote:I've made a small addition to sorttv.pl that might be of interest to other Linux users; I'm not sure if it'll work properly under Windows, but it's mere existence shouldn't cause any issues.

I store my sorted TV files on the same partition as my torrent download folder, so it's convenient for me to use hard links rather than symbolic links. I added the following conditional branch to 2 places in sorttv.pl:

Code:
elsif($sortby eq "PLACE-HARDLINK") {
        link($file,$newpath) or out("warn", "File $file cannot be hardlinked to $newpath. : $!");

In version 1.29, add it to lines 1461 and 1462 of function sub sort_file, and again to lines 1486 and 1487 of function sub move_a_season. Insert the above code immediately after the closing brace "}" on lines 1461 and 1486.

Once added and saved, you will be able to use PLACE-HARDLINK as one of the sort-by options. Like I said, I don't know if this will work properly in Windows, because I'm not sure if Windows supports true hard links like *nix does. However, it's mere presence in the script shouldn't cause any problems for Windows. Also, only use this option if your sorted directory is on the same partition as your source directory; hard links only work on the same partition.

Thanks! Applied to 1.30. Smile

In the future, please consider using the following command to generate a patch, which makes it easier for me to apply your changes:
Code:
diff -u old-file-or-dir new-file-or-dir > mysorttv.patch

Pablohoney Wrote:Thanks for your reply and also this awesome script! I am using the one you just upped on 7/10/11 "pyWHATauto-1.291" Maybe I am misunderstanding what treat-directories=RECURSIVELY_SORT_CONTENTS but it seems pretty straight forward that it will move (and leave a symlink behind, in my case) the files in the directory. Instead it takes a look at the directory and, i'm assuming, since it doesn't ending in *.mkv *.avi *.mp4 or *.ogm (the containers I specified in my whitelist) it skips them and spits out the NOT IN WHITELIST error.

For example if my:
directory-to-sort=/download/

and rtorrent downloads and moves to:
/download/Breaking.Bad.e04s01.720p.HDTV.DD5.1.x264/Breaking.Bad.e04s01.720p.HDTV.DD5.1.x264

it will scan /download/Breaking.Bad.e04s01.720p.HDTV.DD5.1.x264
and spit out the NOT IN WHITELIST error, never even scanning the file
/download/Breaking.Bad.e04s01.720p.HDTV.DD5.1.x264/Breaking.Bad.e04s01.720p.HDTV.DD5.1.x264

at least that is my case...

Fixed Smile

Enjoy.
spazlon Wrote:So Paul got back to me rather quickly. Turns out he had no idea it wasn't working.

Apparently his module is listed in Strawberry's CPAN, but will not install.

This was his output when trying to install it:

Code:
cpan> install WWW::TheMovieDB::Search
Database was generated on Fri, 22 Jul 2011 15:39:24 GMT
Warning: Cannot install WWW::TheMovieDB::Search, don't know what it is.
Try the command

    i /WWW::TheMovieDB::Search/

to find objects with matching identifiers.

He checked http://cpan.strawberryperl.com/modules/0...ils.txt.gz and found his module listed at line 87981:

Code:
WWW::TheMovieDB::Search            0.01  P/PJ/PJOBSON/WWW-TheMovieDB-Search.docupdate.tar.gz

After that he went into Strawberry's chat room and received no help. Paul then emailed Adam Kennedy who maintains Strawberry Perl.

We are currently waiting for a reply from Adam.

Does anybody know why the module won't install even though it is listed in the package?

Thanks.

Great!

Paul submitted his module to CPAN quickly after I initially contacted him regarding using it in SortTV.

Happy to hear that you guys are looking into those error messages from Strawberry Perl Smile

Once the module is available to Windows users (who make up roughly ~60% of SortTV users) then we can start to incorporate movie sorting.

I have also considered incorporating ID3 tag based MP3 sorting at some point.

Maybe eventually SortTV will need a name change Smile
cliffe Wrote:Great!

Paul submitted his module to CPAN quickly after I initially contacted him regarding using it in SortTV.

Happy to hear that you guys are looking into those error messages from Strawberry Perl Smile

Once the module is available to Windows users (who make up roughly ~60% of SortTV users) then we can start to incorporate movie sorting.

I have also considered incorporating ID3 tag based MP3 sorting at some point.

Maybe eventually SortTV will need a name change Smile

Cliffe,

Here is the reply from Adam Kennedy (maintainer of Strawberry):

Quote:Firstly, Strawberry doesn't maintain a CPAN repository as such, we
just maintain a reflector to an existing known-good default
repository. We set up the reflector so we can change that known-good
repository over time without clients having to reconfigure.

Second, it's not just that module, your entire author record is missing!

i /PJOBSON/

Thirdly, I don't believe we do anything differently to any other
distro, we ship the standard Perl with standard CPAN and standard
CPAN::SQLite. There shouldn't be anything strawberry specific in there
at all.

I would have a look to see if a) Is the module in the cpan SQLite file
and the client isn't seeing it b) Is the CPAN::SQLite parser rejecting
it during parsing for some reason.

But the author record missing looks suspicious.

Adam K

Now I am just waiting for a reply from Paul with his reaction to this. Maybe it's just as simple as adding his author info...
Paul just shot me an email:

Quote:Figured it out ..

As of yesterday, I had the gzip file named: WWW-TheMovieDB-Search.docupdate.tar.gz

Yesterday afternoon, I pushed another copy to PAUSE named: WWW-TheMovieDB-Search-0.01.tar.gz

Today, I reindexed my local CPAN and it appeared. Not sure why having it named oddly would stop Strawberry Perl from loading it.

--Paul

He said we just need to reload index then install WWW::TheMovieDB::Search.

Cliffe, is this what you needed to integrate it into you app?

- Ryan
spazlon Wrote:Paul just shot me an email:



He said we just need to reload index then install WWW::TheMovieDB::Search.

Cliffe, is this what you needed to integrate it into you app?

- Ryan

Great!

Could someone please confirm that this module works on Strawberry Perl now (Windows)?

Run this on a command line and let me know if it installs:
cpan WWW::TheMovieDB::Search
Just a quick update. I have started work on the movie sort feature. It might take a few weeks until a release, since I don't have much free time at the moment. If anyone has examples of movie filenames you want SortTV to be able to sort, then PM me. PM me filenames, but lets keep discussion on this thread. Cheers.
PM sent with about 50 movie names (original and post-rename).

Looking forward to this implementation!
Has anybody tried loading this on something less mainstream?

I tried loading it on a WDTV and a Asus RT-N16 running dd-wrt (both with Optware). I have tar installed but keep getting this error when I run "cpan File::Copy::Recursive File::Glob LWP::Simple TVDB::API Getopt::Long"

Checksum for /opt/.cpan/sources/authors/id/G/GA/GAAS/LWP-MediaTypes-6.01.tar.gz ok
Uncompressed /opt/.cpan/sources/authors/id/G/GA/GAAS/LWP-MediaTypes-6.01.tar.gz successfully
Using Tar:/opt/bin/tar xvf /opt/.cpan/sources/authors/id/G/GA/GAAS/LWP-MediaTypes-6.01.tar:
Couldn't untar /opt/.cpan/sources/authors/id/G/GA/GAAS/LWP-MediaTypes-6.01.tar

Has anybody been successful in getting this to run on smaller devices like a router?
Version 1.31

This version adds movie sorting.

Config options:
  • --movie-directory={directory}
    Where to sort movies into
    If not specified, movies are not moved
    Enabling this feature requires Internet access to look up movie names
  • --fetch-movie-images=[TRUE|FALSE]
    Download images for movies
    Downloaded images are copied into the destination directory.
    If not specified, TRUE
  • --rename-movie-format={formatstring}
    The format to use if renaming movies
    The format can be made up of:
    [MOVIE_TITLE]: "My Movie"
    [YEAR1]: "(2011)"
    [YEAR2]: "2011"
    If not specified the format is, "[MOVIE_TITLE] [YEAR2]/[MOVIE_TITLE] [YEAR1]"
  • --movie-lookup-language=[en|...]
    Set language for tmdb lookups

This release has been somewhat rushed, and I won't be able to sort out any issues for a week or so. However, please report your experiences. This is particularly important since (other than testing) I will rarely use this feature myself.


Remember to install the modules:
sudo cpan File::Copy::Recursive File::Glob LWP::Simple TVDB::API Getopt::Long Switch WWW::TheMovieDB::Search XML::Simple
(without the "sudo" on Windows)

Get the new version from:
http://sourceforge.net/projects/sorttv/files/
Until I hear from some of you, I won't be setting this as the default SortTV download, so just choose to download this version from the list of available files.


spazlon Wrote:Paul just shot me an email:

He said we just need to reload index then install WWW::TheMovieDB::Search.

Cliffe, is this what you needed to integrate it into you app?

- Ryan

Thanks again Smile
Awesome! I can't wait to try it out this weekend.

Thanks for the hard work.
I updated to 1.31 now getting the following error:

Code:
SortTV
~~~~~~
Sorting:
        From /mnt/DATA/Torrents/Complete/TV Show/
        TV episodes into /media/FREECOM/TV Shows/
18:59:13, 22-7-2011
Use of uninitialized value in division (/) at ./sorttv/sorttv.pl line 1033.

Any advice?
Latest update is pretty sweet, I've been looking for a movie sorting option under linux for a while now. One thing i noticed, the script seems to simply remove "-" without putting a space in it's place like it does with periods. This causes misspellings in the movie names so the movie title can't be found in MovieDB.
Sorry if this has been answered before, but what's the best way to go about updating SortTV? Can I simply replace sorttv.pl with the one in the zip and leave everything else as is?

I'd prefer to not have to redo my sorttv.conf if it's not necessary.
Capt.Insano Wrote:I updated to 1.31 now getting the following error:

Code:
SortTV
~~~~~~
Sorting:
        From /mnt/DATA/Torrents/Complete/TV Show/
        TV episodes into /media/FREECOM/TV Shows/
18:59:13, 22-7-2011
Use of uninitialized value in division (/) at ./sorttv/sorttv.pl line 1033.

Any advice?

FIXED!!

Must have been an updating config issue or a permissions issue, completely removed sortTV, started again and now working again!!

Sorry about that Cliffe!!
Now I can update sorttv without having to add the PLACE-HARDLINK option manually! Thanks!

I will be loving the movie sort option, too. I don't download movies a whole lot, but this sorting option will be most useful.

I'll have this in place as soon as my CPAN updates are complete. Nice work as usual, cliffe!
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49