Quote:
Originally Posted by Wiggo
OK, I do my best.
I followed your post https://www.mobileread.com/forums/sh...77#post4333077 and adapted it to my situation.
Your column #pen_names is my column #alias.
I also had an old group search called pen-names consisting of #authors and #alias
Attachment 205292
and my similar author search is the grouped search pen-names.
Attachment 205293
When I searched for similar authors in the past, every search looked like this one
Attachment 205294
but now a similiar authors search with containing aliases looks like this one
Attachment 205295
I think the confusion comes from my renaming - my grouped search pen-names != your column #pen_names.
I hope I was able to bring some clarity to the issue.
|
Thanks for the details.
What I see is:
- You created the Pen Names and Real Names columns using the templates from the post you referenced. Your Pen Name column has the lookup name #alias.
- You created a grouped search term "pen-names" that references both #authors and #alias.
- You changed Similar Books:authors to reference the grouped search term "pen-names".
I stand by my saying that it is working as it should, and as it has always worked.
- The values of items in your #alias column are calibre search URLS so they are clickable in book details.
- Similar books works by evaluating the listed columns (in your case #authors and @pen-names) then putting each value from the column into the search string.
- Thus similar books adds the calibre search urls to the search string.
To avoid this behavior and use names instead you must create another composite column (#alias_names ?) that contains the author names instead of the calibre search strings. You then add that column to the grouped search term instead of the one that contains calibre search strings. This column shouldn't be shown in the booklist or book details.
The template will look like this, corrected for your name changes:
Code:
python:
def evaluate(book, context):
from collections import defaultdict
from calibre.utils.icu import sort_key
alias_category = 'Aliases.'
db = context.db.new_api
# Build a set of other pen names for each author that is a pen name.
# This loop only processes categories prefixed with alias_category
all_pen_names = defaultdict(set)
for pen_names in [[v[0] for v in vals]
for cat,vals in db.pref('user_categories').items()
if cat.startswith(alias_category)]:
for pn in pen_names:
all_pen_names[pn].update(pen_names)
# Build the set of all pen names for all the authors of this book. Use a set
# to remove duplicates.
auts = set()
for p in book.authors:
if p in all_pen_names:
auts.update(all_pen_names[p])
# Now build the sorted list of pen names.
auts = list(sorted(auts, key=sort_key))
# Combine all the authors into a single string with the URLS separated by link_break.
return ' & '.join(auts)
The column definition looks like this: