View Single Post
Old 03-24-2021, 08:01 AM   #7
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,473
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
After thinking about this overnight, I think my suggestion is more than you need. All you need to do is run a single field edit on identifiers over all the books. The template would generate the 'right' identifiers and return those. If there are no changes then return the existing identifiers.

The template would implement the equivalent of the three S & Rs, manipulating the list directly. Here is a sample template that does the first and the third. The second is a near copy of the first.

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, '^.*/(\d+)$', '\1');
		ids = list_union(ids, strcat('ao3:', 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
chaley is offline   Reply With Quote