Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 10-27-2023, 09:33 AM   #46
lidans
Junior Member
lidans began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jan 2020
Device: oboox notepro 10.3
is it possible some how to use this plugin to send all my library data to obsidian?
(even if no highlights)
lidans is offline   Reply With Quote
Old 10-31-2023, 05:51 PM   #47
jm289765
Enthusiast
jm289765 began at the beginning.
 
Posts: 25
Karma: 10
Join Date: Jan 2023
Device: calibre
Quote:
Originally Posted by lidans View Post
is it possible some how to use this plugin to send all my library data to obsidian?
(even if no highlights)
H2O doesn't have a way to send all of your library data to Obsidian.

It could be modified to send data from books instead of from highlights by giving highlight_sender.HighlightSender a list of books or the entire library instead of a list of annotations. But you would have to make a lot of other changes to make that work. And you would lose the highlight-specific formatting options.

If you want to try modifying the plugin, these two functions might be good places to start:

The function that manages the highlight sending process: highlight_sender.HighlightSender.send()
https://github.com/jm289765/highligh...r.py#L703-L727

A helper function that all the "Send Highlights" buttons use for setting up a HighlightSender and sending highlights:
https://github.com/jm289765/highligh...actions.py#L27
jm289765 is offline   Reply With Quote
Old 12-04-2023, 09:09 AM   #48
BertMv
Member
BertMv began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Sep 2023
Device: Kobo Clara HD
Whenever I send highlights, instead of opening Obsidian, it opens Firefox which then asks me if I want to open Obsidian.
I have the mime-types correctly setup since I can use the obsidian:// scheme from other programs and the command line and then it does correctly open obsidian directly.
BertMv is offline   Reply With Quote
Old 12-05-2023, 12:16 PM   #49
jm289765
Enthusiast
jm289765 began at the beginning.
 
Posts: 25
Karma: 10
Join Date: Jan 2023
Device: calibre
Quote:
Originally Posted by BertMv View Post
Whenever I send highlights, instead of opening Obsidian, it opens Firefox which then asks me if I want to open Obsidian.
I have the mime-types correctly setup since I can use the obsidian:// scheme from other programs and the command line and then it does correctly open obsidian directly.
This could have something to do with H2O using Python's webbrowser.open() to open Obsidian URIs. After looking at the documentation, you might have a BROWSER environment variable that's being used instead of Obsidian. I think BROWSER is mostly only used on Linux operating systems, but I'm not sure. My Windows 11 computer doesn't seem to use it.

You might be able to change Firefox's settings to open obsidian links automatically instead of asking.

You could also try manually modifying H2O to use os.system() instead of webbrowser.open().
jm289765 is offline   Reply With Quote
Old 12-06-2023, 06:04 AM   #50
BertMv
Member
BertMv began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Sep 2023
Device: Kobo Clara HD
Quote:
Originally Posted by jm289765 View Post
I think BROWSER is mostly only used on Linux operating systems, but I'm not sure. My Windows 11 computer doesn't seem to use it.

You might be able to change Firefox's settings to open obsidian links automatically instead of asking.

You could also try manually modifying H2O to use os.system() instead of webbrowser.open().
I am indeed on Linux. I tried changing the firefox settings before. The only thing this does for me, is that it no longer asks, but still doesn't open obsidian automatically. I need to press the "goto url" button manually.
I will try to change H2O next weekend and let you know if that solves it for me.
BertMv is offline   Reply With Quote
Old 12-06-2023, 06:49 AM   #51
BertMv
Member
BertMv began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Sep 2023
Device: Kobo Clara HD
I decided to try it now as I had a bit of time. I made the following change:

Code:
        #webbrowser.open(uri)
        os.system("xdg-open \"" + uri + "\"")
And obviously had to import os.

This works like a charm now.

Perhaps add an option that enables people to set the used method? I could see if I can do it and send you a pull request? (when i have the time, which might be next year, )
BertMv is offline   Reply With Quote
Old 12-07-2023, 11:51 AM   #52
jm289765
Enthusiast
jm289765 began at the beginning.
 
Posts: 25
Karma: 10
Join Date: Jan 2023
Device: calibre
Quote:
Originally Posted by BertMv View Post
Perhaps add an option that enables people to set the used method? I could see if I can do it and send you a pull request? (when i have the time, which might be next year, )
I was going to write a comment about some things to consider when adding the new option, but then decided to add it myself.

I replaced os.system() with subprocess.run() because it has better error handling, so I need you to test this to make sure it still works for you. Then I'll update H2O to 1.4.1.
Attached Files
File Type: zip h2o-1.4.1-wip.zip (34.4 KB, 50 views)
jm289765 is offline   Reply With Quote
Old 12-11-2023, 04:49 AM   #53
BertMv
Member
BertMv began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Sep 2023
Device: Kobo Clara HD
I am sorry for the late reply, I wasn't at home this weekend.

