Author sort fails sometimes in tag browser

Bug #1367943 reported by arspr
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Fix Released
Undecided
Unassigned

Bug Description

Hi Kovid,

I just cannot understand this issue.

Look at the screenshot.

"Marta Ribera de la Cruz" would be sorted "Cruz, Marta Ribera de la" with default Calibre criteria. And in this way it is sorted in the tag browser. BUT you can see how author sort is actually and explicitly set to the correct Spanish "Ribera de la Cruz, Marta"...

But this is not a general fault. Because in "F" you can see "Ignacio Ferrando Pérez", in which Calibre is obviously following the explicitly set "Ferrando Pérez, Ignacio", not its default "Pérez, Ignacio Ferrando".

(Or "Gabriel García Márquez"--"García Márquez, Gabriel", which also works fine).

Why do "Ferrando Pérez, Ignacio" and "García Márquez, Gabriel" work, but not "Rivera de la Cruz, Marta"? Am I doing something wrong?

Revision history for this message
arspr (arspr) wrote :
Revision history for this message
Kovid Goyal (kovid) wrote : Re: calibre bug 1367943

Hard to say, could be one of several things, attach the metadata.db from
your calibre library.

Revision history for this message
arspr (arspr) wrote :

Here you go.

(I've previously tested it inside Calibre, and no problems have been found).

Revision history for this message
arspr (arspr) wrote :

Here you go.

(I've previously tested it inside Calibre, and no problems have been found).

Revision history for this message
Kovid Goyal (kovid) wrote : Fixed in master

Fixed in branch master. The fix will be in the next release. calibre is usually released every Friday.

 status fixreleased

Changed in calibre:
status: New → Fix Released
Revision history for this message
arspr (arspr) wrote :

Umm... It's not fully fixed.

I mean, yes, I didn't noticed the missing "red color" feature for tweaked sort fields. And this side of the issue is fixed. (See attached screenshot).

But the tag browser continues sorting the explicitly set "Rivera de la Cruz, Marta" as the default "Cruz, Marta Rivera de la"...

Revision history for this message
Kovid Goyal (kovid) wrote :

The Tag Browser will sort the author by the author's sort value, not the value used in the edit metadata dialog. The authors sort value for that author is Cruz, ...

To change that, right click on the author in the Tag Browser and click Manage authors. Once you do that, you will notice that the edit metadata dialog is no longer red.

Revision history for this message
Kovid Goyal (kovid) wrote : Re: calibre bug 1367943

Note that you can also fix individual authors sort values by clicking
the manage authors button to the left of the authors field in the edit
metadata dialog.

Revision history for this message
arspr (arspr) wrote :

Err... I don't follow you.

I mean, I'm already talking about "Author sort" field in the Metadata Editor which is set to "Rivera...". Are you saying that Calibre has ANOTHER EXTRA "Author sort" field in another place?

(I'll test later when I'm at home, nevertheless).

Revision history for this message
Kovid Goyal (kovid) wrote :

yes, one is the author sort field for the *book* and one is the sort
field for the *author*.
http://manual.calibre-ebook.com/faq.html#how-does-app-manage-author-names-and-sorting

Revision history for this message
arspr (arspr) wrote :

Thanks for your time Kovid,

I'm learning a lot.

So:

+Author sort is actually set in the Manage Authors dialogue (as is a per author feature, not a per book feature).
+Then what is Author sort inside the book metadata used for?

(I mean: I thought that if even if it is inside the ebook metadata, if you changed that "Author sort" field, it was actually changed for that global author value. If you changed it in book A and you went to book B you'd see it updated there too. I mean I do not understand how having book A with a different Author Sort field than B can be useful. Where is it used? In the table view Author sort field is the book-related one? or its author-related one?)

Revision history for this message
Kovid Goyal (kovid) wrote :

Think about books with multiple authors, or publications from different
publishers with different conventions for name sorting, but the same
author contributing to both.

Revision history for this message
Charles Haley (cbhaley) wrote :

There are several reasons why a book might have an author sort that is different from that associated with the author(s). The first is when the first author listed is not the primary author, found for example in many Anne McCaffrey books. In this case you would manually set the author sort for the book to the second or later author. A similar case arrives with edited and translated books.

Revision history for this message
arspr (arspr) wrote :

About sorting by different authors: You could make the main Author field aware of its order, (if it is not currently): A & B & C not being the same as B & A & C. No need for a complementary Author sort field. I mean, selecting the primary or secondary author is a completely different issue than how each author is itself sorted against other authors.

But I agree that maybe different publishers, editions, languages, whatever, could use different ways of sorting, (or even NAMING), the very same author. So a per-book setting could be desirable although it can result really, really messy...

Because of your last replies I suppose, (I'll test later nevertheless), that the Calibre main table view is then sorted by the per-book author sort value, not by the global author sort one. Am I right? I mean if I set "Rivera de la Cruz, Marta" in one book but "Cruz, Marta Rivera de la" in another one, when I sort by author both books are going to be quite separated... (As I said a really, really messy issue).

If this situation is what happens (or even the contrary) I'd suggest a possible new enhancement for Calibre: the possibility to switch between both sources in when sorting by author the Calibre main table view. If you ticked/unticked it both books would be sorted either together or separated...

Revision history for this message
Charles Haley (cbhaley) wrote :

Yes, book lists such as the "main view" is sorted by the book's author sort. If it wasn't then that field would be useless.

Authors lists, as in catalogs and the tag browser, are sorted by the author's sort strings, not the books.

If a book's cover says A & B then I think the authors must be listed A & B. You may think otherwise. If so then order the authors however you choose. If the "main author" is B, then I want the book sorted by B even if listed A & B. To do this I must have the ability to change the author sort on a book by book basis.

If you always want the author sort string to be generated from the authors then use bulk metadata edit and tell it to automatically set author sort. That will set the author sort values for all books to what is in the authors info. From then on ensure that the author sort box for a book is green. If it is red then you have either made a mistake or have chosen to use a different sort for that book.

Revision history for this message
arspr (arspr) wrote :

Good point about cover appearance vs. real priority of authors. You have fully convinced me.

Nevertheless I insist in suggesting, (and asking for), an easy and fast way for changing the sorting data source for Author in the Calibre main view.

A detailed example, (although hypothetical and invented):

"Marta Rivera de la Cruz" sort is by default set as the expected Spanish "Rivera de la Cruz, Marta" (and in this way is set through Manage Authors). And therefore I also use that "Rivera de la Cruz, Marta" value in most of her books (green field).

But some of them are English translations and, because of whatever reason, I know that in England Marta is sorted as "Cruz, Marta Rivera de la" and therefore I want to set that specific sorting in those translated books. (Red field in those books).

But when I sort my books by author in the main table view, do I want all Marta's books appearing together or separated?

Neither answer is fully optimal as a default and unmovable decision, so please, let the user easily chose without needing to manually edit all the involved metadata in all the involved books. More over, depending on what I'm looking for, I might want modify the behavior on the fly...

Revision history for this message
Charles Haley (cbhaley) wrote :

That is not something I am interested in doing, as I would never use it.

I will look at adding a formatter function that returns the sort values from the authors table in the order of the authors in the book. If I do this then you could make a custom column containing the alternate order and sort by that.

Or perhaps someone else is interested in implementing your suggestion.

Revision history for this message
arspr (arspr) wrote :

Perfect Charles, I've just tested your new function.

I've used it in a new column which I've called "#global_author_sort". And then, through another one, {:'strcmp(field('#global_author_sort'), field('author_sort'), 'Yes', 'No', 'Yes')'}, I've set up a quick test where I can easily see which books seem to have a bogus Author Sort value.

(Playing with it I've discovered https://bugs.launchpad.net/calibre/+bug/1368928)

Now I have another question: is there a function to call the sorting process Calibre perform in titles? I mean the process Calibre follows to fill "title_sort" from "title" by default. I would like to built up a similar auxiliary column in order to quickly detect possible strange values in "title_sort". Something like:

{:'strcmp(the_function_I_am_asking_about(field('title'), maybe_language_code_also_needed_here), field('title_sort'), 'Yes', 'No', 'Yes')'}

Revision history for this message
Charles Haley (cbhaley) wrote :

No, that function doesn't exist.

You can write your own template function that does this using preference / advanced / template functions. Something like the following should do what you want.

def evaluate(self, formatter, kwargs, mi, locals):
 from calibre.ebooks.metadata import title_sort
 return title_sort(mi.title, order=None, lang=None)

Revision history for this message
arspr (arspr) wrote :

Thanks!!!

(A bit hard it seems, but I suppose when I have some free time I'll try playing with it)

Revision history for this message
arspr (arspr) wrote :

Well, I got it working although I'm not sure if this is the best way or even if I'm making strange things along the way:

The template function I have used has been:

def evaluate(self, formatter, kwargs, mi, locals, lang_code):
 from calibre.ebooks.metadata import title_sort
 return title_sort(mi.title, order=None, lang=lang_code)

(So one extra argument, lang_code, instead of your 0 arguments).

Then the custom column I've built is:

{:'strcmp(title_default_sort(field('languages')), field('title_sort'), 'No', 'Yes', 'No')'}

(I've switched 'Yes' and 'No' because it's prettier this way).

AND IT WORKS!!!!

But I think I've found another possible bug, (although I'm not really sure at all):

In the languages field you can set one or many languages and Calibre seems to set the red/green background in title_sort based on articles determined by the VERY FIRST one (which is a quite logical design decision). So "Spanish, English" is not the same as "English, Spanish". Quite logical, no problems here.

But if you call to 'languages', it always seem to give you the string of used languages in an alphabetical way ("eng, spa"), so you are losing information along the way. And in fact my function fails for "Spanish, English" books because it looks for English articles in the title.

I upload a screenshot with a custom column beside the official "languages" one which shows the possible issue. (Its code is just {languages})

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.