wars2k / booktracker

Selfhosted app for organizing your library and tracking your reading habits.
MIT License
42 stars 1 forks source link

Error retrieving book info #11

Open CrowMash opened 1 year ago

CrowMash commented 1 year ago

Hi! Thanks a lot for this project!

Just found something weird, when I search "Max Brooks Attaques", some infos are missing. In the response from /api/books/new I get that :

{
  "title": "Attaques répertoriées",
  "author": null,
  "publisher": null,
  "publishedDate": "2015-11-12",
  "imageLink": null,
  "description": "Ceux qui n'apprennent rien du passé sont condamnés à le répéter. Depuis l'âge de pierre jusqu'à celui de l'information, les morts-vivants ont menacé d'engloutir l'humanité. Ils arrivent. Ils ont faim. N'attendez pas qu'ils vous surprennent ! Vous trouverez ici les principales attaques zombies recensées depuis l'aube de l'humanité. Dans la savane africaine, contre les légions romaines, en haute mer avec Francis Drake, chaque civilisation a dû les affronter. Autant de leçons à méditer et à retenir. Organisez-vous avant qu'ils se soulèvent. Recueillies par le plus grand spécialiste mondial des zombies, ces Attaques répertoriées nous révèlent de quelle manière d'autres cultures ont fait face et survécu à cet immémorial fléau viral. Cette immersion dans les horreurs du passé permettra peut-être de nous préparer face à celles de demain.",
  "pageCount": "144",
  "id": "aIMZjwEACAAJ",
  "isbn": [
    {
      "type": "ISBN_10",
      "identifier": "225318392X"
    },
    {
      "type": "ISBN_13",
      "identifier": "9782253183921"
    }
  ],
  "categories": null
}

But when I search on Google Books : here, infos are not missing :

image

wars2k commented 1 year ago

Hello,

After looking into this issue it seems like a glitch/defect with the Google Books API.

The /api/book/new endpoint queries the Google Books API with this URL: https://www.googleapis.com/books/v1/volumes?q=Max+Brooks+Attaques. As you pointed out, the third response lacks a publisher and author. Interestingly, if you search for the third response's Google Books ID ("aIMZjwEACAAJ") directly through the API, more info is included:

https://www.googleapis.com/books/v1/volumes/aIMZjwEACAAJ

Response:

{
    "kind": "books#volume",
    "id": "aIMZjwEACAAJ",
    "etag": "7txxEWZ0DCs",
    "selfLink": "https://www.googleapis.com/books/v1/volumes/aIMZjwEACAAJ",
    "volumeInfo": {
        "title": "Attaques répertoriées",
        "authors": [
            "Max Brooks"
        ],
        "publisher": "LGF/Le Livre de Poche",
        "publishedDate": "2015",
        "description": "<long description...>",
        "industryIdentifiers": [
            {
                "type": "ISBN_10",
                "identifier": "225318392X"
            },
            {
                "type": "ISBN_13",
                "identifier": "9782253183921"
            }
        ],
        "readingModes": {
            "text": false,
            "image": false
        },
        "pageCount": 144,
        "printedPageCount": 144,
        "dimensions": {
            "height": "21.00 cm",
            "width": "14.70 cm",
            "thickness": "1.20 cm"
        },
        "printType": "BOOK",
        "maturityRating": "NOT_MATURE",
        "allowAnonLogging": false,
        "contentVersion": "preview-1.0.0",
        "language": "fr",
        "previewLink": "http://books.google.com/books?id=aIMZjwEACAAJ&hl=&source=gbs_api",
        "infoLink": "https://play.google.com/store/books/details?id=aIMZjwEACAAJ&source=gbs_api",
        "canonicalVolumeLink": "https://play.google.com/store/books/details?id=aIMZjwEACAAJ"
    },
...

As you can see, author and publisher are included (though category & image link are still missing).

In Booktracker, the 1st Google Books API endpoint is used for searching for books, and the 2nd one is used for saving them. This means that although author and publisher won't show up when searching for this book, they will still get added automatically when you save the book to your list. As for the missing category and images, I think some Google Books records just don't have those at all.

Thanks for pointing this out. I'm not sure if fixing it is feasible since it seems to be a rare issue with the Google Books API that is mostly resolved after saving the book, but I'm happy to discuss it more if you'd like.

CrowMash commented 1 year ago

In Booktracker, the 1st Google Books API endpoint is used for searching for books, and the 2nd one is used for saving them. This means that although author and publisher won't show up when searching for this book, they will still get added automatically when you save the book to your list. As for the missing category and images, I think some Google Books records just don't have those at all.

You were right, after saving the book, all the informations avaible on Google Books were there.

Thanks for pointing this out. I'm not sure if fixing it is feasible since it seems to be a rare issue with the Google Books API that is mostly resolved after saving the book, but I'm happy to discuss it more if you'd like.

Maybe you could use the first API call to get IDs and the second one to get data for every IDs you got.

A feature request that could be very useful too: add a pagination on search, because showing only 12 results can be not enough sometime.

Again, thanks for this project!