I am getting the following error with this one:

Code:
calibre, version 7.1.0
ERROR: Unhandled exception: <b>CalledProcessError</b>:Command '['xdg-open', 'obsidian://new?vault=My%20Vault&amp;file=Books%2FBehold%20the%20Man%20by%20Michael%20Moorcock&amp;content=%0A%5BHighlighted%5D%28calibre%3A%2F%2Fview-book%2FCalibre-Library%2F111%2FEPUB%3Fopen_at%3Depubcfi%28%2F10%2F2%2F4%2F8%2F1%3A0%29%29%20on%202023-12-11%20at%2009%3A44%3A38%20UTC%3A%0A%3E%20Michael%20Moorcock%20is%20a%20wondrous%20man%2C%20twice%20the%20size%20of%20any%20of%20us%2C%20with%20a%20beard%20like%20Father%20Time%20and%20the%20ability%20to%20practically%20kill%20himself%20for%20that%20which%20he%20loves%20and%0A%0A---%0A&amp;append=true']' returned non-zero exit status 1.

calibre 7.1  embedded-python: True
Linux-6.6.5-arch1-1-x86_64-with-glibc2.38 Linux ('64bit', 'ELF')
('Linux', '6.6.5-arch1-1', '#1 SMP PREEMPT_DYNAMIC Fri, 08 Dec 2023 17:06:25 +0000')
Python 3.11.5
Interface language: None
Successfully initialized third party plugins: Highlights to Obsidian (1, 4, 1) && Kobo Utilities (2, 16, 11)
Traceback (most recent call last):
  File "calibre_plugins.highlights_to_obsidian.menu_button", line 87, in resend
    b_acts.resend_highlights(self.gui, self.gui.current_db.new_api)
  File "calibre_plugins.highlights_to_obsidian.button_actions", line 224, in resend_highlights
    send_highlights(parent, db, condition=highlight_send_condition, update_send_time=False)
  File "calibre_plugins.highlights_to_obsidian.button_actions", line 66, in send_highlights
    amt = sender.send(condition=condition)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "calibre_plugins.highlights_to_obsidian.highlight_sender", line 730, in send
    send_item_to_obsidian(self.make_obsidian_data(note[0], note[1]))
  File "calibre_plugins.highlights_to_obsidian.highlight_sender", line 30, in send_item_to_obsidian
    subprocess.run(['xdg-open', uri], check=True, shell=True)
  File "subprocess.py", line 571, in run
subprocess.CalledProcessError: Command '['xdg-open', 'obsidian://new?vault=My%20Vault&file=Books%2FBehold%20the%20Man%20by%20Michael%20Moorcock&content=%0A%5BHighlighted%5D%28calibre%3A%2F%2Fview-book%2FCalibre-Library%2F111%2FEPUB%3Fopen_at%3Depubcfi%28%2F10%2F2%2F4%2F8%2F1%3A0%29%29%20on%202023-12-11%20at%2009%3A44%3A38%20UTC%3A%0A%3E%20Michael%20Moorcock%20is%20a%20wondrous%20man%2C%20twice%20the%20size%20of%20any%20of%20us%2C%20with%20a%20beard%20like%20Father%20Time%20and%20the%20ability%20to%20practically%20kill%20himself%20for%20that%20which%20he%20loves%20and%0A%0A---%0A&append=true']' returned non-zero exit status 1.
I may be wrong, but I suspect the uri needs to be enclosed in quotes?
BertMv is offline   Reply With Quote
Old 12-11-2023, 04:53 AM   #54
BertMv
Member
BertMv began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Sep 2023
Device: Kobo Clara HD
I replied before but it somehow failed I think.
This version gives me the following error:

Code:
calibre, version 7.1.0
ERROR: Unhandled exception: <b>CalledProcessError</b>:Command '['xdg-open', 'obsidian://new?vault=My%20Vault&amp;file=Books%2FBehold%20the%20Man%20by%20Michael%20Moorcock&amp;content=%0A%5BHighlighted%5D%28calibre%3A%2F%2Fview-book%2FCalibre-Library%2F111%2FEPUB%3Fopen_at%3Depubcfi%28%2F10%2F2%2F4%2F8%2F1%3A0%29%29%20on%202023-12-11%20at%2009%3A44%3A38%20UTC%3A%0A%3E%20Michael%20Moorcock%20is%20a%20wondrous%20man%2C%20twice%20the%20size%20of%20any%20of%20us%2C%20with%20a%20beard%20like%20Father%20Time%20and%20the%20ability%20to%20practically%20kill%20himself%20for%20that%20which%20he%20loves%20and%0A%0A---%0A&amp;append=true']' returned non-zero exit status 1.

