View Single Post
Old 03-26-2021, 12:02 AM   #9
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,420
Karma: 80995913
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
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
Attached Thumbnails
Click image for larger version

Name:	2021-03-26 05_14_57-Template tester.png
Views:	237
Size:	38.4 KB
ID:	186155  

Last edited by ownedbycats; 03-26-2021 at 05:20 AM.
ownedbycats is online now   Reply With Quote