![]() |
#1 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,854
Karma: 74203799
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Template: Specifying that an identifier does not exist
I am trying to convert these three rules into an advanced one:
Context: the first rule checks for url: identifiers I want to remove from finished fanfics, and the second two check for missing ao3/ffnet identifiers that I want to add to in-progress fanfics. If I see the icon, I then run my Cleanup: Fanfiction action chain to automagically do it. ![]() I have this, which works (I changed a few things around): Code:
program: status = $#fanficstatus; publisher = $publisher; ids = $identifiers; u = select(ids, 'url'); a = select(ids, 'ao3'); f = select(ids, 'ffnet'); if u && '(Archive of Our Own|Fanfiction.net)' in publisher && '(Completed|Abandoned|Oneshot)' in status then "metadata.png:" elif u && a && publisher = 'Archive of Our Own' && status = 'In-Progress' then "metadata.png:" elif u && f && publisher = 'FanFiction.net' && status = 'In-Progress' then "metadata.png:" fi Also, how would I specificy "if (A or F) exist" for the first part? I see this part but I don't really understand how to make the syntax work ![]() Code:
or_expression ::= and_expression [ '||' and_expression ]* and_expression ::= not_expression [ '&&' not_expression ]* not_expression ::= [ '!' not_expression ]* | compare_exp ![]() Last edited by ownedbycats; 03-31-2021 at 11:04 AM. |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,393
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
First, note that the test of 'u' is the same in all the condition clauses and you never subsequently use 'u', so it can be factored out.
You use 'unary not' (!) to invert a condition, in your case to return True if the variable is empty. Given the above, I think you want: Code:
program: if select(ids, 'url') then status = $#fanficstatus; publisher = $publisher; ids = $identifiers; a = select(ids, 'ao3'); f = select(ids, 'ffnet'); if (a || f) && '(Archive of Our Own|Fanfiction.net)' in publisher && '(Completed|Abandoned|Oneshot)' in status then "metadata.png:" elif !a && publisher = 'Archive of Our Own' && status = 'In-Progress' then "metadata.png:" elif !f && publisher = 'FanFiction.net' && status = 'In-Progress' then "metadata.png:" fi fi |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,854
Karma: 74203799
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I had to move ids = $identifiers; to the first line to prevent an error, but now I'm getting odd results.
e.g. Status: In-Progress Publisher: Archive of Our Own identifiers: url, ao3 Intended result: null Actual result: metadata.png I am getting the same thing for FanFiction.net/ffnet. modifying my original code like this does get the intended results though: Code:
program: status = $#fanficstatus; publisher = $publisher; ids = $identifiers; u = select(ids, 'url'); a = select(ids, 'ao3'); f = select(ids, 'ffnet'); if (a || f) && u && '(Archive of Our Own|Fanfiction.net)' in publisher && '(Completed|Abandoned|Oneshot)' in status then "metadata.png:" elif !a && u && publisher = 'Archive of Our Own' && status = 'In-Progress' then "metadata.png:" elif !f && u && publisher = 'FanFiction.net' && status = 'In-Progress' then "metadata.png:" fi Last edited by ownedbycats; 03-31-2021 at 04:21 PM. |
![]() |
![]() |
![]() |
#4 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,393
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
|
|
![]() |
![]() |
![]() |
#5 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,854
Karma: 74203799
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
My current database is kinda bulky due to Audit Log, but I'll copy a few books to a test DB and if it's replicated there email it.
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,854
Karma: 74203799
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I replicated the issue in a testing library and sent the database from an outlook.com email address.
|
![]() |
![]() |
![]() |
#7 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,393
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
The problem seems to be you using '=' instead of '==' to do comparisons. The first does an assignment and returns the value being assigned. The second does the comparison.
Does this template do what you expect? I changed lines 15, 16, 20, and 21. Sorry I didn't notice the error before post #2. Code:
program: ids = $identifiers; if select(ids, 'url') then status = $#fanficstatus; publisher = $publisher; a = select(ids, 'ao3'); f = select(ids, 'ffnet'); if (a || f) && '(Archive of Our Own|Fanfiction.net)' in publisher && '(Completed|Abandoned|Oneshot)' in status then "metadata.png:" elif !a && publisher == 'Archive of Our Own' && status == 'In-Progress' then "metadata.png:" elif !f && publisher == 'FanFiction.net' && status == 'In-Progress' then "metadata.png:" fi fi |
![]() |
![]() |
![]() |
#8 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,854
Karma: 74203799
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
That works.
![]() |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Template: saving template tester when restarting Calibre | ownedbycats | Library Management | 14 | 03-29-2021 05:57 PM |
Template: Converting a search & replace into a template | ownedbycats | Library Management | 11 | 03-26-2021 04:32 AM |
Using built-in template functions in a custom template function | ilovejedd | Library Management | 4 | 01-28-2018 12:20 PM |
How would one create an identifier template? | Sidetrack | Library Management | 0 | 06-06-2014 01:38 AM |