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, 10: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,601
Karma: 2092290
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
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, 11:39 AM   #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,601
Karma: 2092290
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'))
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  
Advert
Old 12-12-2010, 11:47 AM   #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: 43,778
Karma: 22666666
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, 12: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,601
Karma: 2092290
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
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, 12: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: 43,778
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.
kovidgoyal is offline  
Advert
Old 12-12-2010, 02: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,601
Karma: 2092290
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.
Attached Files
File Type: zip SearchTheInternet.zip (71.5 KB, 283 views)

Last edited by kiwidude; 12-12-2010 at 03:21 PM. Reason: Bug-fix
kiwidude is offline  
Old 12-12-2010, 03:17 PM   #97
Bertrand
Zealot
Bertrand began at the beginning.
 
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

---------------------------
Bertrand is offline  
Old 12-12-2010, 03: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,601
Karma: 2092290
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
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, 03:36 PM   #99
Bertrand
Zealot
Bertrand began at the beginning.
 
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 !
Bertrand is offline  
Old 12-13-2010, 10: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: 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.
janvanmaar is offline  
Old 12-14-2010, 07: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: 9,707
Karma: 32763414
Join Date: Dec 2008
Location: Krewerd
Device: Pocketbook Inkpad 4 Color; Samsung Galaxy Tab S6
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, 11:32 AM   #102
hedwig
Book Worm
hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.
 
hedwig's Avatar
 
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.
hedwig is offline  
Old 12-14-2010, 11:42 AM   #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,601
Karma: 2092290
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
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, 11:50 AM   #104
hedwig
Book Worm
hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.hedwig can grok the meaning of the universe.
 
hedwig's Avatar
 
Posts: 116
Karma: 158766
Join Date: Dec 2010
Device: Kindle Paperwhite, iPad Air, iPad Mini, iPod Touch 5
Thanks. I found it.
hedwig is offline  
Old 12-15-2010, 01: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: 378
Karma: 3102
Join Date: Dec 2010
Location: EU
Device: Kobo Aura ONE, Kobo Libra H20
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 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


All times are GMT -4. The time now is 02:42 AM.


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