View Single Post
Old 05-31-2022, 10:25 AM   #1
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,477
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Kobo Libra2: template collections not created

I use this template to create collections.
Code:
program:
	globals(serial_number='N4181B1027108');

	if serial_number == 'N4181B1027108' then
		return list_join(
			':@:', 
			list_re($#cbhtags, ',', '^(.*)$', 'CBH Tags: \1'), ',', 
			list_re($authors, '&', '(^.).*', 'Authors: \1'), '&')
	fi;
	if serial_number == 'N4181B5019336' then
		return list_join(
			':@:', 
			list_re($#dthtags, ',', '^(.*)$', 'DTH Tags: \1'), ',',
			list_re($authors, '&', '(^.*)', 'Authors: \1'), '&')
	fi
The problem: no collections are created even though the debug log says the template returned values. Instead I get the following error for all the collections.
Code:
category not added to book.device_collections []
I debugged the problem by copying one book to a new library, preserving structure, and setting the debugging title appropriately. After a few trials I found that the problem is caused by create_collections returning false because nothing is in the collections attributes box. The fix: kobo.driver.py line 3681:
Code:
    @property
    def create_collections(self):
        return (self.manage_collections and self.supports_bookshelves and self.get_pref('create_collections') and
                                (len(self.collections_columns) > 0 or self.use_collections_template))
chaley is offline   Reply With Quote