How to improve AniDB Absolute episode matching

All about user-defined episode / movie format expressions
Post Reply
rv23
Posts: 29
Joined: 19 Jul 2020, 15:05

How to improve AniDB Absolute episode matching

Post by rv23 »

For various reasons I am adding xattr (episode information) to a large number of files that have been verified/sorted/renamed using one of the AniDB clients.
The filename format is basically this:

English Series name - Episode#WithVersion - Episode Title [ReleaseGroup][Source][Resolution][Codec][CRC].extension

Several examples:

Code: Select all

Ahiru no Sora - 32 - Time Limit [FFA][www][1920x1080][HEVC][19BA5AAC].mkv
Somali and the Forest Spirit - 03 - The Sea at the Bottom of the Cave [Erai-raws][www][1280x720][h264][004A20E9].mkv
A Certain Scientific Railgun T - 03v2 - Balloon Hunter [Gremlin][www][1280x720][h264][2DB5BB94].mkv
Bofuri I Don't Want to Get Hurt, So I'll Max Out My Defense_ - 08 - Defense and Third Event [HR][www][1920x1080][HEVC][D54E0BFA].mkv
So I am slowly bumbling through creating a groovy script to add the xattr data to them by "renaming" them into a different directory by filebot and then moving them back.

The directory name includes the AniDB # so I can pass in a query on the title to match them ..

Code: Select all

rename(folder:directory, format: aniAddFormat, query: "${z}", order: 'Absolute', db: 'AniDB')
z being the ID # of the Series..

of the 1657 files I am currently testing with, after two passes (because sometimes another try seems to match a few more) I was only able to match 591 of them..

