DobyTang / LazyLibrarian

This project isn't finished yet. Goal is to create a SickBeard, CouchPotato, Headphones-like application for ebooks. Headphones is used as a base, so there are still a lot of references to it.
729 stars 72 forks source link

Question: Book Genre #1658

Closed yabdali closed 5 years ago

yabdali commented 5 years ago

How can we get the books genre fetched? I see its available in the book info editor but its not populated. I understand that good API provides mainCategory in the response. zif I configure LL with Google API, how can I get my book info updated? I checked LL API commands but can't see an option updated books info.

philborman commented 5 years ago

Goodreads doesn't do genre, at least not in it's api, might be in the html? Googlebooks we look for "genre" in it's response, but there doesn't seem to be any genre. Maybe there used to be? No sign of "mainCategory" either, just "categories" which could easily be added eg https://www.googleapis.com/books/v1/volumes?q=inauthor:tom+holt

Just had a quick look at the code in gb.py and it looks like we should pick up categories[0] as genre in googlebooks

yabdali commented 5 years ago

Here's one example with maincategory. It would be helpful to have category reflected through the OPDS feed by category simialr to by author.

https://www.googleapis.com/books/v1/volumes?q=isbn:9780553804577

philborman commented 5 years ago

Do you get different xml to me? maybe it's geographically specific? I get... "pageCount": 326, "printType": "BOOK", "categories": [ "Business & Economics" ], I get "categories" in the xml no sign of "maincategory" Also I only ever seem to get one category per book even though "categories" is plural and the data is set up as a list. Lazylibrarian picks up the first entry in the list as "bookgenre" in googlebooks interface, but at the moment doesn't use or display the info anywhere.

I can add an option to the opds feed for this, will only appear if there are any genres stored in the books table, either manually added or from googlebooks.

Might be possible to read genre from googlebooks if using the goodreads interface, but it's an additional api call for each book which is slow, and also we need to consider the daily api limits.

yabdali commented 5 years ago

Sorry, I had missed that. I have seen it somewhere in the examples but it doesnt look to appear in the response when I make an API call. https://developers.google.com/books/docs/v1/reference/volumes

The API description for the response is below.

{ "kind": "books#volume", "id": string, "etag": string, "selfLink": string, "volumeInfo": { "title": string, "subtitle": string, "authors": [ string ], "publisher": string, "publishedDate": string, "description": string, "industryIdentifiers": [ { "type": string, "identifier": string } ], "pageCount": integer, "dimensions": { "height": string, "width": string, "thickness": string }, "printType": string, "mainCategory": string, "categories": [ string ], "averageRating": double, "ratingsCount": integer, "contentVersion": string, "imageLinks": { "smallThumbnail": string, "thumbnail": string, "small": string, "medium": string, "large": string, "extraLarge": string }, "language": string, "previewLink": string, "infoLink": string, "canonicalVolumeLink": string }, "userInfo": { "review": mylibrary.reviews Resource, "readingPosition": mylibrary.readingpositions Resource, "isPurchased": boolean, "isPreordered": boolean, "updated": datetime }, "saleInfo": { "country": string, "saleability": string, "onSaleDate": datetime, "isEbook": boolean, "listPrice": { "amount": double, "currencyCode": string }, "retailPrice": { "amount": double, "currencyCode": string }, "buyLink": string }, "accessInfo": { "country": string, "viewability": string, "embeddable": boolean, "publicDomain": boolean, "textToSpeechPermission": string, "epub": { "isAvailable": boolean, "downloadLink": string, "acsTokenLink": string }, "pdf": { "isAvailable": boolean, "downloadLink": string, "acsTokenLink": string }, "webReaderLink": string, "accessViewStatus": string, "downloadAccess": { "kind": "books#downloadAccessRestriction", "volumeId": string, "restricted": boolean, "deviceAllowed": boolean, "justAcquired": boolean, "maxDownloadDevices": integer, "downloadsAcquired": integer, "nonce": string, "source": string, "reasonCode": string, "message": string, "signature": string } }, "searchInfo": { "textSnippet": string } }

philborman commented 5 years ago

Just added genre to the opds server. Only appears as an option if there are any books with genre in you library, so need to either manually add genre, or use googlebooks instead of goodreads.

googlebooks doesn't do series though, so at the moment you can have series or genre, not both :-(

yabdali commented 5 years ago

Thanks a lot, I have set Google Books but it only adds genre of new books. I need to update my existing books genre. Is there a way a part from doing it manually? I have checked OPDS /opds?cmd=Genres but no books are list, I run SQL query to filter the books with genre but only it filters the books that their status set to skipped.

philborman commented 5 years ago

The genre will get added to existing googlebooks when each author refreshes, or you can hit the "refresh active authors" button. If the books were originally imported from goodreads they will not get a genre unless you do it manually as goodreads doesn't include one, and we can't easily include a googlebooks genre on a goodreads book as it would involve an additional api call for every book

/opds?cmd=Genres will only show genres of books marked "Open" as the opds server only shows you books you can download from the library