Fully automated media downloading
Fully automated media downloading
Hi,
I've just discovered FileBot and I'm really impressed by how powerful it is compared to the other media renamers around. I've been having a look at the documentation and playing around with it a little but it is quite complex, but I am eager to support the project.
What I would like to achieve is being able to automatically copy and rename any movies and episodes downloaded via uTorrent to the appropriate directory upon completion of the download, and then ideally update XBMC library. The files need to be copied rather than moved so that the original can be seeded.
The event to trigger the Filebot operations could be either monitoring of the download folder, or alternatively using uTorrent's setting to launch a program upon download completion. Ideally, Filebot would then distinguish between movies and episodes and copy and rename accordingly. (Would other files in the download folder which are not movies or episodes be ignored at this point, or would they need to be filtered out from the directory beforehand?)
Any help on achieving this would be much appreciated. I am eager to get into it and make use of this project!
Cheers
I've just discovered FileBot and I'm really impressed by how powerful it is compared to the other media renamers around. I've been having a look at the documentation and playing around with it a little but it is quite complex, but I am eager to support the project.
What I would like to achieve is being able to automatically copy and rename any movies and episodes downloaded via uTorrent to the appropriate directory upon completion of the download, and then ideally update XBMC library. The files need to be copied rather than moved so that the original can be seeded.
The event to trigger the Filebot operations could be either monitoring of the download folder, or alternatively using uTorrent's setting to launch a program upon download completion. Ideally, Filebot would then distinguish between movies and episodes and copy and rename accordingly. (Would other files in the download folder which are not movies or episodes be ignored at this point, or would they need to be filtered out from the directory beforehand?)
Any help on achieving this would be much appreciated. I am eager to get into it and make use of this project!
Cheers
Re: Fully automated media downloading
The basic command-line should be very simple to use. Things like notifying xbmc and seperating movie from tv shows and complicated and really depends on what you need.
The pre-defined example scripts already do what you need. You can either use those in sequence or copy things into one big scripts that does everything you need the way you want.
btw move/rename is only the standard action, there is also --action move | copy | keeplink | symlink | hardlink and test (which does nothing, so it's useful for testing).
This post tells you where to find the code needed for each task. Should be pretty much copy&paste:
http://filebot.sourceforge.net/forums/v ... &t=86#p583
If you want a folder monitor or start things yourself via utorrent is up to you. Both is possible. Maybe the latter is easier for you.
The pre-defined example scripts already do what you need. You can either use those in sequence or copy things into one big scripts that does everything you need the way you want.
btw move/rename is only the standard action, there is also --action move | copy | keeplink | symlink | hardlink and test (which does nothing, so it's useful for testing).
This post tells you where to find the code needed for each task. Should be pretty much copy&paste:
http://filebot.sourceforge.net/forums/v ... &t=86#p583
If you want a folder monitor or start things yourself via utorrent is up to you. Both is possible. Maybe the latter is easier for you.
Re: Fully automated media downloading
So I've knocked something together using code mostly from the examples. All seems to work well for now, except the XBMC notification.

Not sure what the problem is here.
Also- Is there a way to prevent Filebot from moving all the files already in my downloads folder when I direct it there properly? All the files have been renamed properly at the moment, I only want Filebot to deal with any new incoming files from now.
For triggering within uTorrent, would I just be writing a batch file with the command to run the Groovy script, and running that on completion of all torrents?

Not sure what the problem is here.
Also- Is there a way to prevent Filebot from moving all the files already in my downloads folder when I direct it there properly? All the files have been renamed properly at the moment, I only want Filebot to deal with any new incoming files from now.
For triggering within uTorrent, would I just be writing a batch file with the command to run the Groovy script, and running that on completion of all torrents?
Code: Select all
// filebot -script "rename.groovy" -trust-script <folder> -non-strict --action keeplink
// PERSONALISED SETTINGS
def episodeFormat = "C:/Videos/{n}/Season {s}/{n} - {sxe} - {t}"
def movieFormat = 'C:/Movies/{n} ({y})/{n} ({y}){" CD$pi"}'
def xbmc = ['Apple-TV.lan', 'localhost']
/*
* Move/Rename a mix of episodes and movies that are all in the same folder.
*/
def groups = args.getFiles().groupBy{
def tvs = detectSeriesName(it)
def mov = detectMovie(it, false)
println "$it.name [series: $tvs, movie: $mov]"
// DECIDE EPISODE VS MOVIE (IF NOT CLEAR)
if (tvs && mov) {
if (it.name =~ "(?i:$tvs - .+)" || parseEpisodeNumber(it.name) || parseDate(it.name)) {
println "Exclude Movie: $mov"
mov = null
} else if (detectMovie(it, true)) {
println "Exclude Series: $tvs"
tvs = null
}
}
return [tvs:tvs, mov:mov]
}
groups.each{ group, files ->
// EPISODE MODE
if (group.tvs && !group.mov) {
return rename(file:files, format:episodeFormat, db:'TheTVDB')
}
// MOVIE MODE
if (group.mov && !group.tvs) {
return rename(file:files, format:movieFormat, db:'TheMovieDB')
}
}
// make XBMC scan for new content
xbmc.each { host ->
telnet(host, 9090) { writer, reader ->
writer.println('{"jsonrpc": "2.0", "method": "VideoLibrary.ScanForContent", "id": 1}')
}
}Re: Fully automated media downloading
Code: Select all
filebot -script "rename.groovy" -trust-script <folder> -non-strict --action keeplinkBy default filebot won't override things, it'll process things and then skip if it already exists. If utorrent runs filebot on download complete then it shouldn't be problem.
Re: Fully automated media downloading
Yeah, I know. I guess I could just paste that directly for uTorrent to run on download completion rather than using a batch.rednoah wrote:This only explains how to call filebot from the cmdline. "-non-strict --action keeplink" doesn't work in the script obviously, it's cmdline arguments not groovy script.Code: Select all
filebot -script "rename.groovy" -trust-script <folder> -non-strict --action keeplink
The movies in the destination directory won't necessarily be named identically to how Filebot will name them, though. How will this be handled?By default filebot won't override things, it'll process things and then skip if it already exists. If utorrent runs filebot on download complete then it shouldn't be problem.
Any ideas on what is happening with the telnet calls to XBMC?
Re: Fully automated media downloading
I'm not sure what you mean. The --conflict skip setting only applies what happens if the destination already exists. If it doesn't it'll just continue normally.
Is that telnet call not working? Maybe you need to activate the telnet api in xbmc first. Never tested that since I don't use XBMC. But it should work according to the specs.
Is that telnet call not working? Maybe you need to activate the telnet api in xbmc first. Never tested that since I don't use XBMC. But it should work according to the specs.
Re: Fully automated media downloading
What I mean is that currently the script is just checking the whole download directory for files to rename. Let's say I have the movie Movie.2011.720p.BluRay.x264-REFiNED\refined-movie-720p.mkv in the downloads directory already (prior to Filebot) and the corresponding Movie (2008)\Movie (2008) 720p.mkv in my movies directory. Now when I first direct my Groovy script to the downloads directory, it is going to come across the movie and send it to my movies directory, with the name Movie (2008)\Movie (2008).mkv. It isn't going to realise that the movie is already in the directory because the file name convention isn't identical and there won't be any file name conflict, so the end result will be a duplicate. What I would need is a way to ignore anything that is present when I first run the script and from then on only rename new files in the downloads directory each time the script is run.
Alternatively, it might make more sense to just feed the directories/files to the script directly from uTorrent as those arguments can be passed when the download complete program is run (rather than feeding it the downloads directory each time). That way I don't have to worry about anything else that might be in the input directory or making sure that only new files are renamed.
It gets a bit hairier though because the Groovy script as is only works with directories and won't work with single-file torrents. I would need to pass directory and name for single-file torrents, and I guess %D and %N for multi-file torrents, and then interpret those somehow to arrive at which files actually need to be renamed. I'm not sure I really understand which arguments mean what in terms of passing on the actual file reference to a script.
Alternatively, it might make more sense to just feed the directories/files to the script directly from uTorrent as those arguments can be passed when the download complete program is run (rather than feeding it the downloads directory each time). That way I don't have to worry about anything else that might be in the input directory or making sure that only new files are renamed.
It gets a bit hairier though because the Groovy script as is only works with directories and won't work with single-file torrents. I would need to pass directory and name for single-file torrents, and I guess %D and %N for multi-file torrents, and then interpret those somehow to arrive at which files actually need to be renamed. I'm not sure I really understand which arguments mean what in terms of passing on the actual file reference to a script.
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)Re: Fully automated media downloading
1. It's all in the scripting. Of course you can check if a folder/file already exists somewhere. But you have to came up with the logic that makes sense yourself. Easier to just enable a utorrent process.
2. The cmdline interface has no problem with files/folders. rename(folder:path) will accept a folder whereas rename(file:set) will work with one or more files directly.
Now my example assumes input is a folder. But most of the script works with a set of files.
Think like this:
def f = args[0]
def files = f.isDirectory() ? f.listFiles() : [f]
As for how to use utorrent I also dont know. Just try a test script for various parameter. e.g. args.toString().saveAs("c:/output.txt") and see what the values are for these variables.
EDIT:
Basically you just have to change the code that initally collects the files that will be processed instead of using args.getFiles().
2. The cmdline interface has no problem with files/folders. rename(folder:path) will accept a folder whereas rename(file:set) will work with one or more files directly.
Now my example assumes input is a folder. But most of the script works with a set of files.
Think like this:
def f = args[0]
def files = f.isDirectory() ? f.listFiles() : [f]
As for how to use utorrent I also dont know. Just try a test script for various parameter. e.g. args.toString().saveAs("c:/output.txt") and see what the values are for these variables.
EDIT:
Basically you just have to change the code that initally collects the files that will be processed instead of using args.getFiles().
Re: Fully automated media downloading
Ok, I've abandoned the idea of only submitting to Filebot the files that have only just been downloaded because I just can't get my head around it. I am just going to use the code I posted most recently and have Filebot triggered to scan that folder on each download complete event, and move the files while keeping a symbolic link at the download location to continue seeding.
Now, how do I get Filebot to run under administrator privileges when it is automatically triggered? The only way KEEPLINK works is if the command-prompt is run under administrator privileges.
My plan at the moment would be to add to uTorrent Run Program, rename.bat:
Now, how do I get Filebot to run under administrator privileges when it is automatically triggered? The only way KEEPLINK works is if the command-prompt is run under administrator privileges.
My plan at the moment would be to add to uTorrent Run Program, rename.bat:
Code: Select all
filebot -script "rename.groovy" -trust-script <folder> -non-strict --action keeplinkRe: Fully automated media downloading
I guess you'll need to find some kinda "sudo" for Windows.
Using utorrent to kick off a cmd on complete shouldn't be a problem. Just needs a of testing what these variables really mean. Maybe you can find better documentation or examples online.
Using utorrent to kick off a cmd on complete shouldn't be a problem. Just needs a of testing what these variables really mean. Maybe you can find better documentation or examples online.
Re: Fully automated media downloading
Odd... seems like the privileges isn't a problem when running it from a batch file. Anyway, I have the script running almost perfectly when run from batch. For any other readers, the new JSON-RPC API for XBMC Eden has some slight changes, so that the correct command is now "VideoLibrary.Scan" rather than the command from the example. XBMC needs to be set to receive commands from other programs.
Now I have an odd problem when running the batch file from uTorrent on download completion -- the batch file executes fine, but an error message comes up that Windows can't find the file "rename.groovy" (my Groovy script). At first I thought it might be because the relative file path is changed due to the batch being launched by a different program, but the same error occurs even when I change the path to an absolute one. Any ideas? I am baffled here.
At the moment I am getting the script to read all the files in the folder (as above), which I have set uTorrent to move completed downloads to. This may get to be an issue when more files are downloaded as there will be a lot of needless looking up of files before coming to a conflict at the renaming stage and aborting that file. Is there a way to mark the files as already having been scanned so that only new files will be acted upon by Filebot? From memory, theRenamer does this using the "Archived" attribute.
Now I have an odd problem when running the batch file from uTorrent on download completion -- the batch file executes fine, but an error message comes up that Windows can't find the file "rename.groovy" (my Groovy script). At first I thought it might be because the relative file path is changed due to the batch being launched by a different program, but the same error occurs even when I change the path to an absolute one. Any ideas? I am baffled here.
At the moment I am getting the script to read all the files in the folder (as above), which I have set uTorrent to move completed downloads to. This may get to be an issue when more files are downloaded as there will be a lot of needless looking up of files before coming to a conflict at the renaming stage and aborting that file. Is there a way to mark the files as already having been scanned so that only new files will be acted upon by Filebot? From memory, theRenamer does this using the "Archived" attribute.
Re: Fully automated media downloading
1. Gonna update the samples for XBMC11 with "VideoLibrary.Scan"
2. Did you mess up the cmdline somehow?
Doing this with the latest rev:
Where the script is:
So here is some data I got from playing with this:
single-file torrent:
multi-file torrent:
So just use the variables utorrent provides and just handle files that have been changed. As direct filebot -rename call from utorrent or as filebot -script is up to you depending on what you wanna do.
Try this:
Using a a filesystem property like "Archived" is a really ugly hack. Not to mentioned limited to Windows. But it can be done via scripting if you want to do it that way. If you need to "remember" what has been handled and what hasn't been handled it's probably better to keep a text file around to track that. Using filebots internal rename history might be an idea as well.
2. Did you mess up the cmdline somehow?
Doing this with the latest rev:
Code: Select all
filebot -script "D:/test.groovy" -trust-script "-Xut_file=%F" "-Xut_dir=%D" "-Xut_name=%N" "-Xut_previous_torrent_state=%P" "-Xut_label=%L" "-Xut_tracker=%T" "-Xut_status_message=%M" "-Xut_infohash=%I" "-Xut_torrent_state=%S" "-Xut_torrent_kind=%K"Code: Select all
_args.parameters.toString().saveAs('D:/out.txt')single-file torrent:
Code: Select all
ut_infohash:9622C779B10BE9A7F1F0A4D21D420EB57B0D1422
ut_previous_torrent_state:10
ut_status_message:Seeding
ut_tracker:https://tracker2.tvtorrents.com/TrackerServlet/...
ut_label:tvshows
ut_dir:E:\Storage
ut_torrent_state:5
ut_torrent_kind:single
ut_name:The.Big.Bang.Theory.It.All.Started.With.A.Big.Bang.720p.HDTV.X264-TLA.mkv
ut_file:The.Big.Bang.Theory.It.All.Started.With.A.Big.Bang.720p.HDTV.X264-TLA.mkv
Code: Select all
ut_infohash:5BE429483B294E59AE7A643CDD41154C884879BC
ut_label:
ut_previous_torrent_state:12
ut_status_message:Downloading
ut_tracker:udp://tracker.1337x.org:80/announce
ut_dir:E:\Storage
ut_torrent_state:6
ut_torrent_kind:multi
ut_name:Sherlock Holmes A Game of Shadows (2011) DVDRip XviD-MAXSPEED
ut_file:Try this:
Code: Select all
filebot -rename "%D\%N" -non-strict --action copy --format "..." --conflict overrideRe: Fully automated media downloading
No, the command-line seems to be all normal. Executing the batch file directly works fine, but when that same batch file is run from uTorrent, Windows can't find rename.groovy. It's bizarre.
I guess the command-line interface works just fine for this, I didn't take into account that the TV/movies differentiation wouldn't be an issue when it is just fed the path to what has been downloaded directly. The only functionality missing would be the XBMC library update (which I guess could be done with a separate Groovy script, provided that issue is sorted out).
I wondered whether "Archived" was Windows-specific. In any case I suppose it isn't necessary if it is just the downloaded file/s directly fed to Filebot rather than the entire downloads directory, though it might be for other situations.
I guess the command-line interface works just fine for this, I didn't take into account that the TV/movies differentiation wouldn't be an issue when it is just fed the path to what has been downloaded directly. The only functionality missing would be the XBMC library update (which I guess could be done with a separate Groovy script, provided that issue is sorted out).
I wondered whether "Archived" was Windows-specific. In any case I suppose it isn't necessary if it is just the downloaded file/s directly fed to Filebot rather than the entire downloads directory, though it might be for other situations.
Re: Fully automated media downloading
The stuff I posted above is what I got when running filebot -script from utorrent. It definitely works. Make sure you're escaping everything properly.F12 wrote:No, the command-line seems to be all normal. Executing the batch file directly works fine, but when that same batch file is run from uTorrent, Windows can't find rename.groovy. It's bizarre.
Re: Fully automated media downloading
For me --action symlink/hardlink all don't work because of the permissions problem. Otherwise this command works fine:
utorrent "Run Program":
PS: This will work for folders and files and it'll try some basic auto-detection as to handle the input as a set of episodes or as a movie (keep in mind that the given format will be applied to episode and movie data so it would have to be compatible with both).
utorrent "Run Program":
Code: Select all
filebot -rename "%D\%N" -non-strict --action copy --format "..." --conflict overrideRe: Fully automated media downloading
Didn't realise that the uTorrent "Run Program" worked like the command line, I have added the script line from before and it works fine. Running uTorrent as administrator seems to solve the permissions problem, but I am not sure as something else I did might have completely solved that. On a related note, though, KEEPLINK does not appear to permit uTorrent to keep seeding unfortunately ("Error: Files missing from job. Please recheck.") Perhaps HARDLINK would work if the destination and downloads directory were on the same volume, but they are not in my case so I might have to resort to using COPY.
How can the XBMC telnet call be integrated into what we have currently?
Not sure how I would do this with seasons for episodes, CD numbers for movies and so on?(keep in mind that the given format will be applied to episode and movie data so it would have to be compatible with both)
How can the XBMC telnet call be integrated into what we have currently?
Re: Fully automated media downloading
1. keeplink is two operations. First move, then symlink back. The move part breaks utorrent if it has the file open. utorrent just needs to close the original file and then reopen the symlink. So just restart utorrent and/or do stop/resume download. That should work. hardlink/symlink/copy work because the original file is not touched.
2. Nope, cmdline can't take care of more complicated processes. That's what scripting is for.
Working on something for that right now:
http://filebot.sourceforge.net/scripts/ ... ess.groovy
2. Nope, cmdline can't take care of more complicated processes. That's what scripting is for.
Working on something for that right now:
http://filebot.sourceforge.net/scripts/ ... ess.groovy
Re: Fully automated media downloading
You can try this now:
* Replace FileBot.jar with the latest revision r985:
http://sourceforge.net/projects/filebot ... ebot/HEAD/
* Use this utorrent "Run Command" action:
* Replace FileBot.jar with the latest revision r985:
http://sourceforge.net/projects/filebot ... ebot/HEAD/
* Use this utorrent "Run Command" action:
Code: Select all
filebot -script "http://filebot.sf.net/scripts/utorrent-postprocess.groovy" "%D\%N" --output "X:/media" --action copy --conflict override -non-strict -trust-script -Xxbmc=localhostRe: Fully automated media downloading
That was my first thought as well, but after forcing a recheck the same error occurs. I am sure symlink would be more functional but I want the actual files residing in my media folder, not the seeding folder so it looks like I will have to use copy for the time being, at least until I make some changes to my filesystem structure some time down the road. The advantage offered by keeplink is great though, so I'll try to work out what's going on there and why uTorrent doesn't seem to be following the link.rednoah wrote:1. keeplink is two operations. First move, then symlink back. The move part breaks utorrent if it has the file open. utorrent just needs to close the original file and then reopen the symlink. So just restart utorrent and/or do stop/resume download. That should work. hardlink/symlink/copy work because the original file is not touched.
Yeah, I was thinking maybe combining the command-line and a script just for the XBMC notification but it seemed ungainly. The solution you've put together is much better.2. Nope, cmdline can't take care of more complicated processes. That's what scripting is for.
Looks perfect. I'm not home at the moment but I will check it when I get a chance. The only thing I can think of is that the original example allowed for multiple XBMC hostnames through the use of the array. Is that still allowed for in your example or does it only take a single string? The try-catch statement is good though, previously it would error if any of the XBMC instances were closed (or not set up correctly). Also, what is the reason for adding --conflict override?Working on something for that right now:
http://filebot.sourceforge.net/scripts/ ... ess.groovy
This would be worthwhile putting on XBMC forums once it's done, it is far superior to most of the automation solutions used currently.
Re: Fully automated media downloading
It's all in the script. I only provide a standard example then people can edit/modify it later to fit their needs.Looks perfect. I'm not home at the moment but I will check it when I get a chance. The only thing I can think of is that the original example allowed for multiple XBMC hostnames through the use of the array. Is that still allowed for in your example or does it only take a single string? The try-catch statement is good though, previously it would error if any of the XBMC instances were closed (or not set up correctly). Also, what is the reason for adding --conflict override?
If you download the same episode again later (maybe a better quality version) then you can decide what happens via --conflict skip|error|override.
Re: Fully automated media downloading
The utorrent variables really don't make sense. Added the logic for single-vs-multi torrent in the script now:
Also you can do -Xxbmc=localhost,xbmc,etc now.
Code: Select all
filebot -script "http://filebot.sf.net/scripts/utorrent-postprocess.groovy" --output "X:/media" --action copy --conflict override -non-strict -trust-script -Xxbmc=localhost "-Xut_dir=%D" "-Xut_file=%F" "-Xut_label=%L" "-Xut_state=%S" "-Xut_kind=%K"Re: Fully automated media downloading
btw here's a link to utorrent api interface, might be useful if you need to script stopping/starting a torrent:
http://www.utorrent.com/community/devel ... bapi#devs1
http://www.utorrent.com/community/devel ... bapi#devs1
Re: Fully automated media downloading
Turns out the symlink issue is a known bug in uTorrent. Given that it was reported in 2009 there is not much chance of it being fixed anytime in the near future. http://forum.utorrent.com/viewtopic.php?pid=478896
I think copy is really the only solution for me, although hardlink would work for users who have their seeding directory and the media directory on the same volume.
I think copy is really the only solution for me, although hardlink would work for users who have their seeding directory and the media directory on the same volume.
Re: Fully automated media downloading
Ok, really odd problem now. The script works perfectly when pointing it to the online version (straight copy-paste of the command line you posted) but when I use the exact same script locally (C:/Batches/utorrent-postprocess.groovy), it doesn't work. No idea what's happening but it is really frustrating. The script does run momentarily because I can see the command prompt and a few of the first lines (parameters etc.) but then it closes without doing all the look-up etc. I have no idea what is happening - literally the only change is that the script is local.
Another thing that is worth noting (although not really a problem) is that for multi-file torrents, if the files are downloaded one at at time there will be a torrent completion event for each file (which is desirable, obviously), but the path will still refer to the entire directory. That means that the lookup process will all happen for every file in that torrent each time a new file is downloaded. Again, not really a problem but worth noting.
Another thing that is worth noting (although not really a problem) is that for multi-file torrents, if the files are downloaded one at at time there will be a torrent completion event for each file (which is desirable, obviously), but the path will still refer to the entire directory. That means that the lookup process will all happen for every file in that torrent each time a new file is downloaded. Again, not really a problem but worth noting.
Re: Fully automated media downloading
1. Check the utorrent log and see what command is called exactly. Local files work. That's what I work with obviously.
2. Oh? Then it's "multi" but also has "file" set? Can you help me do some testing and see what's happening? Then we can figure out the best way to integrate with utorrent. Is there a way to check if the torrent is completed?
2. Oh? Then it's "multi" but also has "file" set? Can you help me do some testing and see what's happening? Then we can figure out the best way to integrate with utorrent. Is there a way to check if the torrent is completed?
Re: Fully automated media downloading
Code: Select all
[2012-04-27 12:59:28] Executing: filebot -script "C:/Batches/utorrent-postprocess.groovy" --output "F:" --action copy --conflict override -non-strict -trust-script -Xxbmc=localhost "-Xut_dir=D:\Downloads\Torrents\Seeding\The.Big.Bang.Theory.S03.BDRip.XviD-SAiNTS" "-Xut_file=The.Big.Bang.Theory.S03E01.BDRip.XviD-SAiNTS.avi" "-Xut_label=" "-Xut_state=5" "-Xut_kind=multi"
[2012-04-27 13:05:05] Executing: filebot -script "http://filebot.sourceforge.net/scripts/utorrent-postprocess.groovy" --output "F:" --action copy --conflict override -non-strict -trust-script -Xxbmc=localhost "-Xut_dir=D:\Downloads\Torrents\Seeding\The.Big.Bang.Theory.S03.BDRip.XviD-SAiNTS" "-Xut_file=The.Big.Bang.Theory.S03E01.BDRip.XviD-SAiNTS.avi" "-Xut_label=" "-Xut_state=5" "-Xut_kind=multi"From looking at the logs, file is always set (for multi-file torrents it would appear to be the first file of the directory). What I mean by downloading files one at a time is that, for instance, I have a season torrent but choose to download each episode as I watch it (using the uTorrent Files option). The torrent would go to 100% each time a new file is marked for download and completed, and uTorrent will feed the entire directory for that torrent to the script, including any files that were downloaded previously. As far as I can tell there wouldn't be any way to feed it only the most recently downloaded files apart from separately logging which files have already been moved, but I don't think it is really an issue to rescan the files for each new file, unless it is a really large multi-file torrent. (Large multi-file torrents are common for scene releases, now I think about it. Collections of movies and the like, where you wouldn't usually download all the movies at once but might pick and choose at different times.)
Re: Fully automated media downloading
Did you try copying the utorrent cmd that doesnt work into the cmd and see what happens? You can also try using a file-URL instead of a file path.
Well, in that case it depends and what you want. Running multiple times should be fine but you should switch --conflict override to --conflict skip so you don't copy things over and over from the original location.
Well, in that case it depends and what you want. Running multiple times should be fine but you should switch --conflict override to --conflict skip so you don't copy things over and over from the original location.
Re: Fully automated media downloading
Darn... my browser had cached the previous version of utorrent-postprocess.groovy so that is what I had been copying into the local file, which explains a lot. It is working much better now (that is to say, it works where previously it didn't). I did have to change the regexp to include a dash as it was previously splitting one of my hostnames inappropriately.
Unless I run into any other issues, I would have to say this is a perfect solution to my initial project of automating my media centre downloads. It is a very powerful app.
Unless I run into any other issues, I would have to say this is a perfect solution to my initial project of automating my media centre downloads. It is a very powerful app.
Re: Fully automated media downloading
Let me know how it goes. I'll add subtitle and artwork/NFO download later as well. When it runs fine I'll release 2.62 with all of that.
Re: Fully automated media downloading
* Added fetching of TVDB/TMDB artwork/nfo to the utorrent-postprocess script.
Re: Fully automated media downloading
The new fn:utorrent-postprocess script should take care of everything easily now.
Re: Fully automated media downloading
It is running fantastically so far. My main concern was that Filebot might hang occasionally (for example, if multiple instances of the script are run within a few seconds of one another) but it all seems to run very smoothly. It really is an amazingly powerful tool.
Given that this is a uTorrent completion script, how would one go about adding (very basic) music handling? In my case, it would simply involve moving/copying any music files straight to the "Add to iTunes" directory, although in others' cases it might involve launching a second app to handle the renaming by tags. I would assume by making use of the File.isAudio() function and then simply copying it to the given directory, but not too sure about how to integrate it into the Groovy script.
Given that this is a uTorrent completion script, how would one go about adding (very basic) music handling? In my case, it would simply involve moving/copying any music files straight to the "Add to iTunes" directory, although in others' cases it might involve launching a second app to handle the renaming by tags. I would assume by making use of the File.isAudio() function and then simply copying it to the given directory, but not too sure about how to integrate it into the Groovy script.
Re: Fully automated media downloading
If you start a second instance while the first one is still running then the second one will not get access to the diskcache. Doesn't break anything but it'll be slower since it'll download all the data files that would usually be cached.
Re: Fully automated media downloading
Here's generally how you copy audio files to where you want:
Specifically in the utorrent-postprocess script it'd be like this (before you limit input to video/subtitle files):
If you want you can do some renaming as well via getMediaInfo/moveTo. This is how you print artist/title info for example:
You should be able to read all important tags via mediainfo. You can test that in the format editor using an audio file as sample input. But keep in mind that often some tags are not defined.
Code: Select all
args.getFiles{ it.isAudio() }*.copyTo("E:/New Music")Code: Select all
input.findAll{ it.isAudio() }*.copyTo("E:/New Music")Code: Select all
args.getFiles{ it.isAudio() }.each{ println getMediaInfo(file:it, format:"{fn} = {media.title} by {media.performer}")}Re: Fully automated media downloading
Perfect! Thanks rednoah. One other thing I noticed is that the XBMC calls at the end are all in a single try...catch statement, rather than trying each telnet call separately. The functional implication is that if the first XBMC instance errors, then none of the other XBMC instances will be updated. In my case, I had one of my XBMC instances closed so my other build did not update automatically as it was listed afterwards in the parameters. Not a big issue for me as I just put all the "always-open" XBMC instances first and then the instance that may sometimes be closed last.
Re: Fully automated media downloading
That's already fixed in the latest instance of the utorrent-postprocess script.
Re: Fully automated media downloading
Hi !
I tried all I could to rename audio but none works :
and
musicDir contains many music albums that I want to format and copy to "E:/Sorted/Musique"
I call this script with :
Here is the error in the two code examples above :
Anyone has an idea ?
I tried all I could to rename audio but none works :
Code: Select all
def musicDir = "E:/Downloads"
def musicFormat = "E:/Sorted/Musique/{fn}.{ext}"
musicDir.getFolders{ it.hasFile{ it.isAudio() } }.each{ dir ->
println "Processing $dir"
def files = dir.listFiles{ it.isAudio() }
rename(file:files, format:musicFormat)
}
Code: Select all
def musicDir = "E:/Downloads"
def musicFormat = "E:/Sorted/Musique/{fn}.{ext}"
musicDir.getFiles{ it.isAudio() }.each{
rename(file:it, format:musicFormat)
}
I call this script with :
Code: Select all
filebot -script "myscript.groovy" --action copy --conflict skip -non-strict -trust-scriptCode: Select all
Exception: No media files: [E:\Downloads\Album Folder\01 - Track.mp3]Re: Fully automated media downloading
FileBot doesnt support audio, so rename(...) only matches episodes and movies.
Check out the topic "Any Mass Renaming" for examples how to move files with scripting.
Check out the topic "Any Mass Renaming" for examples how to move files with scripting.
Re: Fully automated media downloading
Actually it already explains everything in the thread above. Have a look.
Re: Fully automated media downloading
I understand, thanks
maybe a future feature for filebot ?
I think I will search for a external tool to call after renaming my movies and tv shows, in order to process a folder with mp3 to a sorted folder like "/Music/Artist - Year - Album/01 - Track 01.mp3" ,
Anyone has an idea ?
I think I will search for a external tool to call after renaming my movies and tv shows, in order to process a folder with mp3 to a sorted folder like "/Music/Artist - Year - Album/01 - Track 01.mp3" ,
Anyone has an idea ?
Re: Fully automated media downloading
There's excellent tools out there for identifying / tagging mp3s. Just reading tags is easy and I'm sure there is loads of cmdline tools to rename files based on their tags.
Re: Fully automated media downloading
I've been happily using this script since I last posted but I am keen to just improve it a little bit and iron out any small issues. It seems to treat MP4 video as both audio and video, in that it both gets transferred to my iTunes folder and moved to my videos folder (as per normal). I'm not too sure why this is happening. Also, how can I integrate subtitle fetching into this if they are not present in the file?
The major issue was that the cmd kept stealing focus from XBMC but I found your .vbs script to address that so hopefully that issue will be resolved now.
The major issue was that the cmd kept stealing focus from XBMC but I found your .vbs script to address that so hopefully that issue will be resolved now.
Re: Fully automated media downloading
1. Had both mp4/m4a in media.types -> just gonna keep m4a then. You can quick fix that by not just using f.isAudio() but f.isAudio() && f.length() < 20*1024*1024, something like that, isAudio() only checks for extensions so you can check filesize for sanity.
2. getSubtitles(...) not working? If filebot -get-subtitles <file> works then it should also work in utorrent-postprocess (activate via --def subtitles=y)
2. getSubtitles(...) not working? If filebot -get-subtitles <file> works then it should also work in utorrent-postprocess (activate via --def subtitles=y)
Re: Fully automated media downloading
Somehow the functionality seems to have broken in the last week or so, not exactly sure where the issue lies. Looks like there might have been a change server-side?
On a mostly unrelated issue, would it be possible to include functionality to ignore sample videos downloaded, either in the script or even as core Filebot functionality? Usually I disable downloading them in the client but sometimes I forget and often Filebot and the script end up copying the sample video to the directory rather than the proper file. They are common in scene releases to check the quality. Screening for "sample" in the filename should be sufficient, it is also usually in a "Sample" subfolder and obviously much smaller in file size than the correct file. You can see an example in the cmd line output above.
Code: Select all
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\User>filebot -script "C:/Batches/utorrent-postprocess.groovy" --outpu
t "F:" --action copy --conflict override -non-strict -trust-script -Xxbmc=localh
ost "-Xut_dir=D:\Downloads\Torrents\Seeding\Parks.and.Recreation.S06E03.720p.HDT
V.X264-DIMENSION[rarbg]" "-Xut_file=Parks.and.Recreation.S06E03.720p.HDTV.X264-D
IMENSION.mkv" "-Xut_label=" "-Xut_state=5" "-Xut_kind=multi"
Parameter: ut_label =
Parameter: ut_kind = multi
Parameter: ut_dir = D:\Downloads\Torrents\Seeding\Parks.and.Recreation.S06E03.72
0p.HDTV.X264-DIMENSION[rarbg]
Parameter: xbmc = localhost
Parameter: ut_state = 5
Parameter: ut_file = Parks.and.Recreation.S06E03.720p.HDTV.X264-DIMENSION.mkv
Input: D:\Downloads\Torrents\Seeding\Parks.and.Recreation.S06E03.720p.HDTV.X264-
DIMENSION[rarbg]\parks.and.recreation.603.720p-dimension.nfo
Input: D:\Downloads\Torrents\Seeding\Parks.and.Recreation.S06E03.720p.HDTV.X264-
DIMENSION[rarbg]\Parks.and.Recreation.S06E03.720p.HDTV.X264-DIMENSION.mkv
Input: D:\Downloads\Torrents\Seeding\Parks.and.Recreation.S06E03.720p.HDTV.X264-
DIMENSION[rarbg]\RARBG.com.txt
Input: D:\Downloads\Torrents\Seeding\Parks.and.Recreation.S06E03.720p.HDTV.X264-
DIMENSION[rarbg]\Sample\p.n.fn.r.603.720p-dimension.sample.mkv
Oct 05, 2013 12:23:00 PM net.sourceforge.filebot.media.MediaDetection detectSeri
esNames
WARNING: Failed to match folder structure: http://www.filebot.net/data/series.li
st.gz
java.io.FileNotFoundException: http://www.filebot.net/data/series.list.gz
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
rce)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unkno
wn Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown So
urce)
at net.sourceforge.filebot.web.WebRequest.fetch(Unknown Source)
at net.sourceforge.filebot.web.WebRequest.fetchIfModified(Unknown Source
)
at net.sourceforge.filebot.web.CachedResource.fetchData(Unknown Source)
at net.sourceforge.filebot.web.CachedResource.get(Unknown Source)
at net.sourceforge.filebot.media.ReleaseInfo.getSeriesList(Unknown Sourc
e)
at net.sourceforge.filebot.media.MediaDetection.matchSeriesByName(Unknow
n Source)
at net.sourceforge.filebot.media.MediaDetection.detectSeriesNames(Unknow
n Source)
at net.sourceforge.filebot.media.MediaDetection$detectSeriesNames.call(U
nknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSi
teArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCa
llSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCa
llSite.java:120)
at Script2.detectSeriesName(Script2.groovy:168)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMet
hodSite.invoke(PogoMetaMethodSite.java:226)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(P
ogoMetaMethodSite.java:52)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent
(CallSiteArray.java:46)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(Abs
tractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(Abs
tractCallSite.java:145)
at Script2.detectSeriesName(Script2.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:
90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1053)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:920)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:883)
at groovy.lang.Closure.call(Closure.java:410)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.callGlobal(GroovySc
riptEngineImpl.java:380)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.access$000(GroovySc
riptEngineImpl.java:72)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl$2.invokeMethod(Groo
vyScriptEngineImpl.java:301)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl$2.invokeMethod(Groo
vyScriptEngineImpl.java:290)
at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java
:44)
at groovy.lang.Script.invokeMethod(Script.java:78)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelega
tionObjects(ClosureMetaClass.java:407)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(C
losureMetaClass.java:346)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:883)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(Po
goMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent
(CallSiteArray.java:46)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(Abs
tractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(Abs
tractCallSite.java:141)
at Script3$_run_closure5.doCall(Script3.groovy:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:
90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(C
losureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:883)
at groovy.lang.Closure.call(Closure.java:410)
at groovy.lang.Closure.call(Closure.java:423)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.groupBy(DefaultGroov
yMethods.java:3052)
at org.codehaus.groovy.runtime.dgm$364.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMetho
dSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMeta
MethodSite.java:53)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSi
teArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCa
llSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCa
llSite.java:116)
at Script3.run(Script3.groovy:26)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEn
gineImpl.java:315)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEn
gineImpl.java:111)
at javax.script.AbstractScriptEngine.eval(Unknown Source)
at net.sourceforge.filebot.cli.ScriptShell.evaluate(Unknown Source)
at net.sourceforge.filebot.cli.ScriptShell.run(Unknown Source)
at net.sourceforge.filebot.cli.ScriptShell.run(Unknown Source)
at net.sourceforge.filebot.cli.ArgumentProcessor.process(Unknown Source)
at net.sourceforge.filebot.Main.main(Unknown Source)
Caused by: java.io.FileNotFoundException: http://www.filebot.net/data/series.lis
t.gz
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown So
urce)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(Unknown So
urce)
at java.net.URLConnection.getHeaderFieldLong(Unknown Source)
at java.net.URLConnection.getContentLengthLong(Unknown Source)
at java.net.URLConnection.getContentLength(Unknown Source)
... 72 more
FileNotFoundException: http://api.themoviedb.org/2.1/Movie.search/en/xml/5a6edae
568130bf10617b6d45be99f13/Parks+and+Recreation+S06E03
java.io.FileNotFoundException: http://api.themoviedb.org/2.1/Movie.search/en/xml
/5a6edae568130bf10617b6d45be99f13/Parks+and+Recreation+S06E03
at net.sourceforge.filebot.web.WebRequest.getReader(Unknown Source)
at net.sourceforge.filebot.web.CachedPage.openConnection(Unknown Source)
at net.sourceforge.filebot.web.TMDbClient$1.openConnection(Unknown Sourc
e)
at net.sourceforge.filebot.web.CachedPage.fetchData(Unknown Source)
at net.sourceforge.filebot.web.CachedResource.get(Unknown Source)
at net.sourceforge.filebot.web.TMDbClient.fetchResource(Unknown Source)
at net.sourceforge.filebot.web.TMDbClient.getMovies(Unknown Source)
at net.sourceforge.filebot.web.TMDbClient.searchMovie(Unknown Source)
at net.sourceforge.filebot.media.MediaDetection.queryMovieByFileName(Unk
nown Source)
at net.sourceforge.filebot.media.MediaDetection.detectMovie(Unknown Sour
ce)
at net.sourceforge.filebot.media.MediaDetection$detectMovie.call(Unknown
Source)
at Script2.detectMovie(Script2.groovy:173)
at Script2.detectMovie(Script2.groovy)
at Script3$_run_closure5.doCall(Script3.groovy:28)
at Script3.run(Script3.groovy:26)
at net.sourceforge.filebot.cli.ScriptShell.evaluate(Unknown Source)
at net.sourceforge.filebot.cli.ScriptShell.run(Unknown Source)
at net.sourceforge.filebot.cli.ScriptShell.run(Unknown Source)
at net.sourceforge.filebot.cli.ArgumentProcessor.process(Unknown Source)
at net.sourceforge.filebot.Main.main(Unknown Source)
Failure (░_░)
Launch4j: Failed to run the given command.Re: Fully automated media downloading
series.list.gz has been removed in recent versions. I think your filebot install is too outdated. Try updating.
EDIT: Looks like TheMovieDB turned off the old deprecated 2.1 API
EDIT: Looks like TheMovieDB turned off the old deprecated 2.1 API
Re: Fully automated media downloading
I thought that might be the case so I updated, but the above log is after updating to the most recent version earlier today. Is TheMovieDB issue with the Groovy script or more internal to Filebot functioning?
Re: Fully automated media downloading
Nope, the log above is most definitely made by outdated filebot code. Maybe you have two installs?
Re: Fully automated media downloading
Looks like you're right, the GUI asks me to update when launched. It would seem either the installer isn't overwriting for some reason or there's multiple installs, but I can't find any duplicate install in Program Files or a reason for such.
Re: Fully automated media downloading
OK, I've managed to update but now filebot isn't accepting the arguments anymore.
If I delete that argument, it flags the next (-Xut_dir) as invalid, and so on. Has some functionality changed in recent versions that I need to update the command-line function?
Code: Select all
"-Xxbmc=localhost" is not a valid option.Re: Fully automated media downloading
The syntax for that one change completely... long ago..
It's --def name=value name=value now:
It's --def name=value name=value now:
Code: Select all
--def xbmc=localhostRe: Fully automated media downloading
OK, I finally got around to just switching over to your inclusive script for Automated Media Center which was much easier than I expected, rather than trying to keep hacking the outdated solution to work as things were updated.
Re: Fully automated media downloading
I guess utorrent-postprocess / amc has come a long way since you started this thread! 