12-12-2010, 10:46 AM | #91 |
Calibre Plugins Developer
Posts: 4,636
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
|
12-12-2010, 11:39 AM | #92 |
Calibre Plugins Developer
Posts: 4,636
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
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')) 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? |
Advert | |
|
12-12-2010, 11:47 AM | #93 |
creator of calibre
Posts: 43,842
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
title = u"De l'inconv\xe9nient d'\xeatre n\xe9"
|
12-12-2010, 12:33 PM | #94 |
Calibre Plugins Developer
Posts: 4,636
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
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")) |
12-12-2010, 12:40 PM | #95 |
creator of calibre
Posts: 43,842
Karma: 22666666
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.
|
Advert | |
|
12-12-2010, 02:46 PM | #96 |
Calibre Plugins Developer
Posts: 4,636
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
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. Last edited by kiwidude; 12-12-2010 at 03:21 PM. Reason: Bug-fix |
12-12-2010, 03:17 PM | #97 |
Zealot
Posts: 118
Karma: 10
Join Date: Dec 2008
Location: France
Device: None
|
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 --------------------------- |
12-12-2010, 03:22 PM | #98 | |
Calibre Plugins Developer
Posts: 4,636
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
Quote:
|
|
12-12-2010, 03:36 PM | #99 |
Zealot
Posts: 118
Karma: 10
Join Date: Dec 2008
Location: France
Device: None
|
Brilliant ! Works like a charm now.
Thanks a lot kiwidude, and thanks to Kovid ! |
12-13-2010, 10:26 AM | #100 |
Addict
Posts: 219
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 10:31 AM. |
12-14-2010, 07:44 AM | #101 | |
Grand Sorcerer
Posts: 9,707
Karma: 32763414
Join Date: Dec 2008
Location: Krewerd
Device: Pocketbook Inkpad 4 Color; Samsung Galaxy Tab S6
|
Quote:
|
|
12-14-2010, 11:32 AM | #102 |
Book Worm
Posts: 116
Karma: 158766
Join Date: Dec 2010
Device: Kindle Paperwhite, iPad Air, iPad Mini, 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. |
12-14-2010, 11:42 AM | #103 | |
Calibre Plugins Developer
Posts: 4,636
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
Quote:
|
|
12-14-2010, 11:50 AM | #104 |
Book Worm
Posts: 116
Karma: 158766
Join Date: Dec 2010
Device: Kindle Paperwhite, iPad Air, iPad Mini, iPod Touch 5
|
Thanks. I found it.
|
12-15-2010, 01:38 PM | #105 | |
Addict
Posts: 378
Karma: 3102
Join Date: Dec 2010
Location: EU
Device: Kobo Aura ONE, Kobo Libra H20
|
Quote:
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. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Custom external commands in the GUI | janvanmaar | Calibre | 18 | 11-28-2010 10:35 AM |
Calibre GUI behavior between machines | phenomshel | Calibre | 2 | 08-21-2010 06:28 PM |
Calibre 0.6.10 GUI crashes on startup | Wagenius | Calibre | 1 | 09-03-2009 01:53 AM |
--breadth-first option in calibre GUI | osmo79 | Calibre | 1 | 05-30-2009 11:45 AM |
Calibre GUI crash on convert | aapezzuto | Calibre | 1 | 08-02-2008 06:39 PM |