mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
6c0afb84d1
commit
94a885a961
@ -71,7 +71,7 @@ class HeadRequest(mechanize.Request):
|
|||||||
def get_method(self):
|
def get_method(self):
|
||||||
return 'HEAD'
|
return 'HEAD'
|
||||||
|
|
||||||
class OpenLibraryCovers(CoverDownload):
|
class OpenLibraryCovers(CoverDownload): # {{{
|
||||||
'Download covers from openlibrary.org'
|
'Download covers from openlibrary.org'
|
||||||
|
|
||||||
OPENLIBRARY = 'http://covers.openlibrary.org/b/isbn/%s-L.jpg?default=false'
|
OPENLIBRARY = 'http://covers.openlibrary.org/b/isbn/%s-L.jpg?default=false'
|
||||||
@ -109,7 +109,9 @@ class OpenLibraryCovers(CoverDownload):
|
|||||||
result_queue.put((False, self.exception_to_string(e),
|
result_queue.put((False, self.exception_to_string(e),
|
||||||
traceback.format_exc(), self.name))
|
traceback.format_exc(), self.name))
|
||||||
|
|
||||||
class LibraryThingCovers(CoverDownload):
|
# }}}
|
||||||
|
|
||||||
|
class LibraryThingCovers(CoverDownload): # {{{
|
||||||
|
|
||||||
name = 'librarything.com covers'
|
name = 'librarything.com covers'
|
||||||
description = _('Download covers from librarything.com')
|
description = _('Download covers from librarything.com')
|
||||||
@ -161,7 +163,9 @@ class LibraryThingCovers(CoverDownload):
|
|||||||
result_queue.put((False, self.exception_to_string(e),
|
result_queue.put((False, self.exception_to_string(e),
|
||||||
traceback.format_exc(), self.name))
|
traceback.format_exc(), self.name))
|
||||||
|
|
||||||
def check_for_cover(mi, timeout=5.):
|
# }}}
|
||||||
|
|
||||||
|
def check_for_cover(mi, timeout=5.): # {{{
|
||||||
from calibre.customize.ui import cover_sources
|
from calibre.customize.ui import cover_sources
|
||||||
ans = Event()
|
ans = Event()
|
||||||
checkers = [partial(p.has_cover, mi, ans, timeout=timeout) for p in
|
checkers = [partial(p.has_cover, mi, ans, timeout=timeout) for p in
|
||||||
@ -176,7 +180,9 @@ def check_for_cover(mi, timeout=5.):
|
|||||||
break
|
break
|
||||||
return ans.is_set()
|
return ans.is_set()
|
||||||
|
|
||||||
def download_covers(mi, result_queue, max_covers=50, timeout=5.):
|
# }}}
|
||||||
|
|
||||||
|
def download_covers(mi, result_queue, max_covers=50, timeout=5.): # {{{
|
||||||
from calibre.customize.ui import cover_sources
|
from calibre.customize.ui import cover_sources
|
||||||
abort = Event()
|
abort = Event()
|
||||||
temp = Queue()
|
temp = Queue()
|
||||||
@ -208,7 +214,9 @@ def download_covers(mi, result_queue, max_covers=50, timeout=5.):
|
|||||||
except Empty:
|
except Empty:
|
||||||
break
|
break
|
||||||
|
|
||||||
def download_cover(mi, timeout=5.):
|
# }}}
|
||||||
|
|
||||||
|
def download_cover(mi, timeout=5.): # {{{
|
||||||
results = Queue()
|
results = Queue()
|
||||||
download_covers(mi, results, max_covers=1, timeout=timeout)
|
download_covers(mi, results, max_covers=1, timeout=timeout)
|
||||||
errors, ans = [], None
|
errors, ans = [], None
|
||||||
@ -223,8 +231,9 @@ def download_cover(mi, timeout=5.):
|
|||||||
break
|
break
|
||||||
return ans, errors
|
return ans, errors
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
def test(isbns):
|
def test(isbns): # {{{
|
||||||
from calibre.ebooks.metadata import MetaInformation
|
from calibre.ebooks.metadata import MetaInformation
|
||||||
mi = MetaInformation('test', ['test'])
|
mi = MetaInformation('test', ['test'])
|
||||||
for isbn in isbns:
|
for isbn in isbns:
|
||||||
@ -241,6 +250,7 @@ def test(isbns):
|
|||||||
prints('\t', err[-1]+':', err[1])
|
prints('\t', err[-1]+':', err[1])
|
||||||
print '\n'
|
print '\n'
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
isbns = sys.argv[1:] + ['9781591025412', '9780307272119']
|
isbns = sys.argv[1:] + ['9781591025412', '9780307272119']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user