Ok I did some more tinkering of the code on #7 and tweaked the regexes a bit (
^.*/(\d+)$ occasionally captured chapter numbers instead of the story id).
Code:
program:
publisher = field('publisher');
ids = field('identifiers');
status = field('#fanficstatus');
u = select(ids, 'url');
if publisher == 'Archive of Our Own' && u && status != 'Anthology' then
ids = list_difference(ids, strcat('url:', u), ',');
n = re(u, '^https://archiveofourown.org/works/(\d+)', '\1');
ids = list_union(ids, strcat('ao3:', n), ',')
fi;
if publisher == 'FanFiction.net' && u && status != 'Anthology' then
ids = list_difference(ids, strcat('url:', u), ',');
n = re(u, '^https://www.fanfiction.net/s/(\d+)/(\d+)/', '\1');
ids = list_union(ids, strcat('ffnet:', n), ',')
fi;
if 'Completed|Oneshot|Abandoned' in status && u &&
(select(ids, 'ao3') || select(ids, 'ffnet')) then
ids = list_difference(ids, strcat('url:', u), ',')
fi;
ids
Oddly enough if I remove the
last part it still removes the url: identifier
I will keep tinkering.
EDIT: If I remove the list_difference lines (except the last one), it does not remove url: Is that necessary for something else to work? I did not see any strange results when I tried with multiple books of different statuses