Remove name if it contains certain string

Any questions? Need some help?
Post Reply
Elamania
Posts: 39
Joined: 07 Sep 2015, 23:00

Remove name if it contains certain string

Post by Elamania »

Hi,
some files in anidb only have Volume n or Episode n as Episodes names and in that case I would like to not show any Episodename.
How do I do that?
I used:

Code: Select all

{t.contains(Volume|Episode) ? " " : " - " + norm(t).take(40)}
But it just deletes the whole Episodename.

What I want is that if t is nothing else than "Episode x" or "Volume x" then nothing will be shown otherwise the Episodename.
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Remove name if it contains certain string

Post by rednoah »

If you had listed one of these shows, then that would have made testing a bit easier and saved me a bit of time. ;)


e.g.

Code: Select all

{
	t ==~ /(Volume|Episode).[0-9]+/ ? null : ' - ' + t
}


Elamania wrote: 08 Feb 2022, 11:22 But it just deletes the whole Episodename.
Your code is syntactically wrong, thus there's an error, hence it does nothing.

Code: Select all

Binding "Volume": No such property
:arrow: Please use the Format Editor GUI so you can prototype things step by step and see the error messages.

Image
:idea: Please read the FAQ and How to Request Help.
Elamania
Posts: 39
Joined: 07 Sep 2015, 23:00

Re: Remove name if it contains certain string

Post by Elamania »

Thank you!

Sorry, I thought that it would be easy enough :)

I see, I didnt´use a string with contains. But even with it, it didn´t work properly.

When I understand it corretly then you use ~ in order to make a Regex. ... So "==~" means "equals to this regex" ?
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Remove name if it contains certain string

Post by rednoah »

Yes, ==~ is the exact-match operator:
https://groovy-lang.org/operators.html#_match_operator
:idea: Please read the FAQ and How to Request Help.
Elamania
Posts: 39
Joined: 07 Sep 2015, 23:00

Re: Remove name if it contains certain string

Post by Elamania »

...And another thing.

{episode.special ? 'Special' : 'Season '+s}/

Generates under certain conditions a Season Folder.
How can I say that it is not supposed to generate one if there is only one Season of that Series?

I am talking about Anime/anidb. Strangely sometimes it does generate the Folder, sometimes it doesn´t.
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Remove name if it contains certain string

Post by rednoah »

Anime don't have season numbers. So you can just remove the {...} part altogether. AniDB fundamentally doesn't support {s}. However, FileBot will infer the season number you want to see from external sources, which may or may not work on a case by case basis, so {s} may yield a value, or throw an error, on a case by case basis.


:idea: Please read [Anime] Convert Absolute to SxE numbers for details.


:idea: Note that ImageImage mapping information is maintained by the Anime-Lists/anime-lists project. If you use AniDB and {s} is giving you a number, then that's where it came from.


:idea: If you were to use a database that has the concept of seasons for each series, then the {sc} season count binding could be used to yield different values depending on whether or not the series has multiple seasons, but if you're using AniDB, that probably won't work.
:idea: Please read the FAQ and How to Request Help.
Elamania
Posts: 39
Joined: 07 Sep 2015, 23:00

Re: Remove name if it contains certain string

Post by Elamania »

lol, you are right. Totally overlooked that...
Interesting... why would I use this mapper if I can just use TVDB?


Regarding series names..

Code: Select all

"/{norm(localize.en.primarytitle)}/
{f.subtitle ? "Subs/" : null} 
{norm(localize.en.n)} - "
Whose names will be taken with those and what other Name Properties are there?
Because currently it takes sometimes a different name (what I want) and sometimes the same.
I basically want the main name and the english name.

It sometimes takes for both a name that is not used on anidb.

eg.: https://anidb.net/anime/14725/name NSFW

The original name is Jitaku Keibiin (2019), but both Properties will return Jitaku Keibiin. .... why? It´s not even available on anidb. But the Episodetitles will be correctly identified.
"[SakuraCircle] Jitaku Keibiin (2019) - 02 (DVD 720x480 h264 AAC) [3D253C32].mkv"
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Remove name if it contains certain string

Post by rednoah »

Elamania wrote: 08 Feb 2022, 23:24 why would I use this mapper if I can just use TVDB?
If you can, then you wouldn't. But if you can't, then you might. :lol:


:?: Which database are you using? Which title do you want? What series are you testing with and what file name do you want for a given sample (i.e. a tricky corner case) file?


AniDB can provide x-jat (transliterated Japanese) and English series name. TheTVDB does not support x-jat and can only give you the English series name. If you want AniDB x-jat name and TheTVDB English name, then things get complicated, but of course possible with the bindings and mappings mentioned in the thread linked above.

tl;dr you can reliably have season numbers, or reliably have x-jat names, but you can't reliably have both, because neither AniDB nor TheTVDB support both


