Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Closed Thread
 
Thread Tools Search this Thread
Old 12-12-2010, 11:46 AM   #91
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,230
Karma: 1345754
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
Quote:
Originally Posted by kovidgoyal View Post
from urllib import quote

quote(title.encode('utf-8))
Legend, thanks Kovid. Will give that a go.
kiwidude is offline  
Old 12-12-2010, 12:39 PM   #92
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,230
Karma: 1345754
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
Ok, not having quite the desired result with this. Here is my test python code:
Code:
#!/usr/bin/env python
# -*- coding: latin-1 -*-
from urllib import quote_plus
title = u"De l'inconvénient d'être né"
print quote_plus(title.encode('utf-8'))
What I would "like" to get (for Amazon to work) as the output is this:
De+l%27inconv%E9nient+d%27%EAtre%20n%E9

But instead what I get is this:
De+l%27inconv%C3%A9nient+d%27%C3%AAtre+n%C3%A9

You can see that é is being turned into %C3%A9 instead of %E9.

Clearly some kind of encoding mismatch going on but this is way out of my comfort zone of knowledge. Any suggestions?
kiwidude is offline  
 
Advertisement
Old 12-12-2010, 12:47 PM   #93
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: 26,437
Karma: 5383257
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
title = u"De l'inconv\xe9nient d'\xeatre n\xe9"
kovidgoyal is offline  
Old 12-12-2010, 01:33 PM   #94
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,230
Karma: 1345754
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
Quote:
Originally Posted by kovidgoyal View Post
title = u"De l'inconv\xe9nient d'\xeatre n\xe9"
Thanks, but now I'm more confused Without changing my string contents I got the above code to work by dropping the u prefix (since as you point out it is not unicode in it's current form) then dropping the ".encode("utf-8")" from the call to quote_plus. "Works" but not useful in terms of Calibre code.

The question I think becomes how do I get the title as it is stored in Calibre into the right encoding combination. In other words, what do I need to "fix" the right result when using something like this:
Code:
title = self.db.title(row)
converted = quote_plus(title.encode("utf-8"))
If I use that code, I end up with the same incorrect result as my test. Head... hurts...
kiwidude is offline  
Old 12-12-2010, 01:40 PM   #95
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: 26,437
Karma: 5383257
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Use encode('latin-1') instead of utf-8. Apparently amazon wants its urls encoded in latin-1 rather than utf-8, which is wrong as per the relevant RFCs, but this is Amazon, so I'm not surprised.
kovidgoyal is offline  
Old 12-12-2010, 03:46 PM   #96
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,230
Karma: 1345754
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
Thanks Kovid for your help and explanation.

Attached is an "experimental" build of v1.2 of the Search The Internet add-in. Once a few people have tried it I will update the original post. To recap for anyone new - this build is to solve the issue of passing foreign language names like "De l'inconvénient d'être né" to certain websites which differ in the way they encode them for searches. As Kovid says above Amazon uses 'latin-1' whereas the web standard seems to be 'utf-8'.

My solution in the attached version 1.2 has been to add an additional parameter to the tuple defining the website menus. This fourth parameter is unsurprisingly "Encoding", for which the default (if you specify None) will be 'utf-8', however this can be overridden for a particular website such as Amazon by specifying 'latin-1'.

One note for people upgrading who already have defined custom menus in tweaks in 'stip_search_internet_menus'. Your tweaks value will be incorrect, as the menu definition will only have 3 columns instead of 4. I suggest you add your additional column values to the tweak before you update the plugin/restart. Copy values from the enclosed readme if in doubt. I have coded in some error handling so if it detects not enough columns in your tweaks it will still run but use utf-8 for all urls.

Please let me know if I have introduced any issues with this change.
Attached Files
File Type: zip SearchTheInternet.zip (71.5 KB, 73 views)

Last edited by kiwidude; 12-12-2010 at 04:21 PM. Reason: Bug-fix
kiwidude is offline  
Old 12-12-2010, 04:17 PM   #97
Bertrand
Connoisseur
Bertrand began at the beginning.
 
Posts: 65
Karma: 10
Join Date: Dec 2008
Location: Paris, France
Device: Nexus 7
I get an error when I try to perform a search, no matter which book/website I select :

ERROR: ERREUR : Exception non traitée: <b>NameError</b>:global name 'TOKEN_AUTHOR' is not defined

Traceback (most recent call last):
File "<string>", line 87, in search_web_link
File "<string>", line 93, in search_web_for_book
NameError: global name 'TOKEN_AUTHOR' is not defined

---------------------------
Bertrand is offline  
Old 12-12-2010, 04:22 PM   #98
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,230
Karma: 1345754
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
Quote:
Originally Posted by Bertrand View Post
I get an error when I try to perform a search, no matter which book/website I select :

ERROR: ERREUR : Exception non traitée: <b>NameError</b>:global name 'TOKEN_AUTHOR' is not defined

Traceback (most recent call last):
File "<string>", line 87, in search_web_link
File "<string>", line 93, in search_web_for_book
NameError: global name 'TOKEN_AUTHOR' is not defined

---------------------------
I did say it was experimental, though not quite that much . Please download again, I have updated the zip.
kiwidude is offline  
Old 12-12-2010, 04:36 PM   #99
Bertrand
Connoisseur
Bertrand began at the beginning.
 
Posts: 65
Karma: 10
Join Date: Dec 2008
Location: Paris, France
Device: Nexus 7
Brilliant ! Works like a charm now.

Thanks a lot kiwidude, and thanks to Kovid !
Bertrand is offline  
Old 12-13-2010, 11:26 AM   #100
janvanmaar
Addict
janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.
 
Posts: 218
Karma: 404
Join Date: Nov 2010
Device: Kindle 3G, Samsung SIII
I have noticed a small problem indirectly related to the GUI plugins:
the customized buttons disappear from the toolbar when a reader is connected by USB. Does anybody else experience this or is it my setup specific?

EDIT: Of course it is just me. I did not notice a special category "The toolbar when a device is connected" in the toolbar customization. Adding the buttons to both categories fixes the problem.

Last edited by janvanmaar; 12-13-2010 at 11:31 AM.
janvanmaar is offline  
Old 12-14-2010, 08:44 AM   #101
Sweetpea
Grand Sorcerer
Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.
 
Sweetpea's Avatar
 
Posts: 8,071
Karma: 22730000
Join Date: Dec 2008
Location: Krewerd
Device: AVTN8; BBMini; Onyx Boox T68; SGN8
Quote:
Originally Posted by janvanmaar View Post
I have noticed a small problem indirectly related to the GUI plugins:
the customized buttons disappear from the toolbar when a reader is connected by USB. Does anybody else experience this or is it my setup specific?

EDIT: Of course it is just me. I did not notice a special category "The toolbar when a device is connected" in the toolbar customization. Adding the buttons to both categories fixes the problem.
Nah, isn't just you. The first time I saw it I was also like: what happened to my bar! I had just removed that and that button and now it's back!?!?!
Sweetpea is offline  
Old 12-14-2010, 12:32 PM   #102
hedwig
Book Worm
hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.
 
hedwig's Avatar
 
Posts: 100
Karma: 151446
Join Date: Dec 2010
Device: Amazon Kindle 3 WiFi, iPad Air, Kobo Glo, iPod Touch 5
Hi,
I am new to Calibre so if someone has already asked this I apologize.
I have a Calibre for Mac and I am trying to install the Barnes and Noble Plugin. The instructions say go to preferences and press the advanced button. However, there is no advanced button in my preferences. Is this because I have a mac and not windows?
Thanks.
hedwig is offline  
Old 12-14-2010, 12:42 PM   #103
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,230
Karma: 1345754
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
Quote:
Originally Posted by hedwig View Post
Hi,
I am new to Calibre so if someone has already asked this I apologize.
I have a Calibre for Mac and I am trying to install the Barnes and Noble Plugin. The instructions say go to preferences and press the advanced button. However, there is no advanced button in my preferences. Is this because I have a mac and not windows?
Thanks.
That means the Advanced section on the dialog (near the bottom), not a button.
kiwidude is offline  
Old 12-14-2010, 12:50 PM   #104
hedwig
Book Worm
hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.hedwig inspires wonder wherever he or she goes.
 
hedwig's Avatar
 
Posts: 100
Karma: 151446
Join Date: Dec 2010
Device: Amazon Kindle 3 WiFi, iPad Air, Kobo Glo, iPod Touch 5
Thanks. I found it.
hedwig is offline  
Old 12-15-2010, 02:38 PM   #105
paulfiera
Addict
paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.
 
paulfiera's Avatar
 
Posts: 339
Karma: 3102
Join Date: Dec 2010
Location: EU
Device: iPad, Kobo Glo
Quote:
Originally Posted by kiwidude View Post
This plugin was designed to allow quick navigation from the selected book/author in Calibre to a choice of websites in your browser.
Fantastic plugin. This is really a lifesaver.

I can see "Search the internet" in the toolbar and it works great but, how can I display it in the context menu? I've copy & pasted your instructions in "Preferences -> Tweaks" but I can't get it to show up.

Many thanks

Paul

Great plugin btw.
paulfiera is offline  
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom external commands in the GUI janvanmaar Calibre 18 11-28-2010 11:35 AM
Calibre GUI behavior between machines phenomshel Calibre 2 08-21-2010 07:28 PM
Calibre 0.6.10 GUI crashes on startup Wagenius Calibre 1 09-03-2009 02:53 AM
--breadth-first option in calibre GUI osmo79 Calibre 1 05-30-2009 12:45 PM
Calibre GUI crash on convert aapezzuto Calibre 1 08-02-2008 07:39 PM


All times are GMT -4. The time now is 11:07 AM.


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