Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 12-09-2023, 03:02 AM   #1
azuravian
Enthusiast
azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.
 
Posts: 31
Karma: 30848
Join Date: Feb 2012
Device: Kobo Aura One
Adding image to notes

Hello,

I'm creating a plugin that grabs author information and adds it to notes. I've looked through the API documentation and thought I had everything figured out, but I'm running into a wall.

I'm creating an html table that contains various author info. For the picture, I'm using pythons requests module to get image data from a url and then using Calibre's add_notes_resource function to create the resource. I'm using the hash to add an <img> tag to the table.

When the note is created, the img source is empty.

As a test, I had my code print out the final html block that is imported using the import_note function.

This block has the img source, and if I manually take this html block and add it to the note as html source, the image shows up, so I know the resource is being created correctly.

I'm just unsure why the src part of the image tag is being deleted when being imported as a note.
azuravian is offline   Reply With Quote
Old 12-09-2023, 06:23 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Use import_note() to import your html file. Embed the images using data: URLs in the html

Last edited by kovidgoyal; 12-09-2023 at 06:26 AM.
kovidgoyal is offline   Reply With Quote
Old 12-09-2023, 06:40 PM   #3
azuravian
Enthusiast
azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.
 
Posts: 31
Karma: 30848
Join Date: Feb 2012
Device: Kobo Aura One
Ooof, didn't even think about using data: URLs and was banging my head trying to get the notes resources working. Tested data: URLs and everything is great.
azuravian is offline   Reply With Quote
Old 12-10-2023, 03:06 AM   #4
azuravian
Enthusiast
azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.
 
Posts: 31
Karma: 30848
Join Date: Feb 2012
Device: Kobo Aura One
One quick follow-up question to this. Is there a function to completely delete a note? I don't even see a way to do it through the Calibre interface? For now, I'm just replacing the note with an empty note, but that still leaves the author names in the "Book Details" panel as having notes (i.e. they have the pencil icon next to the name).
azuravian is offline   Reply With Quote
Old 12-10-2023, 03:19 AM   #5
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,575
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by azuravian View Post
One quick follow-up question to this. Is there a function to completely delete a note? I don't even see a way to do it through the Calibre interface? For now, I'm just replacing the note with an empty note, but that still leaves the author names in the "Book Details" panel as having notes (i.e. they have the pencil icon next to the name).
Are you sure it's empty.

I got caught by stray white space, now I Ctrl+A in HTML Tab, press Del, then press Ctrl+Numpad-Del. Pencil gone.

BR
BetterRed is offline   Reply With Quote
Old 12-10-2023, 05:30 AM   #6
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by azuravian View Post
One quick follow-up question to this. Is there a function to completely delete a note? I don't even see a way to do it through the Calibre interface? For now, I'm just replacing the note with an empty note, but that still leaves the author names in the "Book Details" panel as having notes (i.e. they have the pencil icon next to the name).
You can delete a note in the Manage categories window for the category. For example, in Book details, right-click on the item, choose "Manage ...", right-click in the note column, select "Delete".

I will look at adding "Delete" to the note context menu in book details. EDIT: change in calibre source.

Last edited by chaley; 12-10-2023 at 06:44 AM. Reason: Change to add delete note to the context menu is in source
chaley is offline   Reply With Quote
Old 12-10-2023, 08:50 AM   #7
azuravian
Enthusiast
azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.
 
Posts: 31
Karma: 30848
Join Date: Feb 2012
Device: Kobo Aura One
Just to clarify, if I delete the entire note from the HTML tab, it does remove the pencil. If I perform a import_note() where the data to import is empty, it removes the content, but does not remove the pencil.

I just tested, and on those where I have cleared the note using the import_note() function, I can open the note, go to HTML and click OK (without changing anything) and the pencil goes away, so there's definitely nothing in there.
azuravian is offline   Reply With Quote
Old 12-10-2023, 09:10 AM   #8
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Importing an empty note does not delete the note it just sets it to an empty document. Use set_notes_for() with an empty document to delete the note instead. importing is meant for importing actual notes.
kovidgoyal is offline   Reply With Quote
Old 12-10-2023, 09:10 AM   #9
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by azuravian View Post
Just to clarify, if I delete the entire note from the HTML tab, it does remove the pencil. If I perform a import_note() where the data to import is empty, it removes the content, but does not remove the pencil.

I just tested, and on those where I have cleared the note using the import_note() function, I can open the note, go to HTML and click OK (without changing anything) and the pencil goes away, so there's definitely nothing in there.
I assume you are calling import_note() via your plugin on a book open in the book details pane. Are you telling the GUI that you changed something? Book details won't know otherwise. You can tell the GUI that some field changed using
Code:
gui.do_field_item_value_changed()
I suspect that the pencil will go away if you select a different book then select the original again, which is another way of refreshing the GUI.
chaley is offline   Reply With Quote
Old 12-10-2023, 09:12 AM   #10
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
And yes you have ot refresh the gui after deleting as charles points out.
kovidgoyal is offline   Reply With Quote
Old 12-12-2023, 12:18 AM   #11
azuravian
Enthusiast
azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.
 
Posts: 31
Karma: 30848
Join Date: Feb 2012
Device: Kobo Aura One
Thank you everyone. This got everything sorted.
azuravian is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
adding notes to books while reading sabri Calibre 4 12-06-2018 09:57 PM
Highlighting and Adding Notes in Caliber light1 Calibre 0 08-25-2013 02:50 PM
Restrictions with adding notes to books lockheed Amazon Kindle 4 10-12-2012 11:00 AM
Adding notes 20LEgend Amazon Kindle 5 02-10-2011 03:56 PM
Reader for adding notes? kingofaces Which one should I buy? 1 11-30-2010 12:15 PM


All times are GMT -4. The time now is 12:06 PM.


MobileRead.com is a privately owned, operated and funded community.