View Single Post
Old 06-10-2014, 12:45 AM   #2890
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by JimmXinu View Post
It doesn't work that way. Each replace line is applied sequentially.

In the case shown above, "Thor (Movies)" is changed into "Thor" and then doesn't match the next 'Thor \(Movies\)' pattern any more.

I expect davidfor is actually using the technique where you add a new metadata item with extra_valid_entries, populate it with a copy of an existing one, then change each separately and merge back together.
I wish I could say I was being that clever, but I wasn't. I had assumed that it would test against each line. I just checked a couple of stories I use for test cases and of course it doesn't work. My test cases had combinations of tags that meant it looked like it was working, but wasn't really.
Quote:
I've looked at that a bit before and again now. I've found a way that appears to work.

I've arbitrarily chosen '{{,}}' as a separator to indicate to split the replacement string at that point(s) into a list and append the new entries to the end of the list. Because they go to the end, they will in turn have replace_metadata applied.

There's a risk of infinite recursion, that I haven't thought about very deeply yet.

If you're curious, here's my test case:
Spoiler:

Story URL test1.com?sid=1001 and setting default to Update Calibre Only speeds testing considerable.
Code:
[test1.com]
replace_metadata:
 category=>Marvel Cinematic Universe=>Marvel Cinematic MultiVerse
 category=>Thor \(Movies=>\)Thor{{,}}Marvel Cinematic Universe
 genre=>Action=>MovieAction&&category=>MultiVerse
Is that a typo? It looks like you have the "=>" in the wrong place. In any case, when I put it in the place I thought was correct, it worked. And worked well.
davidfor is offline