LuloDev / logseq-book-fetch

Logseq plugin that fetches book data based on an ISBN using the Google Books API.
MIT License
5 stars 0 forks source link

Issue with Book Fetch Plugin: Description Not Displaying #4

Closed salsan closed 1 week ago

salsan commented 1 week ago

Hello,

I've tried using your Book Fetch plugin (version 0.5.1) with Logseq (version 0.10.9), but I'm encountering an issue where it doesn't display the text at the end. Here's what I'm seeing:

image

image

This is default value of logseq-book-fetch.json


 {
  "template": "- ![Book Cover]({{thumbnail}})\n- Title: {{title}}\n- ISBN: {{isbn}}\n- Authors: {{authors}}\n- Published At: {{publishedAt}}\n- Categories: {{categories}}\n- Pages: {{pages}}\n- Language: {{language}}\n- Publisher: {{publisher}}\n- Maturity Rating: {{maturityRating}}\n- Description: {{description}}",
  "disabled": false
}

This is raw text of page

- ![Book Cover](http://books.google.com/books/content?id=eVzfswEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api)
  - Title: Clean code. Guida per diventare bravi artigiani nello sviluppo agile di software
  - ISBN: 8850334389
  - Authors: Robert C. Martin
  - Published At: 1/1/2018
  - Categories: Computers
  - Pages: 435
  - Language: it
  - Publisher: Guida completa
  - Maturity Rating: NOT_MATURE
  - Description: N/A
  - 

The plugin seems to fetch the book information correctly, but the description field shows "N/A" instead of the actual text. Am I missing a step in the setup, or could this be a bug?

Additionally, if I edit the raw text and remove the last "-", the markdown displays correctly.

Thank you for your help!

LuloDev commented 1 week ago

Thank you for reporting the issue. It seems that the description information is not being retrieved due to the specific Google Books API endpoint I’m using. I’ve found a different endpoint that provides the full details, including the description. I will be working on updating the plugin to incorporate this and improve the overall functionality.

LuloDev commented 1 week ago

@salsan Could you let me know which operating system you're using? I believe the issue might be related to line breaks. There seems to be a bug where I'm using \n in Windows, but it appears to work as \\n in Linux within the template.

salsan commented 1 week ago

I am under Windows 10 [Version 10.0.19045.4894]

LuloDev commented 1 week ago

It seems like the issue is with how the line breaks are handled in the configuration file. If you're editing your configuration directly in the settings.json, try updating it like this:

{
  "template": "- ![Book Cover]({{thumbnail}})\\n- Title: {{title}}\\n- ISBN: {{isbn}}\\n- Authors: {{authors}}\\n- Published At: {{publishedAt}}\\n- Categories: {{categories}}\\n- Pages: {{pages}}\\n- Language: {{language}}\\n- Publisher: {{publisher}}\\n- Maturity Rating: {{maturityRating}}\\n- Description: {{description}}",
  "disabled": false
}

Apparently, in the Logseq configuration interface, it shows \n, but it’s stored as \\n in the settings.json file. I’ve edited the default configuration to use \\n in the JSON, but I’m not sure if the update will automatically apply this. You might need to manually edit your settings.json file.

image

image

Additionally, please ensure you update to the latest version of the plugin, as the description information is now being retrieved correctly. Thank you!

image

salsan commented 1 week ago

Confirm now work it , I've edited settings.json and update the plugin tov0.5.2