[GUIDE] Fully Automated Media Center with qBittorrent

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
User avatar
whitestrake
Posts: 14
Joined: 26 Oct 2014, 07:35

[GUIDE] Fully Automated Media Center with qBittorrent

Post by whitestrake »

:: THIS GUIDE IS OUTDATED; DO NOT USE THIS GUIDE UNLESS YOU KNOW WHAT YOU ARE DOING ::


Setup Instructions for qBittorrent:
1. Install FileBot and qBittorrent and if you're on 64-bit make sure you have 64-bit Java installed.

2. Setup qBittorrent directories. Setup Location of Downloaded Files and make sure the path does not end with backslash.

3. Setup qBittorrent to run FileBot. Paste the following command into qBittorrent's "Run an external program on torrent completion" settings.

Options (Alt+O) -> Downloads -> Run an external program on torrent completion:

Code: Select all

filebot -script fn:amc --output "X:/path/to/media" --log-file amc.log --action copy --conflict override -non-strict --def music=y subtitles=en artwork=y excludeList=amc.txt "%f"
4. Change --output to where you want to copy/organize your files. Input is provided by qBittorrent variables.

5. Done! Setting this up will take less then a minute. Now wait and enjoy how things will be organized fully automatically.

6. Restart! If you have just installed FileBot or Java you may need to restart your computer to avoid PATH issues.

Note that qBittorrent has limited parameters for external programs, so it will not be able to pass ut_label, ut_state, ut_kind, or ut_file. It will only pass the main directory where it downloads torrents to, this means that setting --def excludeList is imperative to avoid getting banned.

Image

Head back to the main AMC documentation for more options and information!
User avatar
whitestrake
Posts: 14
Joined: 26 Oct 2014, 07:35

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by whitestrake »

Note for using filebot.launcher to prevent cmd from stealing focus

Due to a quirk in Qt for Windows, calling the script using filebot.launcher instead of filebot will not function correctly in qBittorrent. To counter this, use filebot.launcher.exe instead, like so:

Code: Select all

filebot.launcher.exe -script fn:amc --output "X:/path/to/media" --log-file amc.log --action copy --conflict override -non-strict --def music=y subtitles=en artwork=y excludeList=amc.txt "%f"
Chunkeebee
Posts: 4
Joined: 05 Sep 2014, 01:07

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by Chunkeebee »

Are we able to set absolute paths and naming conventions similar to uTorrent in --def?
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

It's always the same cmdline tool, so yes.
:idea: Please read the FAQ and How to Request Help.
Chunkeebee
Posts: 4
Joined: 05 Sep 2014, 01:07

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by Chunkeebee »

Having some dramas with this working nicely at the moment.
I loaded some 20 episodes last night through qbittorrent and only 3 were moved to the correct directory.

I am using Win 8.1 in a network situation. I am using my own P.C to run qbittorrent which loads the files onto my HTPC/Plex server directly. That runs flawlessy.

I would then usually just drag to whole directory into filebot and let it do its thing.

This morning I changed "filebot" to "filebot.launcher.exe" and the one file that has completed since looks to have worked. Though it didn't --action move the file. It copied it and left the download in its staging directory.

I haven't been able to use absolute paths yet. I usually use different drives in my server for movies or TV shows or music. Though it was just as easy to replicate the same files structure (drive://movies, drive://TV shows, drive://music) across all drives and just point the script and the drive with the most capacity.

Thoughts?

filebot.launcher.exe -script fn:amc --output "X:" --log-file amc.log --action move --conflict override -non-strict --def music=y subtitles=en artwork=y exludeList=amc.txt "%f"

is what I am using right now, though I want my staging area to be clean after it has moved the file to the rightful drive.

Be gentle - even though I work in ICT I haven't done any scripting for a long long long time. Took me an hour to work out how to open a port and configure the qbittorrent remote android app to work external to my network yesterday. (They should seriously write a better guide to using it, more people would use it)
User avatar
whitestrake
Posts: 14
Joined: 26 Oct 2014, 07:35

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by whitestrake »

Hi Chunkeebee,

As a side effect of qbt only reliably passing the root torrents folder via %f, when your first torrent finishes, filebot will run amc on everything currently in your torrents folder, including incomplete files from other torrents.

