mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Disable Kent District Library plugin to download series information. The website could not handle the load calibre's 2 million users put on it
This commit is contained in:
parent
15d1e591ae
commit
a42dbbfe25
@ -121,7 +121,8 @@ def enable_plugin(plugin_or_name):
|
||||
config['enabled_plugins'] = ep
|
||||
|
||||
default_disabled_plugins = set([
|
||||
'Douban Books', 'Douban.com covers', 'Nicebooks', 'Nicebooks covers'
|
||||
'Douban Books', 'Douban.com covers', 'Nicebooks', 'Nicebooks covers',
|
||||
'Kent District Library'
|
||||
])
|
||||
|
||||
def is_disabled(plugin):
|
||||
|
@ -205,7 +205,10 @@ def main(args=sys.argv):
|
||||
open(cpath, 'wb').write(br.open_novisit(curl).read())
|
||||
print 'Cover for', title, 'saved to', cpath
|
||||
|
||||
#import time
|
||||
#st = time.time()
|
||||
print get_social_metadata(title, None, None, isbn)
|
||||
#print '\n\n', time.time() - st, '\n\n'
|
||||
|
||||
return 0
|
||||
|
||||
|
@ -106,6 +106,9 @@ class MetadataSource(Plugin): # {{{
|
||||
def join(self):
|
||||
return self.worker.join()
|
||||
|
||||
def is_alive(self):
|
||||
return self.worker.is_alive()
|
||||
|
||||
def is_customizable(self):
|
||||
return True
|
||||
|
||||
@ -251,7 +254,9 @@ class KentDistrictLibrary(MetadataSource): # {{{
|
||||
|
||||
name = 'Kent District Library'
|
||||
metadata_type = 'social'
|
||||
description = _('Downloads series information from ww2.kdl.org')
|
||||
description = _('Downloads series information from ww2.kdl.org. '
|
||||
'This website cannot handle large numbers of queries, '
|
||||
'so the plugin is disabled by default.')
|
||||
|
||||
def fetch(self):
|
||||
if not self.title or not self.book_author:
|
||||
|
@ -5,7 +5,9 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import re, urllib, urlparse
|
||||
import re, urllib, urlparse, socket
|
||||
|
||||
from mechanize import URLError
|
||||
|
||||
from calibre.ebooks.metadata.book.base import Metadata
|
||||
from calibre import browser
|
||||
@ -17,7 +19,7 @@ URL = \
|
||||
|
||||
_ignore_starts = u'\'"'+u''.join(unichr(x) for x in range(0x2018, 0x201e)+[0x2032, 0x2033])
|
||||
|
||||
def get_series(title, authors):
|
||||
def get_series(title, authors, timeout=5):
|
||||
mi = Metadata(title, authors)
|
||||
if title and title[0] in _ignore_starts:
|
||||
title = title[1:]
|
||||
@ -39,7 +41,12 @@ def get_series(title, authors):
|
||||
|
||||
url = URL.format(author, title)
|
||||
br = browser()
|
||||
raw = br.open(url).read()
|
||||
try:
|
||||
raw = br.open_novisit(url, timeout=timeout).read()
|
||||
except URLError, e:
|
||||
if isinstance(e.reason, socket.timeout):
|
||||
raise Exception('KDL Server busy, try again later')
|
||||
raise
|
||||
if 'see the full results' not in raw:
|
||||
return mi
|
||||
raw = xml_to_unicode(raw)[0]
|
||||
|
Loading…
x
Reference in New Issue
Block a user