From 624bb54a4956f668f0318da6f87802dd97f7fc33 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 10 Apr 2011 10:42:43 -0600 Subject: [PATCH] Amazon plugin: Use latin1 rather than utf-8 as URL encoding --- src/calibre/customize/builtins.py | 14 ++ src/calibre/ebooks/metadata/sources/amazon.py | 4 +- .../gui2/preferences/metadata_sources.py | 9 + .../gui2/preferences/metadata_sources.ui | 193 +++++++++--------- 4 files changed, 126 insertions(+), 94 deletions(-) diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index 298799daa5..52e7e91497 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -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) + #}}} diff --git a/src/calibre/ebooks/metadata/sources/amazon.py b/src/calibre/ebooks/metadata/sources/amazon.py index 3ffb95f2fb..a102a550b5 100644 --- a/src/calibre/ebooks/metadata/sources/amazon.py +++ b/src/calibre/ebooks/metadata/sources/amazon.py @@ -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 # }}} diff --git a/src/calibre/gui2/preferences/metadata_sources.py b/src/calibre/gui2/preferences/metadata_sources.py index cc6da1e995..3a10bdce3e 100644 --- a/src/calibre/gui2/preferences/metadata_sources.py +++ b/src/calibre/gui2/preferences/metadata_sources.py @@ -7,5 +7,14 @@ __license__ = 'GPL v3' __copyright__ = '2011, Kovid Goyal ' __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') diff --git a/src/calibre/gui2/preferences/metadata_sources.ui b/src/calibre/gui2/preferences/metadata_sources.ui index 9cb5943dfe..b8aabdd4fe 100644 --- a/src/calibre/gui2/preferences/metadata_sources.ui +++ b/src/calibre/gui2/preferences/metadata_sources.ui @@ -1,116 +1,125 @@ - StackedWidget - + Form + 0 0 - 766 - 447 + 781 + 300 - StackedWidget + Form - - - - - - Metadata sources - - - - - - <p>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. + + + 0 + + + + + + + + + Metadata sources + + + + + + <p>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. <p>Double click on a metadata source to customize it. + + + true + + + + + + + + + + + + + Downloaded metadata fields - - true + + + + + If you uncheck any fields, metadata for those fields will not be downloaded + + + + + + + + + + Convert all downloaded comments to plain &text - - + + + + Max. number of &tags to download: + + + opt_max_tags + + - - - - - - - Downloaded metadata fields - - - - - - If you uncheck any fields, metadata for those fields will not be downloaded + + + + + + + Max. &time to wait after first match is found: + + + opt_wait_after_first_identify_result + + + + + + + secs + + + + + + + Max. time to wait after &cover is found: + + + opt_wait_after_first_cover_result + + + + + + + secs - - - - - Convert all downloaded comments to plain &text - - - - - - - Max. number of &tags to download: - - - opt_max_tags - - - - - - - - - - Max. &time to wait after first match is found: - - - opt_wait_after_first_identify_result - - - - - - - secs - - - - - - - Max. time to wait after &cover is found: - - - opt_wait_after_first_cover_result - - - - - - - secs - - - - - - + + + +