Fully Automated - moving files to existing library

Running FileBot from the console, Groovy scripting, shell scripts, etc
User avatar
slugxl
Donor
Posts: 50
Joined: 21 Jan 2013, 20:11

Fully Automated - moving files to existing library

Post by slugxl »

Hi,
Awesome work with FileBot. I spent the weekend trying to do what filebot does with scru and the renamer using vb.net as glue. Then Sunday night I discovered Filebot and was just amazed.

I will be donating soon.

I have a question. Filebot is doing everything I wanted but there is one last step that I need to take care of... I have media about 6 different volumes. The volume will have movies or tv. New movies are not hard, I'm just moving them to a particular volume. But tv shows - if I already have a series, and I get a new episode, I'd like to move the new episode to the exising location. If it is a new show, then it will go to another location where I am putting new series.

I'm not sure if I could figure out who to do this with your scripting engine. I know vbscript and vb.net/C#. Can you suggest a way I tie in this final step with FileBot? I am using the utorrent postprocessing script right now.

I would also like to integrate 'pushover' notifications on completions.

I am not asking you to write anything...just maybe some ideas.

Thanks,
slug.
User avatar
slugxl
Donor
Posts: 50
Joined: 21 Jan 2013, 20:11

Re: Fully Automated - moving files to existing library

Post by slugxl »

Donation complete. I don't know how you will know it was me but I did :)

I've been reviewing your scripting code. I suppose you may have documentation up on writing groovy but I have not found what I need yet.

Maybe I will start with trying to add pushover notifications as that should be easier than code to find where to put files dynamically.

Thanks,
slug.
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Fully Automated - moving files to existing library

Post by rednoah »

Just checked your email address you've registered with here. Thx, 2-digit donations are pretty rare! I should make a supports group in the forums sometime.

Overview and plenty of links to get you started are here:
http://filebot.sourceforge.net/script.html

And specifically on the format expressions:
http://filebot.sourceforge.net/naming.html

The "where to put files" you can all code into the format expression. I can show u later.

e.g.

Code: Select all

{new File('C:/Shows', n).exists() ? 'C:/Shows/'+n : 'D:/Shows/'+n}/...
This is just to get you thinking. You can write it much more pretty and more general. Maybe even read from a config file and check free space on different disks etc.

PS: I'll eventually do push-notifications at some point. Seem to be requested more and more lately.
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Fully Automated - moving files to existing library

Post by rednoah »

* Added support for Pushover notifications to utorrent-script:

Code: Select all

--def pushover=userkey
If you want, you can add your own Pushover code with this:

Code: Select all

include('fn:lib/ws')
Pushover('userkey').send('message')
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Fully Automated - moving files to existing library

Post by rednoah »

Here's what I came up with:

Code: Select all

{["C:", "D:", "E:"].collect{"$it/TV/$n" as File}.sort{a,b -> a.exists() <=> b.exists() ?: a.root.freeSpace <=> b.root.freeSpace}.last()}/{episode}
This format will always evaluate to a path to the drive with the most free space, unless the series folder already exists on one of the drives in which case it'll prefer the existing one.

NOTE: You'll need to grab the latest r1419 for this from HEAD.
:idea: Please read the FAQ and How to Request Help.
User avatar
slugxl
Donor
Posts: 50
Joined: 21 Jan 2013, 20:11

Re: Fully Automated - moving files to existing library

Post by slugxl »

Wow. Thank you very much. You can really fly.

I will look forward to testing this out after work.

Thanks again.

slug.

-Just gotta say again, you are awesome. I will send some more coffee your way next paycheck. Well worth it.
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Fully Automated - moving files to existing library

Post by rednoah »

Sure thing! I make it a rule to help people that actively support projects like this. Not a lot of people do.
:idea: Please read the FAQ and How to Request Help.
User avatar
slugxl
Donor
Posts: 50
Joined: 21 Jan 2013, 20:11

Re: Fully Automated - moving files to existing library

Post by slugxl »

Quick question...What would be the syntax to push the output directory name instead of input? I tried to figure out... assume it is in getRenameLog but didn't know how to get it. Thanks, slug.
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Fully Automated - moving files to existing library

Post by rednoah »

You can modify the script and change the message.

Maybe this will get info you what you want?

Code: Select all

getRenameLog().values().dir.path.unique()
:idea: Please read the FAQ and How to Request Help.
User avatar
slugxl
Donor
Posts: 50
Joined: 21 Jan 2013, 20:11

