Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 11-10-2021, 06:03 AM   #1
sllewji
Junior Member
sllewji began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Jun 2017
Device: Onyx Boox Poke2, 3 & 5 / OnePlus 5T / Amazon Fire HD 10
New Tag Browser Hierarchy from Existing Columns

Hi,

I would like to create a new Tag browser Hierarchy based upon Authors and Series - with each author listed once at the top level, similar to the Author(s) group, and all the series that they either authored or co-authored at the second level.
Authors should be shown in lastname order

I've played around with the template language in order to try an get this working, but the closest I've come to a solution is a hierarchy that only includes the first author of the series using this template I found via Google :-
{author_sort:'re(sublist($, 0, 1, '&'), '\.', '')'}.{series}
I'm not much good with Python - does anyone have some more pointers?

Thanks in advance,
sllewji
sllewji is offline   Reply With Quote
Old 11-10-2021, 10:09 PM   #2
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
As a first pass, the following will produce a value that is the first author plus the series:

Code:
program:
if $series then
   strcat(sublist($author_sort, 0, 1, '&'), '.', $series)
fi
With this you will get something like:

Code:
Butcher, Jim.The Dresden Files
And any book without a series will have nothing.

If you want to simply use the full author sort, then remove the use of the sublist function.

To get an entry for each author:

Code:
program:
program:
if $series then
    val = list_re($author_sort, ' & ', '^(.*)$', strcat('\1.', $series));
    val = re(val, ',', '_');
    val = re(val, ' & ', ',');
    val = re(val, '\.\.', '.') 
fi
For a series called "Some Series" with the author_sort of "Author, First & One, Other", this would produce "Author_ First.Some Series, One_ Other.Some Series". And in the tag browser you get the two entries.

The "re"s are to change the commas to underscores so the tags don't get split there. Then the ampersand to commas so they do. Then, if there a two dots together, change it to one so that you will get the hierarchy. This was a problem for authors like "Firstname I. Surname" which will be "Surname, Firstname I." and when the ".Series Name" is added, the hierarchy split doesn't happen.

It looks ugly, but is seems to work.
davidfor is offline   Reply With Quote
Advert
Old 11-11-2021, 03:27 AM   #3
sllewji
Junior Member
sllewji began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Jun 2017
Device: Onyx Boox Poke2, 3 & 5 / OnePlus 5T / Amazon Fire HD 10
Thank you for your proposed solution, and the detailed explanation was very helpful indeed.

This does indeed get a lot farther along than my attempts.

I've removed all full-stops from my authors to avoid the initials issue.

This works perfectly for single authored books, but is still not quite there for co-authored ones.

Dual authored books, I get a three level hierarchy looking like this :-

-Anderson_ Kevin J
- Dune Caladan, Herbert_ Brian
- Dune Caladan

and under the author Herbert_ Brian there is no hierarchy including Dune Caladan.

It seems as if the list is not being separated at the comma into the two separate hierarchy entries.

Triple authored books, such as Road to Dune by Frank Herbert, Brian Herbert and Kevin J Anderson don't appear anywhere in the hierarchy which is again, I guess, associated by the extra comma.

I've tried messing around with subitem() to see if it would help, but then I lost single authored series all together.

I'd be most grateful if you had any further pointers or ideas.
sllewji is offline   Reply With Quote
Old 11-11-2021, 05:04 AM   #4
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
I might have missed what you want. Or, I need to see some examples of the data to make sure we are discussing the same thing. For example, with the last template and a book:

Title: Road to Dune
Authors: Frank Herbert & Brian Herbert & Kevin J Anderson
Author Sort: Herbert, Frank & Herbert, Brian & Anderson, Kevin J
Series: Dune

With that, the result of the template is:

Herbert_ Frank.Dune,Herbert_ Brian.Dune,Anderson_ Kevin J.Dune

That gives me three entries in the tag browser:
Herbert_ Frank.Dune
Herbert_ Brian.Dune
Anderson_ Kevin J.Dune

Each containing the book.

If I create a book with two authors:

Title: Dune Caladan book 1
Authors: Kevin J Anderson & Brian Herbert
Author Sort: Anderson, Kevin J & Herbert, Brian
Series: Dune Caladan

With that, the result of the template is:

Anderson_ Kevin J.Dune Caladan,Herbert_ Brian.Dune Caladan

That gives me three entries in the tag browser:
Anderson_ Kevin J.Dune Caladan
Herbert_ Brian.Dune Caladan

With the book in both.

And for all numbers of authors, if there is no series, the result of the template is empty, and the book will not be in the tags browser.

I think the above is what you are after. But, if it isn't, some examples of both the book metadata and what you expect to see.
davidfor is offline   Reply With Quote
Old 11-11-2021, 05:30 AM   #5
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,446
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
This template produces a similar answer as @davidfor's but using a different technique.
Code:
program:
	series = re($series, '\.', '_');
	if series then
		res = '';
		for aut in $author_sort separator '&':
			res = strcat(res, (if res then ',' fi), re(aut, ',', ';'), '.', series)
		rof
	fi
One difference: I prefer a semicolon over an underscore in the authors' names. YMMV.

For these templates to work the destination column must be "built from other columns, behaves like tags" and the lookup key must be added to the hierarchical columns box.
chaley is offline   Reply With Quote
Advert
Old 11-12-2021, 05:40 AM   #6
sllewji
Junior Member
sllewji began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Jun 2017
Device: Onyx Boox Poke2, 3 & 5 / OnePlus 5T / Amazon Fire HD 10
I tried @chaley's solution, but was getting the same issues as with @davidfor's

I've dropped then re-added the #author_series custom column to the Categories the hierarchical items option in the Tag browser settings and now both proposed solutions are working perfectly.

Thank you both so much for spending time and effort to address this requirement, I am indebted to you both!
sllewji is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why are all text columns shown in tag browser? (And changing column types?) ownedbycats Library Management 0 12-29-2020 09:16 PM
column from other columns with hierarchy and names DBorG Library Management 1 10-01-2018 04:03 PM
Hierarchy columns mezme Calibre 7 03-07-2016 01:10 PM
suggestion: tag groups should use Calibre tag hierarchy comox Calibre Companion 53 05-25-2015 07:22 PM
Tag browser Series hierarchy Dopedangel Library Management 4 06-15-2012 06:20 AM


All times are GMT -4. The time now is 03:35 PM.


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