xlcnd / isbnlib

python library to validate, clean, transform and get metadata of ISBN strings (for devs).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Include subtitle from Google Books API

samueljsb opened this issue · comments

Is your feature request related to a problem? Please describe.
Some books have a subtitle. If I look up a book with a subtitle I would like to see that in the returned metadata.

Describe the solution you'd like

>>> import isbnlib
>>> isbnlib.meta("9780141986869")
{'ISBN-13': '9780141986869', 'Title': 'The Econocracy', 'Subtitle': 'On the Perils of Leaving Economics to the Experts', 'Authors': ['Joe Earle', 'Cahal Moran', 'Zach Ward-Perkins'], 'Publisher': 'Penguin Classics', 'Year': '2018', 'Language': 'en'}

Describe alternatives you've considered
I could query Google books myself directly but this would make isbnlib unnecessary. (I would also lose out on the information from openlibrary)

commented

Hi,

I can append that field to 'Title':

{'ISBN-13': '9780141986869', 'Title': 'The Econocracy - On The Perils Of Leaving Economics To The Experts', 'Authors': ['Joe Earle', 'Cahal Moran', 'Zach Ward-Perkins'], 'Publisher': 'Penguin Classics', 'Year': '2018', 'Language': 'en'}

otherwise big changes to the structure of isbnlibare needed!

It looks to me like it could just be added as a line in isbnlib/_goob.py (around line 29):

canonical['Subtitle'] = records.get('subtitle', [u('')])

I was going to submit a PR later today. My concern with just appending it to the title is that it would be difficult to separate them out if either contains a -. It also might be considered a breaking change for some people, whereas an extra key:value pair in the dict that meta returns should be safe.

From a quick glance at the Open Library API docs the same could be added in isbnlib/_openl.py too. I'll check my approach works and open a PR if it does.

commented

Your solution, adding a new field to canonical, probably solves your problem but is not in accord with the rest of the library! The goal is to get metadata according with the Dublin Core standard. So it is better to append that information (when available) to Title.

Some providers do that already (see plugins).

commented

The branch 'dev' already includes this feature. It was in my TODO list for a while!