calibre 7.1  embedded-python: True
Linux-6.6.5-arch1-1-x86_64-with-glibc2.38 Linux ('64bit', 'ELF')
('Linux', '6.6.5-arch1-1', '#1 SMP PREEMPT_DYNAMIC Fri, 08 Dec 2023 17:06:25 +0000')
Python 3.11.5
Interface language: None
Successfully initialized third party plugins: Highlights to Obsidian (1, 4, 1) && Kobo Utilities (2, 16, 11)
Traceback (most recent call last):
  File "calibre_plugins.highlights_to_obsidian.menu_button", line 87, in resend
    b_acts.resend_highlights(self.gui, self.gui.current_db.new_api)
  File "calibre_plugins.highlights_to_obsidian.button_actions", line 224, in resend_highlights
    send_highlights(parent, db, condition=highlight_send_condition, update_send_time=False)
  File "calibre_plugins.highlights_to_obsidian.button_actions", line 66, in send_highlights
    amt = sender.send(condition=condition)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "calibre_plugins.highlights_to_obsidian.highlight_sender", line 730, in send
    send_item_to_obsidian(self.make_obsidian_data(note[0], note[1]))
  File "calibre_plugins.highlights_to_obsidian.highlight_sender", line 30, in send_item_to_obsidian
    subprocess.run(['xdg-open', uri], check=True, shell=True)
  File "subprocess.py", line 571, in run
subprocess.CalledProcessError: Command '['xdg-open', 'obsidian://new?vault=My%20Vault&file=Books%2FBehold%20the%20Man%20by%20Michael%20Moorcock&content=%0A%5BHighlighted%5D%28calibre%3A%2F%2Fview-book%2FCalibre-Library%2F111%2FEPUB%3Fopen_at%3Depubcfi%28%2F10%2F2%2F4%2F8%2F1%3A0%29%29%20on%202023-12-11%20at%2009%3A44%3A38%20UTC%3A%0A%3E%20Michael%20Moorcock%20is%20a%20wondrous%20man%2C%20twice%20the%20size%20of%20any%20of%20us%2C%20with%20a%20beard%20like%20Father%20Time%20and%20the%20ability%20to%20practically%20kill%20himself%20for%20that%20which%20he%20loves%20and%0A%0A---%0A&append=true']' returned non-zero exit status 1.
I suspect the uri needs to be enclosed in quotes?
BertMv is offline   Reply With Quote
Old 12-11-2023, 04:57 AM   #55
BertMv
Member
BertMv began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Sep 2023
Device: Kobo Clara HD
For some reason my replies get deleted. (This is the 3rd time trying).
I get an error with this version. I suspect the uri needs to be enclosed in quotes.

Code:
subprocess.CalledProcessError: Command '['xdg-open', 'obsidian://new?vault= .......

 returned non-zero exit status 1.
BertMv is offline   Reply With Quote
Old 12-11-2023, 05:02 AM   #56
BertMv
Member
BertMv began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Sep 2023
Device: Kobo Clara HD
The full error message is here: https://pastebin.com/8xe7gDHm
BertMv is offline   Reply With Quote
Old 12-16-2023, 09:54 AM   #57
jm289765
Enthusiast
jm289765 began at the beginning.
 
Posts: 25
Karma: 10
Join Date: Jan 2023
Device: calibre
Quote:
Originally Posted by BertMv View Post
I get an error with this version. I suspect the uri needs to be enclosed in quotes.
Here's a version that uses os.system() instead of subprocess.run(). I added some conditionals to check operating system to fix the problem of bad error messages.
Attached Files
File Type: zip h2o-1.4.1-wip-2.zip (34.4 KB, 83 views)
jm289765 is offline   Reply With Quote
Old 12-17-2023, 04:44 AM   #58
BertMv
Member
BertMv began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Sep 2023
Device: Kobo Clara HD
Quote:
Originally Posted by jm289765 View Post
Here's a version that uses os.system() instead of subprocess.run(). I added some conditionals to check operating system to fix the problem of bad error messages.
Yes! That one works for me. Thank you so much.
BertMv is offline   Reply With Quote
Old 12-18-2023, 11:29 PM   #59
Aaronhoma
Junior Member
Aaronhoma began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Aug 2022
Device: none
First of all, I really appreciate your work. Thanks!

As I use different colors in the highlight section for different purposes and usages, I've named every color of Highlights with a specific name. Names such as "Dictionary", "Anki", "ZettleKasten", "Quote" and so on.
So, It would be great to have an option like 'HighlightStyleName' in formatting options.
Aaronhoma is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
KOReader Highlights in Obsidian Edo78 KOReader 5 10-30-2023 09:12 PM
[GUI Plugin] Noosfere_util, a companion plugin to noosfere DB lrpirlet Plugins 2 08-18-2022 03:15 PM
[GUI Plugin] Save Virtual Libraries To Column (GUI) chaley Plugins 14 04-04-2021 05:25 AM
[GUI Plugin] Plugin Updater **Deprecated** kiwidude Plugins 159 06-19-2011 12:27 PM


All times are GMT -4. The time now is 01:26 AM.


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