Amazon plugin: Use latin1 rather than utf-8 as URL encoding

This commit is contained in:
Kovid Goyal 2011-04-10 10:42:43 -06:00
parent 0c755dedf1
commit 624bb54a49
4 changed files with 126 additions and 94 deletions

View File

@ -1038,6 +1038,17 @@ class Server(PreferencesPlugin):
'give you access to your calibre library from anywhere, ' 'give you access to your calibre library from anywhere, '
'on any device, over the internet') 'on any device, over the internet')
class MetadataSources(PreferencesPlugin):
name = 'Metadata download'
icon = I('metadata.png')
gui_name = _('Metadata download')
category = 'Sharing'
gui_category = _('Sharing')
category_order = 4
name_order = 3
config_widget = 'calibre.gui2.preferences.metadata_sources'
description = _('Control how calibre downloads ebook metadata from the net')
class Plugins(PreferencesPlugin): class Plugins(PreferencesPlugin):
name = 'Plugins' name = 'Plugins'
icon = I('plugins.png') icon = I('plugins.png')
@ -1076,6 +1087,9 @@ plugins += [LookAndFeel, Behavior, Columns, Toolbar, Search, InputOptions,
CommonOptions, OutputOptions, Adding, Saving, Sending, Plugboard, CommonOptions, OutputOptions, Adding, Saving, Sending, Plugboard,
Email, Server, Plugins, Tweaks, Misc, TemplateFunctions] Email, Server, Plugins, Tweaks, Misc, TemplateFunctions]
if test_eight_code:
plugins.append(MetadataSources)
#}}} #}}}

View File

@ -341,9 +341,9 @@ class Amazon(Source):
# Insufficient metadata to make an identify query # Insufficient metadata to make an identify query
return None return None
utf8q = dict([(x.encode('utf-8'), y.encode('utf-8')) for x, y in latin1q = dict([(x.encode('latin1'), y.encode('latin1')) for x, y in
q.iteritems()]) q.iteritems()])
url = 'http://www.amazon.%s/s/?'%domain + urlencode(utf8q) url = 'http://www.amazon.%s/s/?'%domain + urlencode(latin1q)
return url return url
# }}} # }}}

View File

@ -7,5 +7,14 @@ __license__ = 'GPL v3'
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>' __copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
from calibre.gui2.preferences.metadata_sources_ui import Ui_Form
class ConfigWidget(ConfigWidgetBase, Ui_Form):
pass
if __name__ == '__main__':
from PyQt4.Qt import QApplication
app = QApplication([])
test_widget('Interface', 'Behavior')

View File

@ -1,18 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>StackedWidget</class> <class>Form</class>
<widget class="QStackedWidget" name="StackedWidget"> <widget class="QWidget" name="Form">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>766</width> <width>781</width>
<height>447</height> <height>300</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>StackedWidget</string> <string>Form</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QStackedWidget" name="stack">
<widget class="QWidget" name="page"> <widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" rowspan="5"> <item row="0" column="0" rowspan="5">
@ -20,7 +26,7 @@
<property name="title"> <property name="title">
<string>Metadata sources</string> <string>Metadata sources</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
@ -110,7 +116,10 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="page"/> <widget class="QWidget" name="page_2"/>
</widget>
</item>
</layout>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>