Gintama and AMC script

Any questions? Need some help?
jbsoum
Posts: 21
Joined: 01 Feb 2015, 16:27

Gintama and AMC script

Post by jbsoum »

So I've been using filebot to automatically rename my shows as they download via rss feeds, and it's been working pretty great!

There is, however, one show that never seems to get picked up: Gintama. I have a feeling it's because AniDB recognizes the new episodes as a new season, but the way it's downloaded, it's named as a continuation of the original series.

For example, the file would download as Gintama 266, but it's really episode 1 of the new season. I have a feeling nothing can be done about this, but I figured I would give asking a shot.

Thanks!
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Gintama and AMC script

Post by rednoah »

Logs? Expected results (with AniDB links plz)?
:idea: Please read the FAQ and How to Request Help.
jbsoum
Posts: 21
Joined: 01 Feb 2015, 16:27

Re: Gintama and AMC script

Post by jbsoum »

Here is the AniDB link to the episode the file below should have linked to.
http://anidb.net/perl-bin/animedb.pl?show=ep&eid=170188

As you can see, the file is labeled as episode 282, but AniDB recognizes it as episode 17 of Gintama (2015).

Here are the logs:

Code: Select all

Run script [fn:amc] at [Wed Jul 29 05:42:30 CDT 2015]
Parameter: music = y
Parameter: clean = y
Parameter: subtitles = en
Parameter: xbmc = 127.0.0.1
Parameter: seriesFormat = H:/TV2/{n}/{episode.special ? 'Special' : 'Season '+s}/{n} - {episode.special ? 'S00E'+special.pad(2) : s00e00} - {t}
Parameter: animeFormat = D:/Anime/{primarytitle}/{primarytitle} - {episode.special ? 'S00E'+special.pad(2) : s00e00} - {t}
Parameter: movieFormat = H:/Movies/{n} ({y})/{n} ({y}){' CD'+pi}{'.'+lang}
Parameter: musicFormat = H:/Music/{n}/{album+'/'}{pi.pad(2)+'. '}{artist} - {t}
Parameter: ut_label = BTN
Parameter: ut_state = 5
Parameter: ut_title = [HorribleSubs] Gintama - 282 [720p].mkv
Parameter: ut_kind = %K
Parameter: ut_file = [HorribleSubs] Gintama - 282 [720p].mkv
Parameter: ut_dir = H:\New Downloads\Finished Downloads
Input: H:\New Downloads\Finished Downloads\[HorribleSubs] Gintama - 282 [720p].mkv
Group: [anime:gintama] => [[HorribleSubs] Gintama - 282 [720p].mkv]
Rename episodes using [AniDB]
Auto-detected query: [Gintama]
Fetching episode data for [Gintama]
Fetching episode data for [Gintama']
Fetching episode data for [Gintama' (2012)]
Fetching episode data for [Gintama' (2014)]
Fetching episode data for [Gintama (2015)]
Jul 29, 2015 5:42:34 AM net.filebot.media.MediaDetection$7 getSizeValues
WARNING: Unable to read media info: Unable to load 32-bit native library 'mediainfo' [[HorribleSubs] Gintama - 282 [720p].mkv]
Jul 29, 2015 5:42:34 AM net.filebot.media.MediaDetection$7 getSizeValues
WARNING: Unable to read media info: Unable to load 32-bit native library 'mediainfo' [Gintama - E82 - It`s Not Like I Line Up for Ramen. I Line Up for Satisfy Myself..mkv]
Skipped [H:\New Downloads\Finished Downloads\[HorribleSubs] Gintama - 282 [720p].mkv] because [D:\Anime\Gintama\Gintama - E82 - It`s Not Like I Line Up for Ramen. I Line Up for Satisfy Myself..mkv] already exists
Processed 1 files
Notify XBMC: 127.0.0.1
Done ヾ(@⌒ー⌒@)ノ
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Gintama and AMC script

Post by rednoah »

I see. But in this case FileBot simply can't know that Gintama - 282 is magically Gintama (2015) - 17 since AniDB doesn't provide that kind of mapping-information.

EDIT:

I recommend adding an ignore pattern:

Code: Select all

--def "ignore=Gintama"
:idea: Please read the FAQ and How to Request Help.
jbsoum
Posts: 21
Joined: 01 Feb 2015, 16:27

Re: Gintama and AMC script

Post by jbsoum »

Yeah I figured as much. It's the only show I have this problem with.
jbsoum
Posts: 21
Joined: 01 Feb 2015, 16:27

Re: Gintama and AMC script

Post by jbsoum »

rednoah wrote:I see. But in this case FileBot simply can't know that Gintama - 282 is magically Gintama (2015) - 17 since AniDB doesn't provide that kind of mapping-information.

EDIT:

I recommend adding an ignore pattern:

Code: Select all

--def "ignore=Gintama"
So I thought of an idea to fix it, I'm just curious if there's a way for me to do it with the AMC script.

I know that the pattern for this show will be that if it's got Gintama in the file name, I want to replace Gintama with Gintama (2015). For the episode number, I just want the absolute number which will always be 282-265 = 17.

Basically, when 'Gintama' is identified, I want fn:replace(Gintama, Gintama (2015)) and fn:replace(ep number, ep number -265). I don't think my syntax is right, but that's the general idea. If I could make that work then I'd get a positive match on anidb every time. Is this possible?
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Gintama and AMC script

Post by rednoah »

1.
You could do your own pre-processing of filenames with your own script before calling the amc script.

2.
Have you looked into --filter yet?

@see Advanced Fine-Tuning (amc manual)
@see viewtopic.php?f=3&t=2127

Presumably only 1 episode of any Gintama series has aired in the last few days, so --filter "age < 7" could easily exclude everything that old.
:idea: Please read the FAQ and How to Request Help.
jbsoum
Posts: 21
Joined: 01 Feb 2015, 16:27

Re: Gintama and AMC script

Post by jbsoum »

Okay, so filter would limit the universe of possible matches to recently aired episodes, correct? That would serve my needs well, but I don't think that AMC would match Gintama 282 to Gintama (2015) ep17 even if I used filter. Am I correct in assuming that?

I was hoping I could accomplish this without running my own script. But perhaps that's the best option?
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Gintama and AMC script

Post by rednoah »

Nope, you're incorrect. It should work.

In -non-strict mode FileBot will always take the best match, regardless of how good or bad it is, so if you --filter to make sure there's only 1 episode left as an option, that's gonna be the best match.
:idea: Please read the FAQ and How to Request Help.
jbsoum
Posts: 21
Joined: 01 Feb 2015, 16:27

Re: Gintama and AMC script

Post by jbsoum »

Okay, cool! So is there like a way to do filter if? Like only apply filter for files with "Gintama" in the filename?

I only ask because sometimes my RSS feeds will download 2nd versions of episodes I already have a couple of weeks after they aired, and I'm afraid these would get incorrectly matched as the most recent version of an episode. If I could isolate the search to Gintama files only then I could make sure that doesn't happen for that one show.
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Gintama and AMC script

Post by rednoah »

You should be able to use {label} or {defines} in your filter, so you can enable/disable the logic depending on what you pass in when calling the amc script.

e.g.

Code: Select all

age < 7 || !(defines.ut_title =~ /Gintama/)
:idea: Please read the FAQ and How to Request Help.
jbsoum
Posts: 21
Joined: 01 Feb 2015, 16:27

Re: Gintama and AMC script

Post by jbsoum »

Okay great I'll try that. so that's basically saying that the filter only applies if the title is like Gintama, correct?

I was about to ask you if something like this would work. I'm going to try what you recommended, but now I'm just curious.

Code: Select all

--filter if (ut_file.contains('Gintama'))  { "age < 7" }
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Gintama and AMC script

Post by rednoah »

Well, it must be a valid Groovy expression that evaluate to true or false.

e.g. this might work, if you fix the syntax errors:

Code: Select all

--filter "if (defines.ut_file =~ 'Gintama') { return age < 7 } else { return true }"
:idea: Please read the FAQ and How to Request Help.
jbsoum
Posts: 21
Joined: 01 Feb 2015, 16:27

Re: Gintama and AMC script

Post by jbsoum »

Great, thanks! Just wondering if I got the gist of the Groovy language; it appears I do not yet.

I'll try your initial recommendation. Thanks for the help!
jbsoum
Posts: 21
Joined: 01 Feb 2015, 16:27

Re: Gintama and AMC script

Post by jbsoum »

Okay, looks like the file didn't process. Here's the log:

Code: Select all

Run script [fn:amc] at [Wed Sep 02 05:50:29 CDT 2015]
Parameter: music = y
Parameter: clean = y
Parameter: subtitles = en
Parameter: xbmc = 127.0.0.1
Parameter: seriesFormat = H:/TV2/{n}/{episode.special ? 'Special' : 'Season '+s}/{n} - {episode.special ? 'S00E'+special.pad(2) : s00e00} - {t}
Parameter: animeFormat = D:/Anime/{primarytitle}/{primarytitle} - {episode.special ? 'S00E'+special.pad(2) : s00e00} - {t}
Parameter: movieFormat = H:/Movies/{n} ({y})/{n} ({y}){' CD'+pi}{'.'+lang}
Parameter: musicFormat = H:/Music/{n}/{album+'/'}{pi.pad(2)+'. '}{artist} - {t}
Parameter: ut_label = BTN
Parameter: ut_state = 5
Parameter: ut_title = [HorribleSubs] Gintama - 287 [720p].mkv
Parameter: ut_kind = %K
Parameter: ut_file = [HorribleSubs] Gintama - 287 [720p].mkv
Parameter: ut_dir = H:\New Downloads\Finished Downloads
Input: H:\New Downloads\Finished Downloads\[HorribleSubs] Gintama - 287 [720p].mkv
Group: [anime:gintama] => [[HorribleSubs] Gintama - 287 [720p].mkv]
Rename episodes using [AniDB]
Auto-detected query: [Gintama]
Fetching episode data for [Gintama]
Fetching episode data for [Gintama']
Fetching episode data for [Gintama' (2012)]
Fetching episode data for [Gintama' (2014)]
Fetching episode data for [Gintama (2015)]
Apply Filter: {age < 7 || !(defines.ut_title =~ /Gintama/)}
No matching episode: [HorribleSubs] Gintama - 287 [720p].mkv
CmdlineException: Unable to match files to episode data
Finished without processing any files
Failure (°_°)
jbsoum
Posts: 21
Joined: 01 Feb 2015, 16:27

Re: Gintama and AMC script

Post by jbsoum »

This time, it did work. Not really sure why.

Code: Select all

Run script [fn:amc] at [Wed Sep 09 05:50:41 CDT 2015]
Parameter: music = y
Parameter: clean = y
Parameter: subtitles = en
Parameter: xbmc = 127.0.0.1
Parameter: seriesFormat = H:/TV2/{n}/{episode.special ? 'Special' : 'Season '+s}/{n} - {episode.special ? 'S00E'+special.pad(2) : s00e00} - {t}
Parameter: animeFormat = D:/Anime/{primarytitle}/{primarytitle} - {episode.special ? 'S00E'+special.pad(2) : s00e00} - {t}
Parameter: movieFormat = H:/Movies/{n} ({y})/{n} ({y}){' CD'+pi}{'.'+lang}
Parameter: musicFormat = H:/Music/{n}/{album+'/'}{pi.pad(2)+'. '}{artist} - {t}
Parameter: ut_label = BTN
Parameter: ut_state = 5
Parameter: ut_title = [HorribleSubs] Gintama - 288 [720p].mkv
Parameter: ut_kind = %K
Parameter: ut_file = [HorribleSubs] Gintama - 288 [720p].mkv
Parameter: ut_dir = H:\New Downloads\Finished Downloads
Input: H:\New Downloads\Finished Downloads\[HorribleSubs] Gintama - 288 [720p].mkv
Group: [anime:gintama] => [[HorribleSubs] Gintama - 288 [720p].mkv]
Rename episodes using [AniDB]
Auto-detected query: [Gintama]
Fetching episode data for [Gintama]
Fetching episode data for [Gintama']
Fetching episode data for [Gintama' (2012)]
Fetching episode data for [Gintama' (2014)]
Fetching episode data for [Gintama (2015)]
Apply Filter: {age < 7 || !(defines.ut_title =~ /Gintama/)}
Include [Gintama (2015) - 23 - Episode 23]
[COPY] Rename [H:\New Downloads\Finished Downloads\[HorribleSubs] Gintama - 288 [720p].mkv] to [D:\Anime\Gintama (2015)\Gintama (2015) - E23 - Episode 23.mkv]
Processed 1 files
Notify XBMC: 127.0.0.1
Done ヾ(@⌒ー⌒@)ノ
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Gintama and AMC script

Post by rednoah »

New data is continuously added to TheTVDB. I guess somebody started adding the missing episode data.
:idea: Please read the FAQ and How to Request Help.
jbsoum
Posts: 21
Joined: 01 Feb 2015, 16:27

Re: Gintama and AMC script

Post by jbsoum »

Isn't it using AniDB to rename? I had checked at the time of processing and the episode was listed when the query ran.
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Gintama and AMC script

Post by rednoah »

My fault. :P New data is continuously added to AniDB. FileBot is caching requests for a bit less than 2 weeks. So I guess somebody started adding the missing episode data well in advance. At least more than a week in advance anyway.
:idea: Please read the FAQ and How to Request Help.
jbsoum
Posts: 21
Joined: 01 Feb 2015, 16:27

Re: Gintama and AMC script

Post by jbsoum »

Gotcha, thanks! I guess there's nothing I can do about that. I'll see if it works next week. If it works more often than it doesn't then I'll be happy with it.
jbsoum
Posts: 21
Joined: 01 Feb 2015, 16:27

Re: Gintama and AMC script

Post by jbsoum »

Hey! So there's another show I'd like to apply the filter to. I was wondering how I would add that to the following syntax

Code: Select all

age < 7 || !(defines.ut_title =~ /Gintama/)
I tried:

Code: Select all

age < 7 || !(defines.ut_title =~ (/Gintama/ || /Steven Universe/)
But that didn't work.
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Gintama and AMC script

Post by rednoah »

Regular Expression 101

Code: Select all

age < 7 || !(defines.ut_title =~ (/Gintama|Steven.Universe/)
:idea: Please read the FAQ and How to Request Help.
jbsoum
Posts: 21
Joined: 01 Feb 2015, 16:27

Re: Gintama and AMC script

Post by jbsoum »

Okay, thanks! I think I understand now. I wasn't aware that the text between the forward slashes used regex.

So the way that that this reads:

Code: Select all

--filter "age < 7 || !(defines.ut_title =~ /Gintama|Steven.Universe/)
is:
"filter the query to episodes younger than 7 days old" or "the torrent title does NOT contain 'Gintama' or 'Steven?Universe'"

So if the torrent title does contain 'Gintama' or 'Steven?Universe', then the code reduces to:

Code: Select all

--filter "age < 7 || FALSE"
which is literally "age < 7 or FALSE". So then for shows with these strings, look at age <7 episodes or nothing? Which basically means look at only possible matches younger than 7 days?

Then if the torrent title does NOT contain 'Gintama' or 'Steven?Universe', then the code reduces to:

Code: Select all

--filter "age < 7 || TRUE"
which is literally "age < 7 or TRUE". So then for shows without these strings, look at age<7 episodes or everything? Which basically means look at all possible matches?

I'm just trying to make sure I understand how this works.
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Gintama and AMC script

Post by rednoah »

Yep. A bit tricky because of the OR NOT but that's how it works. :)
:idea: Please read the FAQ and How to Request Help.
jbsoum
Posts: 21
Joined: 01 Feb 2015, 16:27

Re: Gintama and AMC script

Post by jbsoum »

Yeah, that is not intuitive at all! Thanks for clarifying! Trying to be self-sufficient at this!
Post Reply