mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update Amazon metadata plugin for changes to amazon.co.jp
Fixes #1922309 [Japanese amazon encoding issue](https://bugs.launchpad.net/calibre/+bug/1922309)
This commit is contained in:
parent
151bc8eca0
commit
eb56bc531b
@ -908,7 +908,7 @@ class Worker(Thread): # Get details {{{
|
|||||||
class Amazon(Source):
|
class Amazon(Source):
|
||||||
|
|
||||||
name = 'Amazon.com'
|
name = 'Amazon.com'
|
||||||
version = (1, 2, 15)
|
version = (1, 2, 16)
|
||||||
minimum_calibre_version = (2, 82, 0)
|
minimum_calibre_version = (2, 82, 0)
|
||||||
description = _('Downloads metadata and covers from Amazon')
|
description = _('Downloads metadata and covers from Amazon')
|
||||||
|
|
||||||
@ -1178,9 +1178,6 @@ class Amazon(Source):
|
|||||||
if not for_amazon:
|
if not for_amazon:
|
||||||
return terms, domain
|
return terms, domain
|
||||||
|
|
||||||
if domain == 'jp':
|
|
||||||
# magic parameter to enable Japanese Shift_JIS encoding.
|
|
||||||
q['__mk_ja_JP'] = 'カタカナ'
|
|
||||||
if domain == 'nl':
|
if domain == 'nl':
|
||||||
q['__mk_nl_NL'] = 'ÅMÅŽÕÑ'
|
q['__mk_nl_NL'] = 'ÅMÅŽÕÑ'
|
||||||
if 'field-keywords' not in q:
|
if 'field-keywords' not in q:
|
||||||
@ -1189,11 +1186,9 @@ class Amazon(Source):
|
|||||||
q['field-keywords'] += ' ' + q.pop(f, '')
|
q['field-keywords'] += ' ' + q.pop(f, '')
|
||||||
q['field-keywords'] = q['field-keywords'].strip()
|
q['field-keywords'] = q['field-keywords'].strip()
|
||||||
|
|
||||||
encode_to = 'Shift_JIS' if domain == 'jp' else 'utf-8'
|
encoded_q = dict([(x.encode('utf-8', 'ignore'), y.encode(
|
||||||
encoded_q = dict([(x.encode(encode_to, 'ignore'), y.encode(encode_to,
|
'utf-8', 'ignore')) for x, y in q.items()])
|
||||||
'ignore')) for x, y in q.items()])
|
|
||||||
url_query = urlencode(encoded_q)
|
url_query = urlencode(encoded_q)
|
||||||
if encode_to == 'utf-8':
|
|
||||||
# amazon's servers want IRIs with unicode characters not percent esaped
|
# amazon's servers want IRIs with unicode characters not percent esaped
|
||||||
parts = []
|
parts = []
|
||||||
for x in url_query.split(b'&' if isinstance(url_query, bytes) else '&'):
|
for x in url_query.split(b'&' if isinstance(url_query, bytes) else '&'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user