Kodi Community Forum
SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Supplementary Tools for Kodi (https://forum.kodi.tv/forumdisplay.php?fid=116)
+--- Thread: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) (/showthread.php?tid=75949)

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


New version available - cliffe - 2011-02-28

v1.22

New features:
  • --filesize-range:rangepattern
    Only copy files that fall within these filesize ranges.
    Examples for the pattern include 345MB-355MB or 1.05GB-1.15GB
  • --sort-only-older-than-days:number
    Sort only files or directories that are older than this number of days.
    If not specified or zero, sorts everything.

Thanks to gardz and Patrick Cole for the code contributions.

You can get the new version here:
https://sourceforge.net/projects/sorttv/

Enjoy.

Gardz, I made some changes, please compare what I have released to the version you posted. Cheers Smile


- Justcop - 2011-02-28

Would you consider adding a lock function to the script so that if you try to run it whilst it is running then it will just exit.

eg http://linux.byexamples.com/archives/494/how-can-i-avoid-running-a-python-script-multiple-times-implement-file-locking/

obviously you need to take into account deleting the lock file if the process is stopped in the middle.

With a lock option implemented the script could be set to run every few minutes and get things into the XBMC library as quickly as possible.


- newphreak - 2011-02-28

cliffe:
Spartacus.Gods.of.the.Arena.Part06.720p.HDTV.x264-IMMERSE
Spartacus.Gods.of.the.Arena.Pt.I.720p.HDTV.X264-DIMENSION
Spartacus.Gods.of.the.Arena.Pt.II.720p.HDTV.X264-CTU


New version available - cliffe - 2011-03-01

v1.23

Corrects the default setting for age of files to sort.

Get the new version here:
https://sourceforge.net/projects/sorttv/


- cliffe - 2011-03-01

Justcop Wrote:Would you consider adding a lock function to the script so that if you try to run it whilst it is running then it will just exit.

eg http://linux.byexamples.com/archives/494/how-can-i-avoid-running-a-python-script-multiple-times-implement-file-locking/

obviously you need to take into account deleting the lock file if the process is stopped in the middle.

With a lock option implemented the script could be set to run every few minutes and get things into the XBMC library as quickly as possible.

Yeah, that is possible. I would rather add a poll feature though. That could do a sort every X minutes. In that case the script could be started in poll mode on startup, running as a daemon, rather than as a scheduled process.

Edit: No reason the script can't do both locking and polling.

I went ahead and added locking, it does it by locking the actual script file itself. This ensures only one instance of the script runs at a time. This feature is not yet tested on Windows.
v1.24

Get the new version here:
https://sourceforge.net/projects/sorttv/


- chortya - 2011-03-01

I'm actually running the script every hour with cron after ftp mirroring using lftp. Is there any better way to run this task as daemon?

And how do I upgrade the config without renewed manual updates? Are the new options appended to the old config?


- Justcop - 2011-03-03

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

Could there be some more fuzzy logic when the pattern seen is not matched.
If not matched it should try a few things eg just first word, ignore words such as season etc

