AMC: User-defined Filename to Series Mapping

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
lift
Posts: 5
Joined: 10 Sep 2014, 11:23

AMC: User-defined Filename to Series Mapping

Post by lift »

I really like how quick and easy FileBot is, EXCEPT when I had to resolve a series look-up conflict. The non-strict switch wasn't doing it for me since I got some false positives, so I decided to add a way to explicitly say what file name maps to what show without having to execute multiple runs of AMC.

New Usage Option:

Code: Select all

filebot --def mapfile=/path/to/mapfile.txt
The rest of the usage is the same as normal AMC.

https://github.com/jwyant/scripts/blob/devel/amc.groovy

Added new command-line switch - mapfile

Code: Select all

// user-defined show mapping
def fileMappings = tryQuietly{ csv(mapfile) }
Added logic to filter on show based on file-name for multiple entries in the same AMC pass.

Code: Select all

def dest = null
fileMappings.each{ fileMapping, showMapping ->
   if (dest == null) { dest = rename(file: files.findAll{ it =~ /(?i:\/${fileMapping})/}, query: "${showMapping}", format: config.format, db: config.db) }
}
// if it's still null (we've exhausted all exceptions), just do a normal match
 if (dest == null) { dest = rename(file: files, format: config.format, db: config.db) }
I'm unsure how well this works on Windows since I look for a beginning "/" before the actual filename to filter out mid-filename matches.



The mapfile format is "filter from the start of the filename";"TVDB Series Name"

Example mapfile:

Code: Select all

Louie;Louie (2010)
Top.Gear;Top Gear
I would certainly be nice if I could map directly to a specific tvdbid, but I have not figured that out yet. Also, I just started playing with Groovy as of yesterday, so please excuse any ugly code...
User avatar
rednoah
The Source
Posts: 23931
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: AMC: User-defined Filename to Series Mapping

Post by rednoah »

I'm not a fan of everyone starting their own alias lists so I'm managing these global mappings here:
http://www.filebot.net/forums/viewtopic.php?f=3&t=360

If you have files that don't get matched correctly just post the logs so I can fix it. Depending on why it doesn't work there's better solutions, that will work for other shows for all users.

EDIT: You can't force a TheTVDB ID during search because there is no use-case except for manual mappings
:idea: Please read the FAQ and How to Request Help.
lift
Posts: 5
Joined: 10 Sep 2014, 11:23

Re: AMC: User-defined Filename to Series Mapping

Post by lift »

Those mappings being global on your list make perfect sense for everyone to have, but for my automated set-up, I would prefer to run strict and eliminate duplicate look-ups. When I ran -non-strict against my files, it put episodes of Top Gear in Top Gear 1977, episodes of Doctor Who 2005 in Doctor Who 2009, and episodes of Louie in the UK Louie. If I was to go back and manually run -non-strict with a filter on all these, it defeats the point of my automation set-up. I'm only collecting one show that has "top.gear" in the file name, so I'll just make sure that those are all set to "Top Gear". I suppose I could run a --filter for "Top Gear" against all my files, but if I know they always have top.gear, why not only process those ones?

If there was some sort of whitelist or prioritization that a user could opt to maintain on their own (ex: always pick Top Gear over Top Gear 1977 if there are multiple query results). That would be fine too.
User avatar
rednoah
The Source
Posts: 23931
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: AMC: User-defined Filename to Series Mapping

Post by rednoah »

If I was you I'd do a few strict find | egrep | filebot -rename calls and once those tricky files are moved out of the way you can call just call the amc script on the rest.

With bash it's easy but on Windows you might wanna write that part in Groovy:
http://www.filebot.net/forums/viewtopic ... =280#p1135


If you prefer the whitelist approach then you can make a smart filter, i.e. in your filter expression check {n} against some file and then allow/disallow based on that. The only issue is that it'll fetch episode data and then discard it again if it doesn't match the filter.


EDIT:
If you're processing newly released episodes then you can simply do something like:

Code: Select all

--filter "age < 7"
That'll simply ignore any episode that has been released more than a week ago. Similarly named shows won't air at the same time, so this will be pretty reliable for weekly episodes.
:idea: Please read the FAQ and How to Request Help.
lift
Posts: 5
Joined: 10 Sep 2014, 11:23

Re: AMC: User-defined Filename to Series Mapping

Post by lift »

That filter should help out with the on-going shows.

I actually based my whole addition to amc.groovy off of that code snippet you linked in your reply. I'm just automating it a bit more with a list of the two arguments (file filter and series filter).
Post Reply