Script for sorting movies and tv-shows

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Post Reply
enumo
Posts: 21
Joined: 15 Jan 2013, 16:19

Script for sorting movies and tv-shows

Post by enumo » 15 Jan 2013, 16:27

Hi,

Great work on Filebot! It Rocks!!

I'm trying to get a script working to sort all my torrent downloads into either movies or tvshows.
But reading trough some topics here i'm uncertain how to get this done.

I want the following:

My directory structure is as follows:

c:\Media\Downloads\Compleet (complete downloaded movies/tvshows directory)

c:\Media\Films\ (my movie directory in wich a movie has a seperate folder e.g: c:\Media\Films\Movie1\Movie1.avi and so on
c:\Media\Series\ (my tv show directory in wich a tvshow has a seperate folder e.g: C:\Media\Series\TV-show1\S1\S1E1.avi and so on

I need a script that can sort the files into the different directory's.

Can this be done?

I want to use utorrent to start the script, what would be the command i have to put in Utorrent after finished downloading?

[edit]
I'm using Windows 7 ultimate x64/
XBMC 11.0 (eden)
Java Developer 7
Filebot 3.2
[/edit]

Thnx for the help!

Gr. Enumo

Vinnie05
Posts: 15
Joined: 14 Jan 2013, 09:30

Re: Script for sorting movies and tv-shows

Post by Vinnie05 » 15 Jan 2013, 22:25

Hi, Im new to FileBot as well, but i'll see if i can point you in the right direction..

You should be able to use the default settings for the 'Fully automated Media Center' from here
http://filebot.sourceforge.net/forums/v ... ?f=4&t=215

you would put the following in Utorrent as described in the post above:

Code: Select all

filebot -script fn:utorrent-postprocess --output "C:/media" --action copy --conflict override -non-strict --def subtitles=y artwork=y "ut_dir=%D" "ut_file=%F" "ut_kind=%K" "ut_title=%N" "ut_label=%L" "ut_state=%S"
This will copy and sort into the folders: C:\media\Movies and C:\media\TV Shows

pretty much everything you need is in the post above..

enumo
Posts: 21
Joined: 15 Jan 2013, 16:19

Re: Script for sorting movies and tv-shows

Post by enumo » 15 Jan 2013, 22:38

Thnx for the help, I get that part, but i want to be able to change the output directory's of /movies to /films and /tv shows to /series. thats all i want.
Also no subtitle nor artwork need to be downloaded as xbmc wil do this on its own.
If I'm getting things correctly than it should say this:

Code: Select all

filebot -script fn:utorrent-postprocess --output "C:/media" --action copy --conflict override -non-strict --def subtitles=n artwork=n "ut_dir=%D" "ut_file=%F" "ut_kind=%K" "ut_title=%N" "ut_label=%L" "ut_state=%S" --def "seriesFormat=c:/media/series/{n}/{fn}" "movieFormat=c:/media/films/{n} {y}/{fn}"
Or do i need to make 2 seperate codes? Im really a noob on this, i was able to build batch files in ms-dos but when variable where introduced i lost it.

In my logical opinion the script should be something like:

find files in c:/media/downloads/completed and sort them in to c:/media/films and c:/media/series
no artwork or subtitles just sorting them from my download directory...
XBMC doesn't care if they are in a subdirectory or not (the movie/serie files) He will sort this out.

enumo
Posts: 21
Joined: 15 Jan 2013, 16:19

Re: Script for sorting movies and tv-shows

Post by enumo » 15 Jan 2013, 22:51

My Semi- Automated Download to XBMC setup is as follows(or i hope it can be)
Got Win7x64
Configured to run without win7 gui, made utorrent a win-services.
Configured utorrent to scan a directory for .torrent files and download them and place complete downloads into c:\media\downloads\compleet.
Now Filebot comes in, looks into c:\media\downloads\compleet and sorts out the movies and tv shows and puts them into c:\media\films (for the movies) and c:\media\series (for the tv-shows)
Then i have automated XBMC to scan for new files in these folders (films and series) and download art/subtitles when needed.
Thats is..

So, how do i configure this?

thnx for the help
Last edited by enumo on 15 Jan 2013, 22:58, edited 1 time in total.

Vinnie05
Posts: 15
Joined: 14 Jan 2013, 09:30

Re: Script for sorting movies and tv-shows

Post by Vinnie05 » 15 Jan 2013, 22:55

that code looks correct, for testing your script you may wish to add an output to a log file at the end

Code: Select all

 >> "D:/filebot.log" 2>&1
you can test in a cmd window if you wish but the code has to be modified for that, the way i went about testing was rather than putting the code in the µTorrent -> Run this program when torrent finishes box, i put the code in the when 'torrent status changes' then i just pause or started an existing movie or tv torrent to test.

enumo
Posts: 21
Joined: 15 Jan 2013, 16:19

Re: Script for sorting movies and tv-shows

Post by enumo » 15 Jan 2013, 23:09

Theres one thing in the code that i posted that i dont get. I make a output on media. And then 1 for movies and one for tv shows. I dont get it.

enumo
Posts: 21
Joined: 15 Jan 2013, 16:19

Re: Script for sorting movies and tv-shows

Post by enumo » 15 Jan 2013, 23:20

I think i got it. This should be the code i guess.

Code: Select all

 filebot -script fn:utorrent-postprocess --output "C:/media" --action copy --conflict override -non-strict --def subtitles=n artwork=n "ut_dir=%D" "ut_file=%F" "ut_kind=%K" "ut_title=%N" "ut_label=%L" "ut_state=%S" --def "seriesFormat=series/{n}/{fn}" "movieFormat=films/{n} {y}/{fn}" 
But will filebot get that needs to look into c:/media/downloads/compleet ?
This is correctly setup in utorrent.

Vinnie05
Posts: 15
Joined: 14 Jan 2013, 09:30

Re: Script for sorting movies and tv-shows

Post by Vinnie05 » 15 Jan 2013, 23:41

Im pretty sure filebot when run from utorrent will know the utorrent compleet directory using the variables "ut_dir=%D" "ut_file=%F"

enumo
Posts: 21
Joined: 15 Jan 2013, 16:19

Re: Script for sorting movies and tv-shows

Post by enumo » 16 Jan 2013, 08:47

oke, so it isn't working, no file whas either copied or moved.
What am i doing wrong?
This is the code im executing :

Code: Select all

 filebot -script fn:utorrent-postprocess --output "C:/media" --action copy --conflict override -non-strict --def subtitles=n artwork=n "ut_dir=%D" "ut_file=%F" "ut_kind=%K" "ut_title=%N" "ut_label=%L" "ut_state=%S" --def "seriesFormat=series/{n}/{fn}" "movieFormat=films/{n} {y}/{fn}" 
Filebot has created this log:

Code: Select all

 Parameter: subtitles = n
Parameter: artwork = n
Parameter: ut_dir = %D
Parameter: ut_file = %F
Parameter: ut_kind = %K
Parameter: ut_title = %N
Parameter: ut_label = %L
Parameter: ut_state = %S
Parameter: seriesFormat = series/ {n}/{fn}
Parameter: moviesFormat = films/{n} {y}/{fn}
Done ?(?????)?

User avatar
rednoah
The Source
Posts: 16278
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Script for sorting movies and tv-shows

Post by rednoah » 16 Jan 2013, 09:09

Vinnie05 wrote:Im pretty sure filebot when run from utorrent will know the utorrent compleet directory using the variables "ut_dir=%D" "ut_file=%F"
Exactly as the guy says.

Did you ever even open µTorrent->Preferences->Run Program?

It clearly says:

Code: Select all

You can use the following parameters:

%F - Name of downloaded file (for single file torrents)
%D - Directory where files are saved
%N - Title of torrent
%P - Previous state of torrent
%L - Label
%T - Tracker
%M - Status message string (same as status column)
%I - hex encoded info-hash
%S - State of torrent
%K - kind of torrent (single|multi)
Also you can run it without utorrent (without the ut_* parameters) and that's all clearly documented in the "Standalone Usage" section alongside a video tutorial.

EDIT:
If u set up utorrent to use your own batch script then you also have to figure how to pass these parameters %D %F etc into the .bat script and from there pass it along to FileBot. So... do exactly as I wrote, no batch scripts, and as the screenshot shows, paste the whole filebot -script ... call directly into utorrent.
:idea: Please read the FAQ and How to Request Help.

enumo
Posts: 21
Joined: 15 Jan 2013, 16:19

Re: Script for sorting movies and tv-shows

Post by enumo » 16 Jan 2013, 09:41

Thx Rednoa. But i Figured it out :D.
And yes i have opened the run in utorrent but it somehow doesn't reconize the utorrent complete folder. I use the stand-alone script like so:

Code: Select all

filebot -script fn:utorrent-postprocess "C:/Media/Downloads/Compleet" --output "C:/Media/" --action copy --conflict override -non-strict --def subtitles=n artwork=n --def "movieFormat=C:/Media/Films/{n} {y}/{fn}" "seriesFormat=C:/Media/Series/{n}/{fn}"
EDIT
I don't use any batch files, i tried the original script you wrote but it failed.
Im now testing it with a download in utorrent if that works, man it would be great..

ill re-edit this post when its finished.
EDIT

EDIT 2
Ok, ive put this into utorrent runprogram:

Code: Select all

C:\invoke.vbs filebot -script fn:utorrent-postprocess "C:/Media/Downloads/Compleet" --output "C:/Media/" --action copy --conflict override -non-strict --def subtitles=n artwork=n --def "movieFormat=C:/Media/Films/{n} {y}/{fn}" "seriesFormat=C:/Media/Series/{n}/{fn}" >> "C:/Media/filebot.log" 2>&1
But i don't get a log, so it isn't excecuted...
Im going to try without the invoke command.

EDIT 2

User avatar
rednoah
The Source
Posts: 16278
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Script for sorting movies and tv-shows

Post by rednoah » 16 Jan 2013, 10:25

Yeah, but with that you'll process everything again and again and again. Normally you'd call that script once for each downloaded folder, or rather utorrent would do it for you.

Not sure what you're doing with utorrent. But it should replace all the %D %F etc with paths and then execute that command. I'm using utorrent 3.2.2 but it should also work with the 2.* versions. You can check the Logger tab in utorrent and see what command with what arguments are called each time.
:idea: Please read the FAQ and How to Request Help.

enumo
Posts: 21
Joined: 15 Jan 2013, 16:19

Re: Script for sorting movies and tv-shows

Post by enumo » 16 Jan 2013, 10:38

Hmm oke, so thats not what i wan't
I use utorrent 3.2.3 as a service!!! not with windows 7 gui.

Could you please tell me wich code i should use, i'm loosing my head here :P

Im getting an empty log... darn!

Maybe something wrong with the way i setup utorrent?
What should be the right way,
At this moment when i put in a .torrent file in my torrent map, utorrent picks up on it an downloads the file and places it in the complete folder.
Then filebot should rename and copy it into the right folder.

aaargh! *frustrated* :D

enumo
Posts: 21
Joined: 15 Jan 2013, 16:19

Re: Script for sorting movies and tv-shows

Post by enumo » 16 Jan 2013, 10:54

Ok. So when the torrent has finished downloading, i see in a blink that the script does get executed but it immidiatly closes.

the log file is blank, when copy pasting the script from the utorrent run dialoge and pasting it into a cmd window it executes with the early given log saying done???

I really dont get it....

enumo
Posts: 21
Joined: 15 Jan 2013, 16:19

Re: Script for sorting movies and tv-shows

Post by enumo » 16 Jan 2013, 11:31

So after some tests, the original script :

Code: Select all

 filebot -script fn:utorrent-postprocess --output "C:/Media/" --action copy --conflict override -non-strict --def subtitles=n artwork=n "ut_dir=%D" "ut_file=%F" "ut_kind=%K" "ut_title=%N" "ut_label=%L" "ut_state=%S" 
Gives the same output as the altered script, I got it working once with the standalone script.

Code: Select all

 
Parameter: subtitles = n
Parameter: artwork = n
Parameter: ut_dir = %D
Parameter: ut_file = %F
Parameter: ut_kind = %K
Parameter: ut_title = %N
Parameter: ut_label = %L
Parameter: ut_state = %S
Done ?(?????)?
WTF am I doing wrong....

enumo
Posts: 21
Joined: 15 Jan 2013, 16:19

Re: Script for sorting movies and tv-shows

Post by enumo » 16 Jan 2013, 11:46

So just to get everything clear.
My setup:

- Windows 7 Ultimate 64bit
- Utorrent 3.2.3
- filebot 3.2 64bit
- Java 7 64Bit
- XBMC

- Windows 7
Is setup without loading explorer.exe (boots straight onto XBMC UI)
I Created a custom service for loading Utorrent (I can acces the webui from a other pc)

- Utorrent
Is Setup to look in C:\Media\Downloads\Torrents for .torrent files and auto-download them.
When download is finished Utorrent puts the files into C:\Media\Downloads\Compleet
Then Utorrent runs the filebot script.

My folder structure is as follows"

C:\Media\Films\The Green Mile 2009\The Green Mile 2009.avi (for movies)
C:\Media\Series\Californication\Californication S1E1.avi (for tv-shows)
C:\Media\Downloads\Compleet (for the completed downloads)
C:\Media\Downloads\Torrents\ (for the .torrent files folder)

The script won't do its thing....

User avatar
rednoah
The Source
Posts: 16278
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Script for sorting movies and tv-shows

Post by rednoah » 16 Jan 2013, 12:37

You torrent should be replacing all these %D etc with paths. I don't know how to setup utorrent as service and how to configure it in this case.

Basically this is an utorrent issues. Maybe you can check in their forums help on how to set up utorrent. If FileBot gets called with correct arguments it'll work.
:idea: Please read the FAQ and How to Request Help.

enumo
Posts: 21
Joined: 15 Jan 2013, 16:19

Re: Script for sorting movies and tv-shows

Post by enumo » 16 Jan 2013, 14:29

Searched on the Utorrent forums but no answer found, im creating a test environment with a normal windows 7 installation to see if it depends on my special setup or if theres something else going on.

enumo
Posts: 21
Joined: 15 Jan 2013, 16:19

Re: Script for sorting movies and tv-shows

Post by enumo » 16 Jan 2013, 14:41

Hmm same issue, no i'm totally confused

What needs to be setup on uTorrent? just to check?

User avatar
rednoah
The Source
Posts: 16278
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Script for sorting movies and tv-shows

Post by rednoah » 16 Jan 2013, 15:08

Nothing. Copy & Paste the command like it says in Step 1. The screenshot below shows you how it should look. Done.

@see http://filebot.sourceforge.net/forums/v ... ?f=4&t=215
:idea: Please read the FAQ and How to Request Help.

enumo
Posts: 21
Joined: 15 Jan 2013, 16:19

Re: Script for sorting movies and tv-shows

Post by enumo » 16 Jan 2013, 15:27

hmm then i know whats going on i think.
I changed the download directory's and stuff in utorrent maybe i should leave those default?

reinstalling utorrent and not changing anything except the run script thing... ill post my findings here...

enumo
Posts: 21
Joined: 15 Jan 2013, 16:19

Re: Script for sorting movies and tv-shows

Post by enumo » 16 Jan 2013, 15:51

That doesn't work either.... i dont know it now anymore, the stand alone script works fine but with the variable for utorrent it doesn't work...

User avatar
rednoah
The Source
Posts: 16278
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Script for sorting movies and tv-shows

Post by rednoah » 16 Jan 2013, 15:53

Has to be a utorrent issue then. Though it seems to work for me and dozens of other people.
:idea: Please read the FAQ and How to Request Help.

enumo
Posts: 21
Joined: 15 Jan 2013, 16:19

Re: Script for sorting movies and tv-shows

Post by enumo » 16 Jan 2013, 19:31

So I finally got the script working with utorrent, now i'm trying to hide the cmd windows with the invoke.vbs script, but then it won't execute the script. No errors in the log, the log will come back empty. The reason why the script wouldn't execute is because of win7 64bit and java 64bit. so i installed java 32bit and the script did its thing. now the vbs script wont work...

Any ideas?

thnx, when it all works i'll make a howto on this for future reference....

gr Enumo

enumo
Posts: 21
Joined: 15 Jan 2013, 16:19

Re: Script for sorting movies and tv-shows

Post by enumo » 16 Jan 2013, 22:34

Its seems like i got it nailed, now for the final test. ill let know when its working. with the script that i used. hope i can help others. (also building a howto)

[edit]

Its working!!! :D, have a massive headache now but thats allright
From putting a .torrent file into a specified map then auto download and auto place it to the correct folder and then xbmc updates the library automaticly :D

Ill Create a new topic with my howto in a couple of days.
Good Night for now!
[edit]

Post Reply