mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
py3: Port urllib in metadata sources
This commit is contained in:
parent
96f4c4c3a2
commit
e0205790b9
@ -12,6 +12,9 @@ try:
|
||||
except ImportError:
|
||||
from Queue import Empty, Queue
|
||||
from threading import Thread
|
||||
try:
|
||||
from urllib.parse import urlparse
|
||||
except ImportError:
|
||||
from urlparse import urlparse
|
||||
|
||||
from calibre import as_unicode, browser, random_user_agent
|
||||
@ -579,6 +582,9 @@ class Worker(Thread): # Get details {{{
|
||||
return sanitize_comments_html(desc)
|
||||
|
||||
def parse_comments(self, root, raw):
|
||||
try:
|
||||
from urllib.parse import unquote
|
||||
except ImportError:
|
||||
from urllib import unquote
|
||||
ans = ''
|
||||
ns = tuple(self.selector('#bookDescription_feature_div noscript'))
|
||||
@ -1048,6 +1054,9 @@ class Amazon(Source):
|
||||
|
||||
def create_query(self, log, title=None, authors=None, identifiers={}, # {{{
|
||||
domain=None, for_amazon=True):
|
||||
try:
|
||||
from urllib.parse import urlencode
|
||||
except ImportError:
|
||||
from urllib import urlencode
|
||||
if domain is None:
|
||||
domain = self.domain
|
||||
|
@ -11,6 +11,9 @@ from calibre.ebooks.metadata.sources.base import Source, Option
|
||||
|
||||
|
||||
def get_urls(br, tokens):
|
||||
try:
|
||||
from urllib.parse import quote_plus
|
||||
except ImportError:
|
||||
from urllib import quote_plus
|
||||
from mechanize import Request
|
||||
from lxml import html
|
||||
|
@ -178,6 +178,9 @@ class Douban(Source):
|
||||
# }}}
|
||||
|
||||
def create_query(self, log, title=None, authors=None, identifiers={}): # {{{
|
||||
try:
|
||||
from urllib.parse import urlencode
|
||||
except ImportError:
|
||||
from urllib import urlencode
|
||||
SEARCH_URL = 'https://api.douban.com/book/subjects?'
|
||||
ISBN_URL = 'https://api.douban.com/book/subject/isbn/'
|
||||
|
@ -234,6 +234,9 @@ class Edelweiss(Source):
|
||||
# }}}
|
||||
|
||||
def create_query(self, log, title=None, authors=None, identifiers={}):
|
||||
try:
|
||||
from urllib.parse import urlencode
|
||||
except ImportError:
|
||||
from urllib import urlencode
|
||||
import time
|
||||
BASE_URL = ('https://www.edelweiss.plus/GetTreelineControl.aspx?'
|
||||
|
@ -199,6 +199,9 @@ class GoogleBooks(Source):
|
||||
# }}}
|
||||
|
||||
def create_query(self, log, title=None, authors=None, identifiers={}): # {{{
|
||||
try:
|
||||
from urllib.parse import urlencode
|
||||
except ImportError:
|
||||
from urllib import urlencode
|
||||
BASE_URL = 'https://books.google.com/books/feeds/volumes?'
|
||||
isbn = check_isbn(identifiers.get('isbn', None))
|
||||
|
@ -65,6 +65,9 @@ class GoogleImages(Source):
|
||||
|
||||
def get_image_urls(self, title, author, log, abort, timeout):
|
||||
from calibre.utils.cleantext import clean_ascii_chars
|
||||
try:
|
||||
from urllib.parse import urlencode
|
||||
except ImportError:
|
||||
from urllib import urlencode
|
||||
import json
|
||||
from collections import OrderedDict
|
||||
|
@ -12,8 +12,7 @@ from datetime import datetime
|
||||
from threading import Thread
|
||||
from io import BytesIO
|
||||
from operator import attrgetter
|
||||
from urlparse import urlparse
|
||||
from urllib import quote
|
||||
from polyglot.urllib import urlparse, quote
|
||||
|
||||
from calibre.customize.ui import metadata_plugins, all_metadata_plugins
|
||||
from calibre.ebooks.metadata import check_issn, authors_to_sort_string
|
||||
|
@ -57,12 +57,15 @@ class Ozon(Source):
|
||||
)
|
||||
|
||||
def get_book_url(self, identifiers): # {{{
|
||||
import urllib2
|
||||
try:
|
||||
from urllib.parse import quote
|
||||
except ImportError:
|
||||
from urllib import quote
|
||||
ozon_id = identifiers.get('ozon', None)
|
||||
res = None
|
||||
if ozon_id:
|
||||
# no affiliateId is used in search/detail
|
||||
url = '{}/context/detail/id/{}'.format(self.ozon_url, urllib2.quote(ozon_id), _get_affiliateId())
|
||||
url = '{}/context/detail/id/{}'.format(self.ozon_url, quote(ozon_id), _get_affiliateId())
|
||||
res = ('ozon', ozon_id, url)
|
||||
return res
|
||||
|
||||
|
@ -8,8 +8,11 @@ import json
|
||||
import re
|
||||
import time
|
||||
from collections import defaultdict, namedtuple
|
||||
from urllib import quote_plus, urlencode
|
||||
try:
|
||||
from urllib.parse import parse_qs, quote_plus, urlencode
|
||||
except ImportError:
|
||||
from urlparse import parse_qs
|
||||
from urllib import quote_plus, urlencode
|
||||
|
||||
from lxml import etree
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user