As you may be aware files currently being downloaded in qbt give "file open in another program" when you try to move/delete them. Thus when your first torrent finishes, AMC catalogs your entire torrent list, attempts to move everything (as your action is set to ’move'), and fails on every file not already finished. They are then added to the exclude list, which stops them from being scanned and actioned again later, when they are finished.

My own solution has been to use action hardlink. It creates a special form of shortcut at the filesystem level that points to the actual file. The downside is that the torrents folder and the Plex media library must be on the same disk. The upside is that it not only works on uncompleted files, but the hard linked "copies" finish as the torrents do, you spend less processing and disk time actually copying bits from one end of your hard drive to the other, and you can then simply delete the completed torrents in qbt and tick the "delete files on disk" option, and your hardlink copies stay as the real deal. I highly suggest you read up on hard links if you are unsure what they are or why they act as they do.

Hope this helps a bit.
Chunkeebee
Posts: 4
Joined: 05 Sep 2014, 01:07

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by Chunkeebee »

Thank you.

I will revert back to copy. I am happy to delete my "completed" directory from my staging area. That is easy enough to do or even schedule. My torrents files are kept on another PC from my server - not that this is a major issue, I could probably install qbittorrent on the server and use the web ui to control it. Though I will use copy for now and see how that goes.
lospo
Posts: 24
Joined: 10 Apr 2015, 16:59

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by lospo »

Hi and good morning :D

Is it possible to configure the language for the renaming?
I am italian and i'd like to see the italian title.
By now with this script it convert the italian title of my film into the english/american version.

THANKS
User avatar
whitestrake
Posts: 14
Joined: 26 Oct 2014, 07:35

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by whitestrake »

Hi lopso,

That question isn't specific to qbittorrent so you might get better luck asking in a new forum thread.

I'm sorry I can't help you as I've never had to use amc in a language other than English. I don't even know if filebot supports that as the databases it matches against are in English and I don't know if they supply metadata in other languages. I've never looked.
lospo
Posts: 24
Joined: 10 Apr 2015, 16:59

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by lospo »

sorry, i thinked that was an AMC option, but here http://www.filebot.net/cli.html thell me the truth.

Simple add the "-- lang it" at the end.
User avatar
whitestrake
Posts: 14
Joined: 26 Oct 2014, 07:35

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by whitestrake »

Glad you were able to fix the issue.

If you have any other AMC questions, feel free to open another topic.
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

Have you considered adding ut_title to make the report title / email subject / message subject more meaningful?

Code: Select all

--def "ut_title=%n"
:idea: Please read the FAQ and How to Request Help.
lospo
Posts: 24
Joined: 10 Apr 2015, 16:59

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by lospo »

Another question (hope in the roght place this time)

Can i set to download two languages for the subs? something like:
(my english is not so good, i need the italian subs to understand :D)

Code: Select all

subtitles=en,it
lospo
Posts: 24
Joined: 10 Apr 2015, 16:59

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by lospo »

Someone know where can i find the AMC.txt (that one: "exludeList=amc.txt")?

edit: OS Windows 7
User avatar
alexander_q
Posts: 21
Joined: 19 Aug 2014, 02:02

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by alexander_q »

I use the following script with qbittorrent:
"C:/Program Files/FileBot/filebot.launcher.exe" -script fn:amc --output "S:" --log-file amc.log --action copy --conflict override -non-strict --def music=n artwork=n xbmc=192.168.20.3 pushbullet=############# clean=y unsorted=y reportError=y "seriesFormat=S:/_TV Shows/{n}/{'Season '+s}/{fn}" "movieFormat=S:/_Movies/{n} ({y})/{fn}" "%f"
When I check my filebot logs, and indeed when I see the pushbullet notifications, I can see that filebot is processing every file in the staging area every time a new file is downloaded. How can I prevent this?
User avatar
whitestrake
Posts: 14
Joined: 26 Oct 2014, 07:35

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by whitestrake »

Hi alexander_q,

qBittorrent is limited in that it does not create subdirectories for every torrent. It also doesn't pass the full filepath via "%f". This makes it impossible to effectively target AMC to the single torrent in question for every type of torrent. I mention this in a previous post.

Use the following code to stop AMC from matching the same file multiple times.

Code: Select all

--def excludeList=amc.txt
This code is documented in the main AMC guide.
Last edited by whitestrake on 16 Nov 2015, 06:47, edited 1 time in total.
thebestnumberis42
Posts: 11
Joined: 12 Aug 2015, 15:21

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by thebestnumberis42 »

whitestrake wrote:Hi alexander_q,

qBittorrent is limited in that it does not create subdirectories for every torrent. It also doesn't pass the full filepath via "%f". This makes it impossible to effectively target AMC to the single torrent in question for every type of torrent. I mention this in a previous post.

Use the following code to stop AMC from matching the same file multiple times.

Code: Select all

--def exludeList=amc.txt
This code is documented in the main AMC guide.
In your previous post, you commented based on the assumption of moving/deleting the originally downloaded file. What if I want to keep the original file instead and copy it to a new directory for processing. Would I presumably run into the same issue where an incomplete download is processed prematurely, added to the exclusion list and never processed again, leaving an incomplete copy in the target directory? I wasn't sure if the situation was the same. I will gladly do research on the topic, but you seemed more immediately familiar.

[edit] I ask because I can't use a hard link. Where I'm copying to and where the original file resides are on two different volumes.
User avatar
whitestrake
Posts: 14
Joined: 26 Oct 2014, 07:35

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by whitestrake »

I think that would work well, as long as you targeted FileBot at your folder you send your copies to. This would also avoid issues trying to copy/move a file currently in use by qbittorrent.

If you get qbt to copy the file to a new directory itself, and then call FileBot, you might be able to keep your FileBot call anonymized, but I'd double check what qbt passes to the script - the original file or the copy.
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

It's excludeList, not exludeList. Some of the examples here are wrong.
:idea: Please read the FAQ and How to Request Help.
User avatar
whitestrake
Posts: 14
Joined: 26 Oct 2014, 07:35

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by whitestrake »

Thanks for the heads up - my original guide was correct, but the example I provided further on has just been corrected.
dem61s
Power User
Posts: 5
Joined: 29 Oct 2015, 23:04

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by dem61s »

Popping in to point out that, for anyone who has updated to version 3.3.0 of qbittorrent, the list of available parameters has now been extended to:
  • %N: Torrent name
  • %L: Label
  • %F: Content path (same as root path for multifile torrent)
  • %R: Root path (first torrent subdirectory path)
  • %D: Save path
  • %C: Number of files
  • %Z: Torrent size (bytes)
  • %T: Current tracker
  • %I: Info hash
I would wager the label and path parameters ought to be useful to anyone trying to run filebot with the command line option.
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

I'm happy to update the default usage if you update for and test with the new parameter options.

Passing along the label to the amc script can be quite useful.
:idea: Please read the FAQ and How to Request Help.
joedo
Posts: 3
Joined: 01 Dec 2015, 00:05

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by joedo »

Hi there, am mostly a visitor here. My qBittorrent execute command stopped working with the 3.3 update... I have the following..

"C:/Program Files/FileBot/filebot.launcher.exe" -script fn:amc --output "R:/FB" --log-file amc.log --action copy --conflict auto -non-strict --def music=n artwork=n excludeList=amc.txt "ut_kind=multi" "ut_dir=%f" --def unsorted=y --def "seriesFormat=R:/FB/TV Shows/{n} - {s00e00} - {t}" "animeFormat=R:/FB/Anime/{fn}" "movieFormat=R:/FB/Movies/{n} ({y})" --def clean=y

Anything looking weird here? Did the update change anything that would break it? I set it up a while ago and can't entirely remember how it all works..

Any help would be much appreciated.
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

:idea: Please read the FAQ and How to Request Help.
joedo
Posts: 3
Joined: 01 Dec 2015, 00:05

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by joedo »

Sorry, did you want me to create a new thread? The title on this one already specifically covers the subject.. or were you pointing me to requirement of posting the log file? The log output is not getting written to... amc.txt hasn't been modified since before the 3.3 update.. as if qBittorrent doesn't run the .exe at all. There's nothing in the execution log on qbittorent.. and filebot never appears in task manager, so it's not getting that far anyway.

I have "C:/Program Files/FileBot/filebot.launcher.exe" at the start of the command.. is that correct? Tried it without quotation marks... though I don't think that will make a difference.

I've updated to the latest version of filebot.. I can load filebot from command prompt. It's there!

Not sure what to try next..
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

The variables changed, so %f is now %F and there's new ones as well. The command template changed, but even if you use the old one, filebot should still be called, so there should be logs. If there's no logs, then filebot is never started.

If something is not working, and you don't know why, but still use filebot.launcher.exe instead of filebot.exe, then really really shouldn't use filebot.launcher.exe in the first place, until you know what you're doing.
:idea: Please read the FAQ and How to Request Help.
joedo
Posts: 3
Joined: 01 Dec 2015, 00:05

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by joedo »

Sod this.. I've not got time to mess around trying to fix it. I've gone back to 3.2.5 and it's working fine. If it doesn't even execute filebot and, as I said, there's no mention of it failing at anything in the qbittorrent logs. No sign of java in task manager.. it's got to be a bug in 3.3.

I don't know what you are referring to regarding not using filebot.launcher.exe instead of filebot.exe... what's the difference? The UI isn't popping up.. is there a technical reason why I shouldn't use it? It's not difficult to edit either way.
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

filebot.exe is a Console application, filebot.launcher.exe is a GUI application.

If you see the Console, you know that it's called, and you'll see all the output. If you don't have a Console you will see nothing, you won't know if it's called, and you won't know when/where/how it failed.

qBittorrent doesn't log output of external commands, but if it did, using filebot.launcher.exe would also make that impossible.

Try something simple, like calling notepad, to confirm that the "run command" feature is working or not.
:idea: Please read the FAQ and How to Request Help.
dem61s
Power User
Posts: 5
Joined: 29 Oct 2015, 23:04

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by dem61s »

Sorry for taking so long to get back to you rednoah. I wanted to let my scripts run for a while before confirming whether or not I got things right. It may be a little late, but here it is anyway:

--def "ut_label=%L" "%F" has been working like a charm for me so far. --def "ut_dir=%F" "ut_kind=multi" "ut_label=%L" has been working just as well (leaving ut_file completely unspecified). I am not sure which of the two working alternatives is the most advisable.
Related side note: while %F would refer to the folder in previous versions, it now appends to the filename as well in the case of single file torrents, which AMC seems more than happy to handle. The heavy reliance on the exclude list for single file torrents described earlier in this topic should not be an issue anymore.

I would have toyed with ut_title=%N and/or whatever may be an appropriate equivalent for ut_state as well, but I am simply not quite sure what these parameters are intended to accomplish in the first place.

Reading through this topic, I would also point out that qbittorrent now comes with a warning that its parameters are case sensitive (and upper case: could that be your problem joedo?).

NB: All tests were done on qbittorrent 3.3.0 & Windows 7. If there are any additional scripts/tests to run on qbittorrent, I am happy to do so and provide whatever logs may be useful.



See a few useless examples below.

Code: Select all

Parameter: ut_label = ignore
Input: random episode from the Simpsons
Finished without processing any files
*read with Bart Simpson's voice* HAHAHA! He can't even find the most basic TV show now.

Code: Select all

Parameter: ut_label = TV Shows
Input: random episode from the Simpsons
Rename episodes using [TheTVDB]
Good boy...

Code: Select all

Parameter: ut_label = 
Input: random episode from the Simpsons
Rename episodes using [TheTVDB]
No 'TV' or 'Show' in the path either and you can still find it? Well done mate.

Code: Select all

Parameter: ut_label = Movies
Input: random episode from the Simpsons
Finished without processing any files
Wasn't there a Simpsons movie? I really expected something to get fucked up here...

Alright, let's play along:

Code: Select all

Parameter: ut_label = Dirty Movies
Input: random episode from the Simpsons
Rename episodes using [TheTVDB]
Well, that was an unexpected match. You've got a dirty mind my dear sir.


Conclusion: While AMC's log remained mostly clean while dealing with whatever creative tagging I could think of, some amount of dirtyness remained unavoidable since AMC insists on sticking its nose (or any other body part I would suppose) into any download tagged as a "Dirty Movie".

The only issues I have left merely seem to stem from my crappy scripting capabilities which fail at processing subtitles in the way I want them too. Nothing I can blame on either filebot or qbittorrent I am afraid.
ZeroByDivide
Posts: 172
Joined: 16 Dec 2014, 01:39

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by ZeroByDivide »

Dunno why this is happening for me but I recently updated filebot to the latest version (I'm running the portable version btw) but when ever I download a show/movie/anime/whatever, filebot never seems to work correctly anymore.

I'm currently running filebot 4.6.1
Qbittorrent 3.3.1

Every time I download a movie or tv show I always get this error -

Code: Select all

Run script [fn:amc] at [Tue Dec 08 11:07:09 CST 2015]
Parameter: subtitles = en
Parameter: deleteAfterExtract = y
Parameter: clean = y
Parameter: ut_title = Quantico.S01E10.HDTV.x264-LOL[ettv]
Parameter: ut_label = 
Parameter: ut_file = C:\Users\timta\Desktop\QBT\Quantico.S01E10.HDTV.x264-LOL[ettv]
Parameter: ut_dir = C:\Users\timta\Desktop\QBT\
MissingPropertyException: No such property: ut_kind for class: Script1
groovy.lang.MissingPropertyException: No such property: ut_kind for class: Script1
	at Script1.run(Script1.groovy:183)
	at net.filebot.cli.ScriptShell.evaluate(ScriptShell.java:61)
	at net.filebot.cli.ScriptShell.runScript(ScriptShell.java:82)
	at net.filebot.cli.ArgumentProcessor.process(ArgumentProcessor.java:114)
	at net.filebot.Main.main(Main.java:169)
Failure (°_°)
and this is how my script looks like inside of qbittorent -

Code: Select all

filebot -script fn:amc --output "C:/Users/timta/Videos" --log-file amc.log --conflict auto -non-strict --filter "age < 250" --def subtitles=en deleteAfterExtract=y clean=y "ut_title=%N" "ut_label=%L" "ut_file=%F" "ut_dir=%D"
The same code was working before I updated to the latest version of filebot but even doing a downgrade doesn't fix it..
now the thing is I dunno where it's pulling this whole ut_kind thing out of since I don't have it in my code since qbittorent doesn't support ut_kind at all. I've tried downgrading both qbittorent and filebot to earlier versions already to see if that would fix it but to no avail at all :( so I'm currently lost on what the issue could be, hopefully someone can help me out with what the issue is.
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

1.
If my call says --def ut_kind=multi and works... but your call doesn't and fails with an error regarding ut_kind... I'm sure you'll figure it out. ;)

@see viewtopic.php?f=4&t=215#p9774


2.
Apparently %F is the a file/folder the downloaded files, whereas %D is the downloads folder that contains everything:

Code: Select all

Parameter: ut_file = C:\Users\timta\Desktop\QBT\Quantico.S01E10.HDTV.x264-LOL[ettv]
Parameter: ut_dir = C:\Users\timta\Desktop\QBT\
Is there any particular reason why you don't stick to the recommended usage?

Code: Select all

"ut_dir=%F" "ut_kind=multi" "ut_title=%N" "ut_label=%L"
@see viewtopic.php?f=4&t=215#p9774
:idea: Please read the FAQ and How to Request Help.
ZeroByDivide
Posts: 172
Joined: 16 Dec 2014, 01:39

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by ZeroByDivide »

Well I didn't think ut_kind was needed since it always worked before without it, it just recently stopped working once I did the update to filebot from 4.6 to 4.6.1 .. as for the second thing I don't really have an answer for that, was just an extra I added in on accident.

anyways that looks to have fixed it though.. dunno why it worked before without ut_kind and now it doesn't work unless it has ut_kind...
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

ut_kind is needed if both ut_dir and ut_file is specified

PS: make sure you're not accidentally processing your entire downloads folder over and over ;)
:idea: Please read the FAQ and How to Request Help.
ZeroByDivide
Posts: 172
Joined: 16 Dec 2014, 01:39

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by ZeroByDivide »

Ah well that would explain my problem then xD and haha I'm not processing my entire downloads folder over and over, always goes through the folder for the torrent download and that's it after it renames and moves the file to the correct place and deletes left over files the script stops like it should.
thebestnumberis42
Posts: 11
Joined: 12 Aug 2015, 15:21

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by thebestnumberis42 »

Just FYI for those who updated to qBittorent 3.3.5, a length limit was accidentally imposed on the external command length. See github comment: https://github.com/qbittorrent/qBittorrent/issues/5399

Most likely this means your downloads aren't being processed by the AMC script. It looks like it's being fixed, but if you happen to get the following error in your qBittorrent log, that's why.

Code: Select all

run external program command too long (length > 260), execution failed.
@rednoah - Thank you for creating and supporting a fantastic piece of software. I never realized how much I relied on it until it wasn't there / being used. I tried donating 3 times just now but PP is being difficult. I'll keep trying until you get the donation.
[edit] fourth time's a charm. Thank you.
cowrecked
Posts: 1
Joined: 22 Jun 2016, 05:01

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by cowrecked »

Just FYI for those who updated to qBittorent 3.3.5, a length limit was accidentally imposed on the external command length. See github comment: https://github.com/qbittorrent/qBittorrent/issues/5399

Most likely this means your downloads aren't being processed by the AMC script. It looks like it's being fixed, but if you happen to get the following error in your qBittorrent log, that's why.
OK, glad it wasn't just me. I just spent the last hour or so trying to figure out why amc wasn't working anymore. I finally got it working by reverting back to qBittorrent 3.3.3.

Also, obligatory thank you to rednoah, donation sent your way as well!
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

1.
Use @file syntax to pass command-line arguments (e.g. lengthy format expressions) via external text files:
viewtopic.php?f=3&t=3244


2.
I never realized how much I relied on it until it wasn't there / being used
I guess that's the definition of successful technologies: become invisible and taken for granted :lol:
:idea: Please read the FAQ and How to Request Help.
filebotuser
Posts: 1
Joined: 22 Jun 2016, 13:22

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by filebotuser »

rednoah wrote:1.
Use @file syntax to pass command-line arguments (e.g. lengthy format expressions) via external text files:
viewtopic.php?f=3&t=3244
Could someone possibly give an example of this? I'm having trouble understanding what I need to do to set this up. I'm trying to use these arguments to process files.

Code: Select all

"C:/Program Files/FileBot/filebot.launcher.exe" -script fn:amc --output "D:/Windows Related/Videos" --log-file amc.log --action copy --conflict override -non-strict --def music=y artwork=n clean=y deleteAfterExtract=y excludeList=amc.txt "ut_dir=%F" "ut_kind=multi" "ut_title=%N"
Thanks for your time.
thebestnumberis42
Posts: 11
Joined: 12 Aug 2015, 15:21

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by thebestnumberis42 »

filebotuser wrote: Could someone possibly give an example of this? I'm having trouble understanding what I need to do to set this up. I'm trying to use these arguments to process files.
My guess is your command would be something like:

Code: Select all

"C:/Program Files/FileBot/filebot.launcher.exe" -script fn:amc --output "D:/Windows Related/Videos" --log-file amc.log --action copy --conflict override -non-strict --def @"D:/arguments.txt"
And your arguments.txt file would maybe be:

Code: Select all

music=y
artwork=n 
clean=y
deleteAfterExtract=y 
excludeList=amc.txt
"ut_dir=%F"
"ut_kind=multi"
"ut_title=%N"
Based on your command it sounds like you're running windows. In rednoah's link the comments say to not use a windows program to edit the text file. I would recommend notepad++. It should let you create a text file with relevant encoding (CP1252) and no extra invisible characters.
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

qBT won't be able to replace the %variables if you do it like that though...

It'll look more like this:

Code: Select all

filebot @/path/to/args.txt --def "ut_dir=%F" "ut_kind=multi" "ut_title=%N"
:idea: Please read the FAQ and How to Request Help.
thebestnumberis42
Posts: 11
Joined: 12 Aug 2015, 15:21

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by thebestnumberis42 »

rednoah wrote:qBT won't be able to replace the %variables if you do it like that though...
Thanks for the correction. qBT properly parses the command now, I didn't know I could move everything but the %variables to the args.txt file. Thanks for the great tip. Unfortunately the command still fails, since with both %F and %N the command is still longer than 260 characters. My torrent names just happen to be too damn long.

I presumably need both "ut_dir=%F and "ut_title=%N" for filebot to process correctly, right? Would I be able to get by with just "ut_dir=%F" since %F also appends the file name or does Filebot need both ut_dir and ut_title to function properly?
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

You might be able to get away with not passing in ut_title.
:idea: Please read the FAQ and How to Request Help.
thebestnumberis42
Posts: 11
Joined: 12 Aug 2015, 15:21

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by thebestnumberis42 »

@rednoah - If I should start a new thread to not hijack this one, please let me know and I'll do it.

I'm not sure if removing ut_title worked or not. I tried both with and without both ut_title and ut_dir but FileBot wasn't being called from qBT. Checked both FileBot and qBT logs but no external command call. I downgraded to qBT 3.3.4 and then 3.3.3 each time trying a combination of different commands, but still no FileBot call. Frustrated, I tried your tip to use cmd and fill in qBT's variables to see wtf is going on. This is what I got.

Code: Select all

Error during startup: The filename, directory name, or volume label syntax is incorrect
java.io.IOException: The filename, directory name, or volume label syntax is incorrect
        at net.filebot.Main.initializeLogging(Main.java:397)
        at net.filebot.Main.main(Main.java:106)
Launch4j: Failed to run the given command.
I'm running windows java 8.0.910.14, FileBot version 4.7.

The file name looks right, from your tutorial. Same with the directory name and volume label syntax. The %variables have the correct slash direction "\" as qBT would output, and I'm using the correct slash direction "/" from your tutorial for the program call. I tried used launcher and platform.launcher exe's in CMD but only the regular exe outputted the error.

I must be missing something obvious. Does anything jump out at you (besides that I'm using Windows)? I'd really appreciate the advice.

Here's my external command and args.txt:

Code: Select all

"C:/Program Files/FileBot/filebot.launcher.exe" @"K:/args.txt" --def "ut_dir=%F" "ut_kind=multi" "ut_title=%N"

Code: Select all

-script fn:amc
--output "Z:"
--log-file "K:/amc.log"
--action copy
...
Last edited by thebestnumberis42 on 26 Jun 2016, 03:58, edited 1 time in total.
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

1 line = 1 argument

Code: Select all

-script
fn:amc
--output
Z:
--log-file
K:/amc.log
...
Use -script fn:sysenv to see the argument array you're passing in, and see if it makes sense.
:idea: Please read the FAQ and How to Request Help.
thebestnumberis42
Posts: 11
Joined: 12 Aug 2015, 15:21

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by thebestnumberis42 »

Thanks for the tip rednoah - I finally got it working. FYI to others trying to use an arguments text file, make sure there's no extra white spaces anywhere, especially at the end of commands. Was hunting awhile for my syntax error until I found the damn white space.

Unfortunately I still had to downgrade qBT to 3.3.3, since even with the args txt file, the external command was too long for 3.3.5. I'll upgrade once they fix the problem, but at least now I know how the arg txt file formats work.

Here's my final command and arg txt file in case anyone wants to reference it. Thanks again rednoah.

external command

Code: Select all

"C:/Program Files/FileBot/filebot.launcher.exe" @"K:/args.txt" --def "ut_dir=%F" "ut_kind=multi" "ut_title=%N"
args.txt

Code: Select all

-script
fn:amc
--output
Z:
--log-file
K:/amc.log
--action
copy
--conflict
override
-non-strict
--def
music=n
artwork=n
reportError=y
pushover=***
seriesFormat=X:/TV/{n}/{'Season '+s}/{n} - {sxe} - {t}
movieFormat=Z:/Movies/{n} ({y})/{n} ({y})
excludeList=K:/amc.txt
benzoto
Posts: 12
Joined: 04 Oct 2016, 09:50

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by benzoto »

Hi All,

First I would like to thank for this Topic. I would like to create the Automated Media Center using Filebot and qBittorrent. The current setup that i have is as follows:

Qbit is downloading all torrents to a folder on a NAS called Z:/Downloads (obviously local drive) :)
Airvideo HD Server is running using this Z:/Downloads location as a source of the video files. No other files besides TV Shows and Movies are being downloaded in this folder.

My question would be:
- What would be the script to run if I want the FileBot just to run through the new downloaded files and download subtitles for them, without renaming, copying, moving or any other action to be performed for those video files.

I've tried few times to set it up and I experienced the following issues

- Not always the subtitles are downloaded - Bulgarian and English - using this command - subtitles=en, bg
- It ran through the Download Location and reorganize my files - Create new folder structure for the Movies/TV Shows, Rename the actual video file

I would appreciate your support and I'm looking forward for your reply.

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

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

* The amc script is about organizing your files. If you don't want to organize your files you can't use the amc script
* Subtitles are not always available (especially for uncommon languages like Bulgarian)

Please read: viewtopic.php?t=5#p8871
:idea: Please read the FAQ and How to Request Help.
benzoto
Posts: 12
Joined: 04 Oct 2016, 09:50

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by benzoto »

Hi,

Thank you for the reply.

So I would not need the AMC script, the thing that I would need to set the Fetch subtitles as per the other thread. Could you please just confirm if the script would look like this, having in mind my Home Setup?

filebot -script fn:suball Z:/Downloads --lang en,bg -non-strict --def maxAgeDays=3

And one more thing, do I add it still in the "Run external program on torrent completion" or I would need to set it as a Scheduled Task or automated CMD script. I know that sometimes Bulgarian subtitles might not be available, that's why i would like to check for both languages - BG and EN.
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

1. Open CMD
2. Run the command
3. Read at the output and see if it's doing what you want it to do

You'll probably wanna add --log-file suball.log just in case.
:idea: Please read the FAQ and How to Request Help.
benzoto
Posts: 12
Joined: 04 Oct 2016, 09:50

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by benzoto »

I've ran the following script using CMD as Administrator and CMD advised it is COMPLETED.

filebot -script fn:suball Z:\Downloads -non-strict --lang en,bg --def maxAgeDays=7 --log-file suball.log

However no subtitles were downloaded. The Logfile shows the following info:

Done ヾ(@⌒ー⌒@)ノ

Done ヾ(@⌒ー⌒@)ノ

Done ヾ(@⌒ー⌒@)ノ

Done ヾ(@⌒ー⌒@)ノ

Done ヾ(@⌒ー⌒@)ノ

I'm not sure where the issue is. I've also tried with filebot.launcher.exe but with this nothing happened even the log file was not filled with details.
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

1.
Why would you run it as Administrator?

2.
The output indicates that you're not passing in any files. Maybe Z:\Downloads is empty. Maybe Z:\Downloads appears empty to the filebot process due to permissions. If subtitles are downloaded, or if files are ignored, then the log will clearly indicate that.

3.
Do not use filebot.launcher.exe unless you know what you're doing: viewtopic.php?f=3&t=1961
:idea: Please read the FAQ and How to Request Help.
benzoto
Posts: 12
Joined: 04 Oct 2016, 09:50

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by benzoto »

Yeah, it seems the issue with the script was running it as Admin. Now it ran however it is requesting for Opensubtitles Login details - error below

OpenSubtitles: Please enter your login details by calling `filebot -script fn:configure`

Would you be able to help me combine the two scripts? Is this even possible.

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

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

Is this message not clear?

Code: Select all

OpenSubtitles: Please enter your login details by calling `filebot -script fn:configure`

1. Open CMD
2. Run this command and follow the instructions:

Code: Select all

filebot -script fn:configure
You only have to enter you login details once.
:idea: Please read the FAQ and How to Request Help.
benzoto
Posts: 12
Joined: 04 Oct 2016, 09:50

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by benzoto »

It is pretty clear indeed, however if an automation has to be created is there a way to combine the scripts.

I've ran the comment and typed the Login Details and all is OK, subs are downloaded for most of the files. What i'm trying to understand if those two scripts can be combined and how the fn:configure script will look so that it can log me in without ME typing the username and the password but somehow embed those within the script.

If those can't be combined i can create two scripts - first to log me in and second to run through the files, but I'm aiming to fully automated solution :)
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

1.
You need to manually call configure once per user. ONCE. Not every single time you call suball. Only ONCE. So unless you're automating the whole filebot install & setup I don't see your problem.

2.
Then you can call suball whenever you want.
:idea: Please read the FAQ and How to Request Help.
benzoto
Posts: 12
Joined: 04 Oct 2016, 09:50

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by benzoto »

Hi, thank you for the reply.

So I assume once would mean once per PC session, in case of a reboot or sort of event this has to happen again, meaning that the automation is failing.

Any suggestions on that?
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

benzoto wrote:So I assume once would mean once per PC session, in case of a reboot or sort of event this has to happen again
No, that'd be stupid.
:idea: Please read the FAQ and How to Request Help.
benzoto
Posts: 12
Joined: 04 Oct 2016, 09:50

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by benzoto »

So this would be stupid however is the reality. I've just restarted the PC that i've setup the suball script, i've downloaded new file and once again the script is requesting to run the fn:configure command to login in OpenSubtitles.

This is what i've expected as well so not sure how this sounded strange.

Any advises on that?

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

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

When you enter your login details FileBot will store them in the Windows registry for your current user. So unless you delete registry entries or log in as a different user (or run as different user!) these settings will not (and could not possibly) be affected by a reboot.
:idea: Please read the FAQ and How to Request Help.
benzoto
Posts: 12
Joined: 04 Oct 2016, 09:50

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by benzoto »

Thx a lot rednoah, you really helped me a lot.
Vanarchy
Posts: 15
Joined: 23 May 2017, 12:30

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by Vanarchy »

Hi quick update - I still cant get filebot to autolaunch with Qbitorrent.

Everything is fresh install from two days ago.
(I had that 4k issue and another "file exists already" error which no long are problems now lol)

The filebot program doesnt appear to even visibly launch at completion of torrents. Filebot works fine as standalone doing one movie at a time but is not launching from qbitorrent.

Im guessing it's something easy Im missing. (I used to use filebot all the time for years no problems, it was about 6 months ago it just stopped autolaunching from qbitorrent. I was having all kinds of problems after reinstalling things and tinkering for over a month to get it working again so I decided fresh install for everything).


System:
Filebot from Windows Store
Windows 10 (64) Creators Update = Just fresh installed new OS
Java (64) (latest version as of the other day)
Qbittorent download folder is : H:/downloads



script=

Code: Select all

filebot -script fn:amc --output "H:" --log-file amc.log --action copy --conflict override -non-strict --def music=y subtitles=en artwork=y excludeList=amc.txt "%f"

amc.log=

Code: Select all

Illegal Argument: java.nio.file.NoSuchFileException: C:\Program Files (x86)\Google\Chrome\Application\59.0.3071.115\%f (%f)
Run script [fn:amc] at [Sun Jul 09 12:39:56 PDT 2017]
Parameter: music = y
Parameter: subtitles = en
Parameter: artwork = y
Parameter: excludeList = amc.txt
Argument[0]: File does not exist: %f
Use excludes: H:\amc.txt (5695)
No files selected for processing
Done ヾ(@⌒ー⌒@)ノ
Illegal Argument: java.nio.file.NoSuchFileException: C:\Windows\system32\%f (%f)
Run script [fn:amc] at [Sun Jul 09 17:08:32 CDT 2017]
Parameter: music = y
Parameter: subtitles = en
Parameter: artwork = y
Parameter: excludeList = amc.txt
Argument[0]: File does not exist: %f
Use excludes: H:\amc.txt (5695)
No files selected for processing
Done ヾ(@⌒ー⌒@)ノ


Any insight is appreciated ;)
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

I'd recommend using the utorrent-postprocess.pyw script to glue qBT and FileBot together:
viewtopic.php?f=4&t=5157

You'll also want to read the Troubleshooting section of the amc script, because your way of testing if it's working couldn't possibly work. ;)
:idea: Please read the FAQ and How to Request Help.
Vanarchy
Posts: 15
Joined: 23 May 2017, 12:30

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by Vanarchy »

Im not sure how to use python or any of that - it doesnt seem like a normal thing to get involved with. Im just a layperson, dont really know anything about codes.

Shouldnt I just be able to use that script above inside qbitorrent (run external program after torrent completion), that's where I put it but it's not launching after torrent.
I mean this: filebot -script fn:amc --output "H:" --log-file amc.log --action copy --conflict override -non-strict --def music=y subtitles=en artwork=y excludeList=amc.txt "%f"



I figured after reinstalling windows, java, and getting filebot from windows store all would be good. Im not clear on why it wouldnt just launch at the completion of a torrent.
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

1.
Yes, but if it doesn't work out of the box, then you will need basic CMD skills to diagnose the problem. Depending on what you're doing, using python to call FileBot will make diagnosing problems much easier, because your customizations (if any) will be in the python script, and not in the qBT command template, making it easier to test from CMD.


2.
One obvious problem is that newer versions of qBT use %VARIABLE names similar to uT. So qBT won't replace %f with the actual file path. Newer versions use %F (case matters) and add additional variables.

I highly recommend following the instructions here which do work with newer versions of qBT out of the box:
viewtopic.php?f=4&t=5157

There is zero coding involved. Just editing a text file. Just like editing the qBT settings text field. Nothing more. ;)
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