Code:
Archive:  /mnt/Storage/Furk/Completed/Californication_488770.zip
extracting: /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 01.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 02.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 03.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 04.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 05.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 06.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 07.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 08.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 09.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 10.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 11.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 12.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 2/Californication - Season 2 - 01.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 2/Californication - Season 2 - 02.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 2/Californication - Season 2 - 03.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 2/Californication - Season 2 - 04.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 2/Californication - Season 2 - 05.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 2/Californication - Season 2 - 06.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 2/Californication - Season 2 - 07.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 2/Californication - Season 2 - 08.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 2/Californication - Season 2 - 09.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 2/Californication - Season 2 - 10.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 2/Californication - Season 2 - 11.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 2/Californication - Season 2 - 12.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 3/Californication - Season 3 - 01.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 3/Californication - Season 3 - 02.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 3/Californication - Season 3 - 03.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 3/Californication - Season 3 - 04.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 3/Californication - Season 3 - 05.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 3/Californication - Season 3 - 06.avi  
extracting: /mnt/Storage/Furk/Completed/Californication - Season 3/Californication - Season 3 - 07.avi  
RAR: extracting /mnt/Storage/Furk/Completed/Californication_488770.zip into /mnt/Storage/Furk/Completed/
Warning: TBDB::API: No series id found for: Californication   Season
INFO: making show directory: /mnt/Storage/TV/Californication   Season
INFO: making season directory: /mnt/Storage/TV/Californication   Season/Season 1
WARN: Could not get episode title for Californication   Season Season 1 Episode 1.
MOVE: sorting /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 01.avi to /mnt/Storage/TV/Californication   Season/Season 1/Californication   Season - 1x01.avi
WARN: Could not get episode title for Californication   Season Season 1 Episode 2.
MOVE: sorting /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 02.avi to /mnt/Storage/TV/Californication   Season/Season 1/Californication   Season - 1x02.avi
WARN: Could not get episode title for Californication   Season Season 1 Episode 3.
MOVE: sorting /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 03.avi to /mnt/Storage/TV/Californication   Season/Season 1/Californication   Season - 1x03.avi
WARN: Could not get episode title for Californication   Season Season 1 Episode 4.
MOVE: sorting /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 04.avi to /mnt/Storage/TV/Californication   Season/Season 1/Californication   Season - 1x04.avi
WARN: Could not get episode title for Californication   Season Season 1 Episode 5.
MOVE: sorting /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 05.avi to /mnt/Storage/TV/Californication   Season/Season 1/Californication   Season - 1x05.avi
WARN: Could not get episode title for Californication   Season Season 1 Episode 6.
MOVE: sorting /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 06.avi to /mnt/Storage/TV/Californication   Season/Season 1/Californication   Season - 1x06.avi
WARN: Could not get episode title for Californication   Season Season 1 Episode 7.
MOVE: sorting /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 07.avi to /mnt/Storage/TV/Californication   Season/Season 1/Californication   Season - 1x07.avi
WARN: Could not get episode title for Californication   Season Season 1 Episode 8.
MOVE: sorting /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 08.avi to /mnt/Storage/TV/Californication   Season/Season 1/Californication   Season - 1x08.avi
WARN: Could not get episode title for Californication   Season Season 1 Episode 9.
MOVE: sorting /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 09.avi to /mnt/Storage/TV/Californication   Season/Season 1/Californication   Season - 1x09.avi
WARN: Could not get episode title for Californication   Season Season 1 Episode 10.
MOVE: sorting /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 10.avi to /mnt/Storage/TV/Californication   Season/Season 1/Californication   Season - 1x10.avi
WARN: Could not get episode title for Californication   Season Season 1 Episode 11.
MOVE: sorting /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 11.avi to /mnt/Storage/TV/Californication   Season/Season 1/Californication   Season - 1x11.avi
WARN: Could not get episode title for Californication   Season Season 1 Episode 12.
MOVE: sorting /mnt/Storage/Furk/Completed/Californication - Season 1/Californication  - Season 1 - 12.avi to /mnt/Storage/TV/Californication   Season/Season 1/Californication   Season - 1x12.avi
Warning: TBDB::API: No series id found for: Californication  Season
INFO: making season directory: /mnt/Storage/TV/Californication   Season/Season 2
WARN: Could not get episode title for Californication  Season Season 2 Episode 1.
MOVE: sorting /mnt/Storage/Furk/Completed/Californication - Season 2/Californication - Season 2 - 01.avi to /mnt/Storage/TV/Californication   Season/Season 2/Californication  Season - 2x01.avi
WARN: Could not get episode title for Californication  Season Season 2 Episode 2.
MOVE: sorting /mnt/Storage/Furk/Completed/Californication - Season 2/Californication - Season 2 - 02.avi to /mnt/Storage/TV/Californication   Season/Season 2/Californication  Season - 2x02.avi
WARN: Could not get episode title for Californication  Season Season 2 Episode 3.
MOVE: sorting /mnt/Storage/Furk/Completed/Californication - Season 2/Californication - Season 2 - 03.avi to



- Justcop - 2011-03-04

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.


- Justcop - 2011-03-04

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.


- Justcop - 2011-03-04

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?


- foe83 - 2011-03-08

First of all, let me say, great script! Thanks for all the work!
Second, I have been having some trouble getting xbmc sorting to work... the script just gives an error and suggest to disable the feature if it is not used. The script runs on the same machine as xbmc so I have localhost:8080 and the enable http control is selected, any thoughts? It would be probably useful to have some more info when this error happens, perhaps something like "host/port incorrect" or "connection established but timeout occurred" (not sure how the connection is made so I'm just guessing here!). Thanks again!


- vikjon0 - 2011-03-08

Quote:Second, I have been having some trouble getting xbmc sorting to work... the script just gives an error and suggest to disable the feature if it is not used. The script runs on the same machine as xbmc so I have localhost:8080 and the enable http control is selected, any thoughts

Same for me. I assumed it was not working with the new web server. But perhaps I am wrong?


- Justcop - 2011-03-08

I haven't really tested it properly yet bu I don't think that feature is working for me either. I also have the script running on the same PC as my XBMC


- cliffe - 2011-03-09

vikjon0 Wrote:Same for me. I assumed it was not working with the new web server. But perhaps I am wrong?

Thanks vikjon0,

I hadn't realised xbmc had moved to a new control interface. (I have only just updated xbmc recently.) I'll try to update the script and respond to the other posts on the weekend.

Thanks again for the feedback everyone Smile


- carmenm - 2011-03-09

Hi cliffe,
I have been testing your script and i must say that it works amazingly well.
I think i am gonna try and add new features to it like:
- confirmation for moving files
- creating an "undo" script (asking for each file if you want to revert operation)
- movie integration ( i ll have to look at themoviedb package).

So i think you should put your project on launchpad or github so that we can work together more easily

Great work!