Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 05-09-2025, 03:52 PM   #1
DJH352
Member
DJH352 began at the beginning.
 
DJH352's Avatar
 
Posts: 10
Karma: 10
Join Date: Apr 2025
Location: UK
Device: Kindle Paperwhite
Series Index Number

I use Reading List and Calibre Companion (v5.4.4.19) to send the details of the books I want to read this year to my mobile. When reading a book in a series, I like to know whereabouts in the series the book fits, e.g. if I am reading The Head Case by Bill Rogers, I can tell it is book 2 in a series of 14 (see screenshot attached).

To do this I have created a custom column (Total Series) that I manually update with the number of the latest book I have in calibre. Whenever a new book in a series is released, I bulk edit all the books in that series. This then updates another custom column (Series Pos), which is sent to Calibre Companion.

However, I wonder if the Total Series column could be automatically populated by calibre, perhaps by using Template/Search Template or a plug-in. My knowledge of templates is basic at best and would appreciate some help on this.

I know calibre can already calculate the next index in a series when adding a new book and I have seen reference to “get_next_series_num_for” in the calibre support (https://manual.calibre-ebook.com/db_api.html), but I cannot figure out how to call the code from a custom column.

Can anyone point me in the right direction, please?
Attached Thumbnails
Click image for larger version

Name:	Calibre Companion.jpg
Views:	39
Size:	143.1 KB
ID:	215590   Click image for larger version

Name:	Calibre Screenshot 2025-05-09 203017.jpg
Views:	32
Size:	73.5 KB
ID:	215591  
DJH352 is offline   Reply With Quote
Old 05-09-2025, 09:47 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,190
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
No templates can access data for only one book at a time. For what you want they would need to access the entire library to check what the largest index value for the series is. The way to automate this would be to create a calibre plugin that scanned the library and updated the custom column.
kovidgoyal is offline   Reply With Quote
Advert
Old 05-09-2025, 10:59 PM   #3
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,903
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
You might look at the Quality check Plugin: Check Metadata: Check Series Gaps.

This is a Log report (copy to clipboard)' You would need to parse it outside of Calibre and the import (Import List Plugin? ) (It does designate Last: # )
Code:
Series: Bookworm - Author: Christopher G. Nuttall - Last: #4 
    Missing#: 1,2
But this only tells you WHAT IS IN the Library and NOT what the actual series has a volumes.
theducks is offline   Reply With Quote
Old 05-10-2025, 06:58 AM   #4
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,336
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
I don't understand exactly what you want to do. It seems you want to do something with the series index when a book is added to the library, specifically copying the maximum series index for a series to a custom column for all books in that series.

If I am right then you can do what you want using the Action chains plugin. You would add the new book(s), ensure their series information is correct, select the new book(s), then use an action chain that uses a python action to determine the highest series index for a selected book then copy that number to your "Total series" column in all the other books in the series.

You could use an action chains event to set the series for new books but I think that would end in disaster. You can't guarantee for any given book that the next index is one higher then the last or even that the series is correct.

Ask in the action chains thread for more help.
chaley is offline   Reply With Quote
Old 05-10-2025, 08:47 AM   #5
DJH352
Member
DJH352 began at the beginning.
 
DJH352's Avatar
 
Posts: 10
Karma: 10
Join Date: Apr 2025
Location: UK
Device: Kindle Paperwhite
Quote:
Originally Posted by kovidgoyal View Post
No templates can access data for only one book at a time. For what you want they would need to access the entire library to check what the largest index value for the series is. The way to automate this would be to create a calibre plugin that scanned the library and updated the custom column.
Thanks for the explanation. I will delve further into available plugins
DJH352 is offline   Reply With Quote
Advert
Old 05-10-2025, 08:55 AM   #6
DJH352
Member
DJH352 began at the beginning.
 
DJH352's Avatar
 
Posts: 10
Karma: 10
Join Date: Apr 2025
Location: UK
Device: Kindle Paperwhite
Quote:
Originally Posted by theducks View Post
You might look at the Quality check Plugin: Check Metadata: Check Series Gaps.

This is a Log report (copy to clipboard)' You would need to parse it outside of Calibre and the import (Import List Plugin? ) (It does designate Last: # )
Code:
Series: Bookworm - Author: Christopher G. Nuttall - Last: #4 
    Missing#: 1,2
The 'Last #' information is exactly what I would like to use


But this only tells you WHAT IS IN the Library and NOT what the actual series has a volumes.
I'd be happy with that. I don't think Goodreads, Fantastic Fiction plug-ins look for that information.
DJH352 is offline   Reply With Quote
Old 05-10-2025, 09:04 AM   #7
DJH352
Member
DJH352 began at the beginning.
 
DJH352's Avatar
 
Posts: 10
Karma: 10
Join Date: Apr 2025
Location: UK
Device: Kindle Paperwhite
[QUOTE=chaley;4511328]I don't understand exactly what you want to do. It seems you want to do something with the series index when a book is added to the library, specifically copying the maximum series index for a series to a custom column for all books in that series.

If I am right then you can do what you want using the Action chains plugin. You would add the new book(s), ensure their series information is correct, select the new book(s), then use an action chain that uses a python action to determine the highest series index for a selected book then copy that number to your "Total series" column in all the other books in the series.



Hi Chaley, that is exactly what I want to do, although it doesn't have to be at the time of adding a new book, I'd be happy to run a plug-in, or similar, every now and again to keep the information up-to-date.

Appreciate you pointing me towards Action Chains
DJH352 is offline   Reply With Quote
Old 05-10-2025, 09:38 AM   #8
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,903
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by DJH352 View Post
I'd be happy with that. I don't think Goodreads, Fantastic Fiction plug-ins look for that information.
Those Plugins fetch metadata from the WWW. I don't even think those sites can even know what the Max number of books in a series is (it is a jumble, if you ever visit the Author page. Some appear in 2 (bridge series), Some books in a series are not even numbered (or are now Omnibus editions). Some get renumbered or even renamed .

IMHO don't bother bloating your metadata with extra columns that may be wrong next random period.

Quickview (built in). Place the cursor on the Series name for a book you are interested in: Tap 'Q' That shows all the members IN YOUR LIBRARY Metadata (I sometimes add 'empty books' to track /wishlist )

I added some of MY custom columns to the Quicview VIEW (red marks) to make deciding easier . (As you use Calibre, you will discover the amazing amount a flexibility in its design)
BTW Quickview can respect the current VL
(not done here).

#Split_series is for when they do bridge (and no PI or site is going to make this obvious) #Split off is when I used EPUB-Split PI to break up a Boxed set) #Done Read 1999 is a flag that I have split this item. All these customs are Manual data entry. There is no Auto fill .
Attached Thumbnails
Click image for larger version

Name:	QuickviewSeries.JPG
Views:	21
Size:	74.5 KB
ID:	215595  
theducks is offline   Reply With Quote
Old 05-10-2025, 10:19 AM   #9
DJH352
Member
DJH352 began at the beginning.
 
DJH352's Avatar
 
Posts: 10
Karma: 10
Join Date: Apr 2025
Location: UK
Device: Kindle Paperwhite
[QUOTE=theducks;4511356]
IMHO don't bother bloating your metadata with extra columns that may be wrong next random period.

I know, but sometimes I just can't help myself

I added some of MY custom columns to the Quicview VIEW (red marks) to make deciding easier . (As you use Calibre, you will discover the amazing amount a flexibility in its design)
BTW Quickview can respect the current VL
(not done here).

Wasn't aware of Quickview, going to have a play with it
DJH352 is offline   Reply With Quote
Old 05-10-2025, 01:27 PM   #10
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 866
Karma: 409968
Join Date: Sep 2017
Location: Buenos Aires, Argentina
Device: moon+ reader, kindle paperwhite
I have a custom information column with this template, maybe you can adapt it and see if it works for you.

Code:
python:
def evaluate(book, context):
# Use the built-in template function to format the title and authors
x = context.funcs.template('{Title} - {authors}')
# Count the books in the series. First get the series name
series = book.get('series')
if series:
# The book is in a series. Get the book count in that series
db = context.db.new_api
series_id = db.get_item_id('series', series)
book_count = len(db.books_for_field('series', series_id))
# Add the number of books to the title - author string
x = x + f' - From the series "{series}, which has {book_count} books {"s" if book_count > 1 else ""}'
else:
x = x + " - This book does not belong to a series"
return x
dunhill is offline   Reply With Quote
Old 05-10-2025, 01:51 PM   #11
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,336
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by dunhill View Post
I have a custom information column with this template, maybe you can adapt it and see if it works for you.
[...]
That is an excellent start.

Here is the converted template. It returns the maximum series index for the series of the book. Somehow the indenting was lost in @dunhill's post, which is corrected here.
Code:
python:
def evaluate(book, context):
	db = context.db.new_api
	# Count the books in the series. First get the series name
	series = book.get('series')
	if series:
		# The book is in a series. Get all the books in that series
		series_id = db.get_item_id('series', series, case_sensitive=True)
		books = db.books_for_field('series', series_id)
		# Get the highest series index
		max_dex = -9999
		for b in books:
			ser = db.field_for('series_index', b)
			if ser > max_dex:
				max_dex = ser
		# Convert the max index to a string.
		x = str(int(max_dex) if max_dex.is_integer() else max_dex)
	else:
		x = ''
	return x
This template could be used in a custom column but it might be too slow because it operates on all the books all the time. It can be used on demand in Action chains, possibly in a Single Field Edit action that operates on all the books in a series.

Last edited by chaley; 05-10-2025 at 01:58 PM. Reason: Faster template
chaley is offline   Reply With Quote
Old 05-10-2025, 02:06 PM   #12
DJH352
Member
DJH352 began at the beginning.
 
DJH352's Avatar
 
Posts: 10
Karma: 10
Join Date: Apr 2025
Location: UK
Device: Kindle Paperwhite
[QUOTE=dunhill;4511391]I have a custom information column with this template, maybe you can adapt it and see if it works for you.


That's great, thanks for the head start
DJH352 is offline   Reply With Quote
Old 05-10-2025, 02:13 PM   #13
DJH352
Member
DJH352 began at the beginning.
 
DJH352's Avatar
 
Posts: 10
Karma: 10
Join Date: Apr 2025
Location: UK
Device: Kindle Paperwhite


Can anyone tell me how you get the 'originally posted by ..." on your replies?
Attached Thumbnails
Click image for larger version

Name:	Screenshot 2025-05-10 190853.jpg
Views:	12
Size:	6.4 KB
ID:	215598  
DJH352 is offline   Reply With Quote
Old 05-10-2025, 02:31 PM   #14
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,903
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by DJH352 View Post


Can anyone tell me how you get the 'originally posted by ..." on your replies?
All tags in MR need to be closed
Your post had the Opening [quote] but appeared to be missing the closing one

BTW I use the advanced message editor (by default. ) The Quote icon is the speech balloon usually found in comics)
EDIT
attached is the setting screen for the MR editor
Attached Thumbnails
Click image for larger version