Vanarchy wrote:11 Jul 2017, 12:10 "Fetch the utorrent-postprocess.pyw python script and modify it to your needs:"

Ive been all over that page for a half hour and there's no download link for that pyw file. It's unclear how to use this. Copy and paste it to a notepad and rename it to something? If it's an exe I dont see a download link, and dont even know where to put it (i did try searching)
I install python 3.x (it's 32 bit btw) and there is no GUI at all. It's all cmd window stuff.

I went on youtube and couldnt find instruction I need , also used google search which brings up a bunch of Jetbrain stuff.

I think Im going to just try utorrent, this is turning out to be a bit much. It's like going down a long rabbit hole lol
1. Click on utorrent-postprocess.pyw
2. Click Raw to go to the raw text file, right-click, Save as... and save the file somewhere. Alternatively, you can also create a new text file and copy & paste the code.
3. Open the file with a text editor and change X:/Media to your output folder.

(Optional) 4. Start CMD and test your postprocess script without qBT first. You didn't do that last time you set up filebot, so maybe you get lucky again.
:idea: Please read the FAQ and How to Request Help.
Vanarchy
Posts: 15
Joined: 23 May 2017, 12:30

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by Vanarchy »

Hi, I saved the file to my downloads file for convenience. So when I open a CMD window it is H:\downloads>>

Then I opened cmd window and ran a test file but nothing happened.

I typed in: utorrent-postprocess.pyw test.mkv

Apparently there is a LOT to learn just getting this to autorun from qbittorent. In the morning I'll try uTorrent and see if that's easier.
Vanarchy
Posts: 15
Joined: 23 May 2017, 12:30

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by Vanarchy »

Filebot works perfect with uTorrent right out of the box. :-D

(I needed python anyway to run Plexpy, so that works out too).

Thanks for all your help.
User avatar
rednoah
The Source
Posts: 24665
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

The usage is documented with examples at the beginning of the script. The script will expect the correct number of arguments in the correct order.

e.g.

Code: Select all

python "C:\path\to\utorrent-postprocess.pyw" "Movie" "5" "Avatar" "multi" "" "X:\Files\Avatar"
:idea: Please read the FAQ and How to Request Help.
tip2tail
Posts: 2
Joined: 16 Jul 2017, 18:56

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by tip2tail »

Hello all,

First off - what a fantastic tool FileBot is! It has made my life so much easier when it comes to renaming and organising my media.

I use qBittorrent and followed the guide on this forum successfully, however I ran into one slight issue. A quirk on the Windows version of qBittorrent means that it sometimes does not release a handle/file lock on downloaded media. This prevents the AMC script/FileBot from moving the media to it's intended destination.

To circumvent this, I have written a batch file script that will do the following:
  • Terminate the running qBittorrent process
  • Execute the AMC script on the newly downloaded media
  • Restart qBittotrrent
I thought that this may be helpful for anyone else suffering from the same issues. As such I have uploaded it to GitHub and make it freely available.

Hope this is of interest...
https://gist.github.com/tip2tail/4be77c ... 7df2997600

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

Re: [GUIDE] Fully Automated Media Center with qBittorrent

Post by rednoah »

qBT is not supposed to release files because it's supposed to keep seeding them. All amc script examples use --action duplicate for that reason, so that your torrent client can keep seeding, because leeching without seeding is not cool. ;)
:idea: Please read the FAQ and How to Request Help.
Post Reply