:idea: If you use AniDB, then primaryTitle is always the x-jat name. If you use TheTVDB, then primaryTitle is always the English name. So {localize} does nothing in this particular use case, but will confuse you because you might think that it does something. ;)


EDIT:

primaryTitle does do some magic in newer revisions, and tries to give you the value you probably want if possible; so for TheTVDB entries, it might give you the AniDB x-jat name automatically if it can be inferred from the Anime-Lists mapping information.
:idea: Please read the FAQ and How to Request Help.
Elamania
Posts: 39
Joined: 07 Sep 2015, 23:00

Re: Remove name if it contains certain string

Post by Elamania »

Hi, I only use anidb.
Didn´t know that tvdb has hentai? :O

I just want the english japanese name and the translated name.

I know that you give no Support for NSFW, but can there be any error on my side when Filebot does not find a Series? - Even in the Episode Tab. Or am I just out of luck?
btw, how do I "force" a TextInput for a file? I know that it was something with Shift + Right click? But that only reruns the Matcher.

btw, did you change something wiht the coloring of the entries?
Because I get here quiite a lot of mismatches, but all of them are white.

Edit:
Just another example with the names:

https://anidb.net/anime/13792 -NSFW
I want the Main title and the first Synonym.
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Remove name if it contains certain string

Post by rednoah »

Sorry. With NSFW you're probably mostly out-of-luck in this case, because you want both name from AniDB and English names / SxE numbers from TheTVDB, and you can't have both. If you're OK with just AniDB naming / AniDB information, then you can just lookup-by-id instead of search-by-name.



AFAIK, AniDB hentai don't work because they aren't in the search index, but if you search by numeric ID, then the episodes should show up, so you can at least rename the files against pristine AniDB episode listings, no SxE mappings though, no English name if AniDB doesn't have the English name, etc:

Code: Select all

$ filebot -list --q 13792 --db AniDB --format "{primaryTitle} | {n} | {s} | {e} | {t}"
Ryoujoku Rinne | Ryoujoku Rinne |  | 1 | Ikumi Chapter
{primaryTitle} | {n} is from AniDB. Presumably, the official English series name hasn't been entered yet.



:idea: Note that FileBot will use the official English series name if there is one:

Code: Select all

$ filebot -list --q 00026 --db AniDB --format "{primaryTitle} | {n} | {s} | {e} | {t}"
Juuni Kokuki | The Twelve Kingdoms | 1 | 1 | Shadow of the Moon, The Sea of Shadow - Chapter 1
{primaryTitle} | {n} is from AniDB. {s} comes from TheTVDB and only works due to the AnimeLists mapping project.




EDIT:
Elamania wrote: 15 Feb 2022, 13:10 btw, did you change something wiht the coloring of the entries?
Because I get here quiite a lot of mismatches, but all of them are white.
Screenshot?

:idea: How does FileBot know that this match is a mismatch? If the episode is 1x01 and the file says 2x02 then the entry is gonna be bright red. But if the kind of mismatch you have is less detectable (e.g. based on series name, episode title, etc) then FileBot won't be able to reliably indicate those.
:idea: Please read the FAQ and How to Request Help.
Elamania
Posts: 39
Joined: 07 Sep 2015, 23:00

Re: Remove name if it contains certain string

Post by Elamania »

Yeah, the name itself was wrong... I thought that you are using something like Hemming Distance to check that.

I am just going to push this one...

I updated FB and now my script does not run anymore.

Code: Select all

{ norm = { it.upperInitial()
             .lowerTrail()       
             .replaceAll(/[`´‘’ʻ""“”]/, "'")
           
			 .take(60)
           } }
 	{file.path[0]}:/Anime/{norm(localize.en.n)}/
	{f.subtitle ? "Subs/" : null} 
	{norm(localize.en.n)}          
           
will produce:
D:Script2$_run_closure1@1b13625 D:/Anime/Saimin Seishidou/Saimin Seishidou
What did change?
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Remove name if it contains certain string

Post by rednoah »

Your format expression is incorrect. But happened to work accidentally with older versions. Your first { ... } returns the norm() function object, which has Script2$_run_closure1@1b13625 as its String representation.


:idea: Please read Why does my custom format yield Script1$_run_closure1@632a2d0c and strange String values like that? for details.


:arrow: I'd simplify the code to bypass the issue like so:

Code: Select all

{ drive }
/Anime
/{ n.upperInitial().lowerTrail().asciiQuotes().take(60) }
{ f.subtitle ? "Subs/" : null } 
/{ n.upperInitial().lowerTrail().asciiQuotes().take(60) }
:idea: Note that localize.en.n likely does nothing, and can be replaced with n, if your preferred language is already set to English.
:idea: Please read the FAQ and How to Request Help.
Post Reply