Name:	MReditor set.JPG
Views:	17
Size:	36.9 KB
ID:	215601  

Last edited by theducks; 05-10-2025 at 02:36 PM. Reason: added image
theducks is offline   Reply With Quote
Old 05-10-2025, 02:41 PM   #15
DJH352
Member
DJH352 began at the beginning.
 
DJH352's Avatar
 
Posts: 10
Karma: 10
Join Date: Apr 2025
Location: UK
Device: Kindle Paperwhite
Quote:
Originally Posted by chaley View Post
That is an excellent start.

Here is the converted template. It returns the maximum series index for the series of the book. Somehow the indenting was lost in @dunhill's post, which is corrected here.
Code:
python:
def evaluate(book, context):
	db = context.db.new_api
	# Count the books in the series. First get the series name
	series = book.get('series')
	if series:
		# The book is in a series. Get all the books in that series
		series_id = db.get_item_id('series', series, case_sensitive=True)
		books = db.books_for_field('series', series_id)
		# Get the highest series index
		max_dex = -9999
		for b in books:
			ser = db.field_for('series_index', b)
			if ser > max_dex:
				max_dex = ser
		# Convert the max index to a string.
		x = str(int(max_dex) if max_dex.is_integer() else max_dex)
	else:
		x = ''
	return x
