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, '
'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):
name = 'Plugins'
icon = I('plugins.png')
@ -1076,6 +1087,9 @@ plugins += [LookAndFeel, Behavior, Columns, Toolbar, Search, InputOptions,
CommonOptions, OutputOptions, Adding, Saving, Sending, Plugboard,
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
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()])
url = 'http://www.amazon.%s/s/?'%domain + urlencode(utf8q)
url = 'http://www.amazon.%s/s/?'%domain + urlencode(latin1q)
return url
# }}}

View File

@ -7,5 +7,14 @@ __license__ = 'GPL v3'
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__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,116 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>StackedWidget</class>
<widget class="QStackedWidget" name="StackedWidget">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>766</width>
<height>447</height>
<width>781</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>StackedWidget</string>
<string>Form</string>
</property>
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" rowspan="5">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Metadata sources</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;p&gt;Disable any metadata sources you do not want by unchecking them. You can also set the cover priority. Covers from sources that have a higher (smaller) priority will be preferred when bulk downloading metadata.
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QStackedWidget" name="stack">
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" rowspan="5">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Metadata sources</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;p&gt;Disable any metadata sources you do not want by unchecking them. You can also set the cover priority. Covers from sources that have a higher (smaller) priority will be preferred when bulk downloading metadata.
&lt;p&gt;Double click on a metadata source to customize it.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QTableView" name="sources_list"/>
</item>
</layout>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Downloaded metadata fields</string>
</property>
<property name="wordWrap">
<bool>true</bool>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QListView" name="fields_list">
<property name="toolTip">
<string>If you uncheck any fields, metadata for those fields will not be downloaded</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QCheckBox" name="opt_txt_comments">
<property name="text">
<string>Convert all downloaded comments to plain &amp;text</string>
</property>
</widget>
</item>
<item>
<widget class="QTableView" name="sources_list"/>
<item row="2" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Max. number of &amp;tags to download:</string>
</property>
<property name="buddy">
<cstring>opt_max_tags</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Downloaded metadata fields</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QListView" name="fields_list">
<property name="toolTip">
<string>If you uncheck any fields, metadata for those fields will not be downloaded</string>
<item row="2" column="2">
<widget class="QSpinBox" name="opt_max_tags"/>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Max. &amp;time to wait after first match is found:</string>
</property>
<property name="buddy">
<cstring>opt_wait_after_first_identify_result</cstring>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QSpinBox" name="opt_wait_after_first_identify_result">
<property name="suffix">
<string> secs</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Max. time to wait after &amp;cover is found:</string>
</property>
<property name="buddy">
<cstring>opt_wait_after_first_cover_result</cstring>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QSpinBox" name="opt_wait_after_first_cover_result">
<property name="suffix">
<string> secs</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QCheckBox" name="opt_txt_comments">
<property name="text">
<string>Convert all downloaded comments to plain &amp;text</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Max. number of &amp;tags to download:</string>
</property>
<property name="buddy">
<cstring>opt_max_tags</cstring>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QSpinBox" name="opt_max_tags"/>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Max. &amp;time to wait after first match is found:</string>
</property>
<property name="buddy">
<cstring>opt_wait_after_first_identify_result</cstring>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QSpinBox" name="opt_wait_after_first_identify_result">
<property name="suffix">
<string> secs</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Max. time to wait after &amp;cover is found:</string>
</property>
<property name="buddy">
<cstring>opt_wait_after_first_cover_result</cstring>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QSpinBox" name="opt_wait_after_first_cover_result">
<property name="suffix">
<string> secs</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page"/>
<widget class="QWidget" name="page_2"/>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>