huh.. I was expecting a bit of a higher match ratio on strict considering .. the names are fairly close to what is in AniDB (I do strip out most control characters, so they don't 100% match on some episodes/series).

So I added some additional groovy to regex the episodes and do a non-strict match with a filter to the specific episode from the regex ..

Code: Select all

rename(file:xfiles, format: aniAddFormat, query: "${z}", filter: "absolute = ${x.toInteger()}", order: 'Absolute', db: 'AniDB', strict:false)
where xfiles is a list of the files, z is the ID # of the seires, and x is the episode #. I do switch to using special (vs absolute) when trying to match the normal specials ( I ignore S101/2 etc).

Which worked for most of them in the first pass, second pass is looking to finish it. But man, this is not very efficient, and I really think I'm pushing my luck on the ban hammer from AniDB.

So my question is .. What's wrong about the naming format I am using, and at least for future files is there some tweaking that I could do that would increase the episode match efficiency?

Code: Select all

FileBot 4.9.1 (r7372)
JNA Native: 6.1.0
MediaInfo: 19.09
7-Zip-JBinding: 9.20
Chromaprint: 1.4.3
Extended Attributes: OK
Unicode Filesystem: OK
Script Bundle: 2020-08-04 (r667)
Groovy: 3.0.3
JRE: OpenJDK Runtime Environment 14
JVM: 64-bit OpenJDK 64-Bit Server VM
CPU/MEM: 4 Core / 2.1 GB Max Memory / 33 MB Used Memory
OS: Windows Server 2019 (amd64)
STORAGE: NTFS [(C:)] @ 87 GB | NTFS [music] @ 24 TB | NTFS [pictures] @ 24 TB | NTFS [video] @ 24 TB | NTFS [multimedia] @ 24 TB | NTFS [animebt] @ 22 TB
DATA: C:\Users\vitki\AppData\Roaming\FileBot
Package: MSI
License: FileBot License xxx (Valid-Until: 2069-11-10)
Done ?(?????)?
User avatar
rednoah
The Source
Posts: 18826
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to improve AniDB Absolute episode matching

Post by rednoah »

Looks like -rename --q <ID> just doesn't work:

Code: Select all

filebot -rename *.mkv --db AniDB --q 13848 --action TEST
Rename episodes using [AniDB] with [Absolute Order]
Fetching episode data for [13848]
Failed to identify or process any files
I'll look into it.



EDIT:

Nevermind. It'll work, but it does require -non-strict for some reason, probably because strict mode checks for matching SxE patterns:

Code: Select all

$ filebot -rename *.mkv --db AniDB --q 13848 --action TEST -non-strict --log INFO
[TEST] from [Ahiru no Sora - 32 - Time Limit [FFA][www][1920x1080][HEVC][19BA5AAC].mkv] to [Ahiru no Sora - 32 - Time Limit.mkv]
If you're worried about non-strict matching, and have you files in order already, then linear list rename might be worth consideration:

Code: Select all

$ filebot -list --q 13848 -rename *.mkv --db AniDB --action TEST --log INFO
[TEST] from [Ahiru no Sora - 32 - Time Limit [FFA][www][1920x1080][HEVC][19BA5AAC].mkv] to [Ahiru no Sora - 01 - The Ugly Duckling.mkv]


EDIT 2:

As it turns out, the 1920x1080 pattern is what makes strict mode reject the match in this case. FileBot r7904 fixes this particular issue.



BONUS:

You just need to process your files once, and then you can use Local Xattr Mode to process files again and again offline:
viewtopic.php?t=2072

e.g.

Code: Select all

$ filebot -rename *.mkv --db xattr --action duplicate --format {plex}
Rename files using [Extended Attributes]
[DUPLICATE] from [Ahiru no Sora - 32 - Time Limit.mkv] to [Anime/Ahiru no Sora/Ahiru no Sora - 32 - Time Limit.mkv]
Processed 1 file
:idea: Please read the FAQ and How to Request Help.
rv23
Posts: 29
Joined: 19 Jul 2020, 15:05

Re: How to improve AniDB Absolute episode matching

Post by rv23 »

Is there a way to get *just* FileBot r7904 vs the latest beta? I tried to download r8004, however it totally doesn't like something I'm doing in the script (which works with r7829) ..

Code: Select all

startup failed:
Script1.groovy: 680: unexpected token: elseif @ line 680, column 7.
       } elseif (mod10 == 2 && mod100 != 12) {
         ^

1 error

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 680: unexpected token: elseif @ line 680, column 7.
       } elseif (mod10 == 2 && mod100 != 12) {
         ^

1 error

        at net.filebot.cli.ScriptShell.evaluate(Unknown Source)
        at net.filebot.cli.ScriptShell.runScript(Unknown Source)
        at net.filebot.cli.ArgumentProcessor.runScript(Unknown Source)
        at net.filebot.cli.ArgumentProcessor.run(Unknown Source)
        at net.filebot.Main.main(Unknown Source)

Error (o_O)
When I remove that offending code, did something change in the rename method? Because that blows up when I try to use it ..

Code: Select all

Did you read the manual?
└ https://www.filebot.net/cli.html

Did you quote and escape your arguments correctly?
└ https://www.filebot.net/help/args.html

args[1] = -script
args[2] = C:\Users\xxx\Desktop\scripts\anime-raw-sorter.groovy
args[3] = --action
args[4] = Move
args[5] = -rename
args[6] = -no-xattr
args[7] = --conflict
args[8] = index
args[9] = -r
args[10] = --def
args[11] = [email protected]:\Users\xxxx\Desktop\scripts\step_x_working_initialsort_officialamc.groovy
args[12] = minFileSize=10
args[13] = minLengthMS=5
args[14] = Z:\FB-1\anime
args[15] = --output
args[16] = Z:\1-InitialSort
args[17] = --log
args[18] = all

SyntaxError: end of line reached within a simple string 'x' or "x" or /x/;
   solution: for multi-line literals, use triple quotes '''x''' or """x""" or /x/ or $/x/$
Failure (?_?)??
This is what I have in the script to do the rename that fails ..

Code: Select all

def rfs = rename(file: files, format: animeFormat, query: "${anime}", order: "${group.order}", db: animeDB, strict:true)
User avatar
rednoah
The Source
Posts: 18826
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to improve AniDB Absolute episode matching

Post by rednoah »

Looks like a typo to me. It's else if and not elseif. Always has. Always will be.

e.g.

Code: Select all

if ( ... ) {
    ...
} else if (...) {
    ...
} else {
    ...
}
:arrow: https://groovy-lang.org/semantics.html#_if_else


This would be another unrelated syntax error, but I'd need to see the code to tell you what's wrong specifically. It's it's printing the argument list alongside the error message, I'd start looking at your --def animeFormat expression and not the script itself, which is never executed according to the console output.

Code: Select all

SyntaxError: end of line reached within a simple string 'x' or "x" or /x/;
   solution: for multi-line literals, use triple quotes '''x''' or """x""" or /x/ or $/x/$
:arrow: https://groovy-lang.org/syntax.html#all-strings


:!: Minor Groovy upgrades may change how Groovy interprets incorrect code though, so it's possible that code that was technically incorrect but somehow did something now correctly yields a syntax error.
:idea: Please read the FAQ and How to Request Help.
rv23
Posts: 29
Joined: 19 Jul 2020, 15:05

Re: How to improve AniDB Absolute episode matching

Post by rv23 »

Thanks, that helped.
It seems this part was having issues in the latest filebot ..

Code: Select all

  myShowSeason = "${ switch (myShowMonth) {
    case { myShowMonth.matches('0?[1-3]') }:
        return 'winter'
    case { myShowMonth.matches('0?[4-6]') }:
        return 'spring'
    case { myShowMonth.matches('0?[7-9]') }:
        return 'summer'
    case { myShowMonth.matches('10|11|12') }:
        return 'fall'
    default:
        return 'unknown'
    }}"
Switching it to this made the error go away ..

Code: Select all

  myShowSeason = """${ switch (myShowMonth) {
    case { myShowMonth.matches('0?[1-3]') }:
        return 'winter'
    case { myShowMonth.matches('0?[4-6]') }:
        return 'spring'
    case { myShowMonth.matches('0?[7-9]') }:
        return 'summer'
    case { myShowMonth.matches('10|11|12') }:
        return 'fall'
    default:
        return 'unknown'
    }}"""
Thank you for your help.
Post Reply