This template could be used in a custom column but it might be too slow because it operates on all the books all the time. It can be used on demand in Action chains, possibly in a Single Field Edit action that operates on all the books in a series.

This is fantastic, thank you so much.

I added an empty book to the Jack Reacher series and calibre immediately populated the column for that book with the maximum index number. There was no lag (1,350 books)

After a re-start all books in the series were updated. When I deleted the empty book and restarted calibre, the field automatically updated again

Thank you to everyone who has help me with my query
Attached Thumbnails
Click image for larger version

Name:	Calibre Series 2025-05-10 192026.jpg
Views:	15
Size:	57.5 KB
ID:	215599   Click image for larger version

Name:	Calibre Series Update 2025-05-10 192026.jpg
Views:	15
Size:	45.1 KB
ID:	215600  
DJH352 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Missing Metadata tags for Series and Series Index? JohnStaats Sigil 16 03-04-2025 02:05 AM
how to view/filter library by series/series index masp Onyx Boox 5 02-04-2021 11:39 AM
How to change series index number format sent to device? Skydog Library Management 6 01-20-2020 10:21 PM
Series Index displayed as separate column from Series Vortex Library Management 3 03-15-2015 08:39 PM
Feature request: Ability to put a book in a series without an index number lunixer Calibre 6 08-29-2011 11:37 AM


All times are GMT -4. The time now is 01:58 AM.


MobileRead.com is a privately owned, operated and funded community.