Re: Fully Automated - moving files to existing library

Post by slugxl »

Thank you!
User avatar
slugxl
Donor
Posts: 50
Joined: 21 Jan 2013, 20:11

Re: Fully Automated - moving files to existing library

Post by slugxl »

Donated.
User avatar
slugxl
Donor
Posts: 50
Joined: 21 Jan 2013, 20:11

Re: Fully Automated - moving files to existing library

Post by slugxl »

Maybe you can help me a little more. You might be like 'what the heck dude' but I haven't had much time to devote to this. I did what you told me above and it works. The shows go where they are supposed to and I get the pushover notification (thank you).

Here are my questions - one thing is happening and I do not know why. When utorrent calls the processing script like I said everything works. It un-rars to my unrar directory and the files get processed. But two things are happening. One, it is also unraring in the 'complete' folder (where my downloads go). It unrars into a all lowercase directory in the directory where all the rar files are. I don't know why that is happening. Second, I am calling it with the cleaner and the cleaner is cleaning my 'complete' folder. I just wanted it to clean the folder it is supposed to be extracting to 'the unrar' folder. So I need it to stop extracting in my 'complete' folder and not clean my 'complete' folder as this is where it is seeding from.

Finally, my request about the pushover giving me the 'final' name is not quite what I intended. I get the 'final' full path. All I was wanting is pushover to send me the 'final' clean name.

Sorry if I am troubling you with this stuff.

Thank you.

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

Re: Fully Automated - moving files to existing library

Post by rednoah »

Can you give me some examples for file paths and issues? I can't quite follow. The console log would be useful.
:idea: Please read the FAQ and How to Request Help.
User avatar
slugxl
Donor
Posts: 50
Joined: 21 Jan 2013, 20:11

Re: Fully Automated - moving files to existing library

Post by slugxl »

Ok. Give me a bit. But I will get back to you.
User avatar
slugxl
Donor
Posts: 50
Joined: 21 Jan 2013, 20:11

Re: Fully Automated - moving files to existing library

Post by slugxl »

Here's the deal. 1) when I run the script using cmdline I see no output, no println. 2) if I add >> "C:\filebot.log" 2>&1 to the end of my cmdlne the command does not see it. The command just ends with the nonstrict.

Sorry, idiot i know, but that's the deal. So tryingt to get log info for you but having trouble.
User avatar
slugxl
Donor
Posts: 50
Joined: 21 Jan 2013, 20:11

Re: Fully Automated - moving files to existing library

Post by slugxl »

Since I am having issues creating the output you need to see I ran procmon and monitored the process. I saved the part where you can see it creating the directory in my complete folder. You will need the procmon app to view this log file. Easily downloadable off the web. Here it is, it filtered it so you just see the writes I am talking about. Probably not what you need, but proof of what is going on:
https://dl.dropbox.com/u/5274864/filebot.PML

Here is the command line:
"C:\Program Files (x86)\FileBot\FileBot.jar" -script "C:/test.groovy" "C:/uTorrent/Complete/" --output "C:/uTorrent/UnRar" --action copy --conflict skip -non-strict

and here is an example of the groovy script i am running. The only difference between this and the actual one is where I specify the directories in the format portion so the shows get copied to the correct location.

https://dl.dropbox.com/u/5274864/test.groovy.copy.txt

and if you want to see this is the actual groovy script i am using:
https://dl.dropbox.com/u/5274864/aj.groovy.copy.txt
Last edited by slugxl on 28 Jan 2013, 23:36, edited 1 time in total.
User avatar
slugxl
Donor
Posts: 50
Joined: 21 Jan 2013, 20:11

Re: Fully Automated - moving files to existing library

Post by slugxl »

Also, any suggestions on what to use so pushover sends me the final 'clean' name of the file?

if you look above i hit you up with another donation.
User avatar
slugxl
Donor
Posts: 50
Joined: 21 Jan 2013, 20:11

Re: Fully Automated - moving files to existing library

Post by slugxl »

And examples of file paths:

