Read on if you dare. Or, perhaps more accurately, if you have time to waste.
After Action Report: Setting up AMC in qbittorrent
A story of pain and hurt, loosely based on reality
System requirements
Why would anybody even start such a journey? Masochistic tendencies aside, the basic ingredients are as follows, in summary:
- Step 1: Contract an addiction to TV shows.
- Step 2: Get fed up with utorrent and use qbittorrent as your primary means for feeding your addiction.
- Step 3: While rss feeds work well enough to automate downloads, using your download client as a media manager should get old very quickly. Especially if you make a habit of renaming every file manually.
- Step 4: Install a plex server and try using Sonarr and CouchPotato to the media managing (and possibly replace the way you feed torrent to your download client).
- Step 5: Run into into all kinds of hell because of their lack of support for qbittorrent (for Sonarr) and possibly being a little green at handling torrents as well (especially CouchPotato)
- Step 6: Come to the conclusion that the downloading part was working just fine so far and that what you actually need is the merely the renaming / metadata fetching part of the system.

Henceforth, you shall be known as...
As far as I can remember, I have always loved naming stuff. It started with giving clever nicknames to my friends. I would usually realize later that many of those nicknames were not so clever after all. It never stopped me from going on. This is the nature of naming things after all.
Some will be perfectly content using one's given name. I am not. The same principle applies to my media. I name them.
For movies, it always seemed like a good starting place was:
Media/Movies/<title> (<year>) [<tags>]/<title> (<year>).<ext>
One is always entitled to have strong opinions on what would constitute a tag, of course. One is also welcome to change his mind over time on the issue, and to hold his new opinion as strongly as the previous one, of course. I have currently taken the view that keeping them to a minimum was advisable. Considering that the release group almost always provided me with enough information about the encoding, I elected to use it. I would merely add a secondary information allowing me to differentiate between the different releases of the same group. Incidentally, my preference would be that this addition had the approval of whatever person (friend or foe) may come across my media library to avoid unwelcome conversations about my naming habits. That is how I settled for the following tags:
[<1080p/720p/480p>,<release group>]
Mr. filebot was kind enough to provide a few examples about the way things could work out. It seemed that the proper way to go would be:
Code: Select all
[{vf},{group}]
Little did I know that this was only the beginning of my headaches. After my earlier experience with missing fields, I was not about to settle for a naming convention that would not be appropriate should any number of fields remain missing. This quest proved very painful. I grew accustomed to [], [,], [<insert random and extremely unhelpful error message>]. I was not quite ready to abandon though and after much perusing on those boards, I finally came up with:
Code: Select all
{allOf{vf}{group} ? " [" + allOf{vf}{group}.join(",") + "]" : ""}
At this stage, an incredible idea struck me: why did I not use this helpful allOf all along, for the other parts of the name as well? And I do mean all of them. I could not find any good answer to this question. Therefore, I settled on the following movie naming scheme:
Code: Select all
{allOf
{"Movies"}
{allOf
{n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’?]/, "'")}
{" (" + y + ")"}
{allOf{vf}{group} ? " [" + allOf{vf}{group}.join(",") + "]" : ""}
.join()}
{allOf
{n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’?]/, "'")} {"(" + y + ")"}
{"CD"+pi}
{lang}
.join(" ")}
.join("/")}
Code: Select all
{allOf
{"TV Shows"}
{n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’?]/, "'")}
{allOf
{n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’?]/, "'")}
{episode.special ? "Specials" : "s"+s.pad(2)}
.join(" - ")}
{allOf
{n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’?]/, "'")}
{episode.special ? airdate : s00e00.lower()}
{t.replaceAll(/[`´‘’?]/, "'").replaceAll(/[!?.]+$/).replacePart(", Part $1")}
.join(" - ")}
.join("/")}
Getting acquainted with Mr. AMC
As a matter of principles, it seemed fairly obvious though that allowing Mr. AMC to blindly rename everything was not going to be an agreeable proposal. He would only be allowed to toy with those torrents that were tagged as either movies or TV shows. Unfortunately, I soon found out that Mr. qbittorrent would not provide me with this kind of information. He can be a bit of a asshole at times... Since he does allow sorting downloads neatly in folders that match their tags, I would have to parse the information required from the file path.
Now ready to name names, it was time for me to have a chat with Mr. AMC. So I started reading up on him. Little known facts about him include:
- Despite claims to the contrary (made by a shity character), tagging files is not the only way to force Mr. AMC into a certain mode (Movies/TV Shows). Mr. AMC is just as attentive to what is in the file path. This detail has its importance (and added benefits) when dealing with Mr. qbittorrent who will append tags to the path but not disclose them out loud.
- Mr. AMC will talk to Mr. MyEpisodes.com it would seem, but not to Mr. Trackt.tv. That is unusual these days. Not to worry about though. Mr. Trackt.tv has become kind of a 2.0 jerk in recent times I am afraid.
- After much syntaxic battling with Mr. AMC, I found out that --filter, when not returning an error, would not filter out input files but would rather filter out search results. That was an unfortunate amount of headaches for very little results.
Escaping
Far from being discouraged by Mr. AMC's grab for power, I decided that the best course of action would to show him the middle finger and I decided to find a way to only call him when I wanted. And that is how I ended up contacting Mr. batch. Unfortunately, he talks an awful language that I have trouble understanding. With a whole lot of efforts, we finally managed to understand each other. The most irritating thing with this Mr. batch is that he would only engage in a conversation if I agreed to escape. All the fucking time. Escaping is pretty much all I did actually. Here is how the conversation finally went:
Code: Select all
:: Runs filebot on completion of a download in qbittorrent
:: intended to be launched as qb_run_on_completion.bat %f within qbittorrent
@ECHO OFF
^
SET TV_SHOWs="TV Shows"
SET MOVIES="Movies"
:: Remove TV Shows and Movies from the path supplied in %1
SET REMOVE_TV_SHOWS=%~1:TV_SHOWS=%
SET REMOVE_MOVIES=%REMOVE_TV_SHOWS:MOVIES=%
^
:: If something has been removed, we are either in the TV Shows or Movies subfolders
:: So we can run filebot
IF NOT REMOVE_MOVIES == %~1 (
^
filebot.launcher.exe ^
^
-script fn:amc ^
--output "D:/Media" ^
--log-file "D:/Thomas/Downloads/Torrents/amc.log" ^
--action hardlink ^
--conflict auto ^
-non-strict ^
^
--def "seriesFormat= {allOf {\"TV Shows\"} {n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’?]/, \"'\")} {allOf {n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’?]/, \"'\")} {episode.special ? \"Specials\" : \"s\"+s.pad(2)} .join(\" - \")} {allOf {n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’?]/, \"'\")} {episode.special ? airdate : s00e00.lower()} {t.replaceAll(/[`´‘’?]/, \"'\").replaceAll(/[!?.]+$/).replacePart(\", Part \$1\")} .join(\" - \")} .join(\"/\")}" ^
^
--def "movieFormat= {allOf {\"Movies\"} {allOf {n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’?]/, \"'\")} {\" (\" + y + \")\"} {allOf{vf}{group} ? \" [\" + allOf{vf}{group}.join(\",\") + \"]\" : \"\"} .join()} {allOf {n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’?]/, \"'\")} {\"(\" + y + \")\"} {\"CD\"+pi}{lang} .join(\" \")} .join(\"/\")}" ^
^
--def music=n ^
--def plex=localhost:SbeBJk7L8joGmnaVfeWX ^
--def exludeList="D:/Thomas/Downloads/Torrents/amc.txt" ^
--def "%~1"
)
Onward
While my account of this adventure will seem a bit odd, it will pale in comparison with this: after so much effort, I only ever tried --action test...
Any story about naming and processing meta data and/or subtitles for my entire library will have to await further adventures. I would rather not try and fetch them on a torrent completion. Any good script for that? Spotted any crappy scripting on my part? Please let me know. I may or may not be open to shifty suggestions.
:p