10-14-2022, 09:09 AM | #1 |
Connoisseur
Posts: 93
Karma: 40
Join Date: Mar 2020
Location: Belgium (sorry, I am from the Walloon side of the country and I speak french only)
Device: PW3, Kobo Libra H2O
|
method identify() is inconsistent in providing authors
I am developing a "new" babelio_db plugin. This is a french site with all books in french...
I am developing in the English language to get the messages ( so I can find the sources), and switching to the french language from time to time to check how it goes. calibre interface is in English. When I create an empty book with no authors, it get translated and stored as "unknown"... I then run the plugin, identify() passes authors as None calibre interface is in French. When I create an empty book with no authors, it get translated and stored as "Inconnu(e)"... When running the plugin, identify() passes authors as None so far so good.. Now, I have a book created under calibre in English. I switch to the french interface, the identify() passes the authors as ['Unknown']. That makes a very different result compared to authors = None Same situation in reverse for a french created book under the English interface, except that identify() now returns ['Inconnu(e)']. I have worked around this last situation by forcing authors = ['Inconnu(e)'] to be None, or by wiping out the authors field before starting the metadata download... But I am not sure that this would be the right approach... I am not that fluent with python, but I am learning (when I have time)... I can try to correct that behavior... but I could not find in the calibre sources where the translation from 'unknown', or equivalent in other language, to None is implemented... Thanks in advance for any help |
10-14-2022, 10:04 AM | #2 |
creator of calibre
Posts: 44,174
Karma: 22670164
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Yes, if you switch between interface languages this will happen. This is because calibre requires there to always be an author value as it is used int he filesystem.
If you expect people to be using multiple interface languages with your plugin, with books with unknown authors, simply special case the "Unknown" string for authors in all those languages in the identify method in your plugin. For you likely five or six major european languages is all you need. |
Advert | |
|
10-14-2022, 11:58 AM | #3 |
Connoisseur
Posts: 93
Karma: 40
Join Date: Mar 2020
Location: Belgium (sorry, I am from the Walloon side of the country and I speak french only)
Device: PW3, Kobo Libra H2O
|
OK, fair enough... If that is the normal behavior, I'll make a note in the associated documentation.
Thanks anyway. To be complete this is what I have done in the very first line of identify(): Code:
debug=self.dbg_lvl & 1 if debug: log.info("title : ", title) log.info("identifiers : ", identifiers) log.info("authors : ", authors) nknwn = ['Inconnu(e)', 'Unknown'] for i in range(len(nknwn)): if authors and nknwn[i] in authors[0]: authors = None break if debug: log.info("authors corrected : ", authors) |
10-15-2022, 05:42 AM | #4 |
Chalut o/
Posts: 413
Karma: 145324
Join Date: Dec 2017
Device: Kobo
|
Oh, un plugin babelio, merci, ça sera utile.
You can also retrieve the current translated value of 'Unknown' with Code:
from calibre.ebooks.metadata.book.base import NULL_VALUES Code:
nknwn = ['Inconnu(e)', 'Unknown', NULL_VALUES['authors'][0]] |
10-15-2022, 06:03 AM | #5 | |
Grand Sorcerer
Posts: 11,864
Karma: 7036239
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
mi.is_null('authors') |
|
Advert | |
|
10-15-2022, 08:28 AM | #6 |
creator of calibre
Posts: 44,174
Karma: 22670164
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Those only work for the current translation, which is handled anyway. its when you have an Unknown value translated into something other than the current language that the issue arises.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Regarding using metadata objects in identify method of metadata download plugin api | aprekates | Development | 1 | 07-06-2014 03:35 AM |
Metadata download API , regarding identify method. | aprekates | Development | 1 | 07-04-2014 12:01 PM |
Is Amazon providing samples not available in restricted countries? | lene1949 | Amazon Kindle | 0 | 04-16-2010 11:08 AM |