The way I have it setup uTorrent's completed downloads go into a folder called 'complete'. So like C:\uTorrent\Complete
For unrar the files (filebot's job) the files go to a folder called UnRar so C:\uTorrent\UnRar
Then the script processes the data in the UnRar folder.

I hope that helps.
User avatar
slugxl
Donor
Posts: 50
Joined: 21 Jan 2013, 20:11

Re: Fully Automated - moving files to existing library

Post by slugxl »

I added the path to java in my path variable and I now can see the output when I run cmdline. But, I still cannot write it to file. Working on it.
User avatar
slugxl
Donor
Posts: 50
Joined: 21 Jan 2013, 20:11

Re: Fully Automated - moving files to existing library

Post by slugxl »

Ok, I piped the output.

Code: Select all

C:\uTorrent>FileBot -script "C:/test.groovy" "C:/uTorrent/Complete/" --output "C:/uTorrent/UnRar" --action copy --conflict skip -non-strict 
Argument: C:\uTorrent\Complete
Read archive [arrow.101.hdtv-lol.rar] to [C:\uTorrent\Complete\Arrow.S01E01.HDTV.x264-LOL\arrow.101.hdtv-lol]
Extracting files [C:\uTorrent\Complete\Arrow.S01E01.HDTV.x264-LOL\arrow.101.hdtv-lol\arrow.101.hdtv-lol.mp4]
Input: C:\uTorrent\Complete\Arrow.S01E01.HDTV.x264-LOL\arrow.101.hdtv-lol\arrow.101.hdtv-lol.mp4
Jan 28, 2013 7:52:30 PM net.sourceforge.filebot.web.OpenSubtitlesXmlRpc checkMovieHash
WARNING: Ignore hash match due to hash collision: ["Arrow" Pilot (2012), "Arrow" Honor Thy Father (2012), A Very Harold & Kumar 3D Christmas (2011), "Arrow" Lone Gunmen (2012)]
arrow.101.hdtv-lol.mp4 [series: Arrow, movie: Love 101 (2000)]
Exclude Movie: Love 101 (2000)
Group: [tvs:Arrow, mov:null, anime:null] => [arrow.101.hdtv-lol.mp4]
Rename episodes using [TheTVDB]
Auto-detected query: [Arrow]
Fetching episode data for [Arrow]
Fetching episode data for [Arrows Of Desire]
[COPY] Rename [C:\uTorrent\Complete\Arrow.S01E01.HDTV.x264-LOL\arrow.101.hdtv-lol\arrow.101.hdtv-lol.mp4] to [C:\uTorrent\UnRar\TV Shows\Arrow\Season 1\Arrow - S01E01 - Pilot.mp4]
Processed 1 files
Sending Pushover notification
Done ?(?????)?
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Fully Automated - moving files to existing library

Post by rednoah »

Looks good to me.

1. What's the issue? Everything you passed in gets extracted, processed and then sorted into --output. Archives will be extracted in the same folder and since you're using COPY the extracted files will not be moved away.

2. What would you message would you like me to send in this case for example?
:idea: Please read the FAQ and How to Request Help.
User avatar
slugxl
Donor
Posts: 50
Joined: 21 Jan 2013, 20:11

Re: Fully Automated - moving files to existing library

Post by slugxl »

will having the extracted directory in my seeding folder effect downloads for those downloading
the torrent? sorry I am ignorant on this.

I'm on my phone cannot see all the code above. just would like the show or movie name after it has been processed.

if you don't know what I mean don't worry about it.

also I cannot use cleaner because it removes files from seeding folder correct? that is what I am seeing.

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

Re: Fully Automated - moving files to existing library

Post by rednoah »

1. Nope, the extracted files will not affect anything.

2. So you mean the destination filename? You mean a table like in the notification email?

3. The cleaner will not touch any folder that contains at least one video file. It may however delete subfolders that only contains subtitles etc. You should not use clean=y unless you're moving files.

EDIT:
--action move --def clean=y As before => run "The Cleaner" on all the input paths
--action copy --def clean=y *NEW* => keep track of extracted files in the beginning, after things have been copied to new location delete those now useless files again
:idea: Please read the FAQ and How to Request Help.
User avatar
slugxl
Donor
Posts: 50
Joined: 21 Jan 2013, 20:11

Re: Fully Automated - moving files to existing library

Post by slugxl »

1 ok
2 Arrow - S01E01- Pilot.mkv
3 ok - don't use cleaner
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Fully Automated - moving files to existing library

Post by rednoah »

2. This will get u started, the rest is easy scripting:

Code: Select all

def m = getRenameLog().values().name.join(', ')
println m
:idea: Please read the FAQ and How to Request Help.
Post Reply