mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Construct manybooks cover url instead of parsing it as manybooks is very slow.
This commit is contained in:
parent
3883a1d6a2
commit
a1cdfeb4ba
@ -24,7 +24,7 @@ class AmazonKindleStore(StorePlugin):
|
|||||||
def open(self, gui, parent=None, detail_item=None):
|
def open(self, gui, parent=None, detail_item=None):
|
||||||
from calibre.gui2.store.web_store_dialog import WebStoreDialog
|
from calibre.gui2.store.web_store_dialog import WebStoreDialog
|
||||||
d = WebStoreDialog(gui, self.ASTORE_URL, parent, detail_item)
|
d = WebStoreDialog(gui, self.ASTORE_URL, parent, detail_item)
|
||||||
d.setWindowTitle('Amazon Kindle Store')
|
d.setWindowTitle(self.name)
|
||||||
d = d.exec_()
|
d = d.exec_()
|
||||||
|
|
||||||
def search(self, query, max_results=10, timeout=60):
|
def search(self, query, max_results=10, timeout=60):
|
||||||
|
@ -22,7 +22,7 @@ class FeedbooksStore(StorePlugin):
|
|||||||
def open(self, gui, parent=None, detail_item=None):
|
def open(self, gui, parent=None, detail_item=None):
|
||||||
from calibre.gui2.store.web_store_dialog import WebStoreDialog
|
from calibre.gui2.store.web_store_dialog import WebStoreDialog
|
||||||
d = WebStoreDialog(gui, 'http://m.feedbooks.com/', parent, detail_item)
|
d = WebStoreDialog(gui, 'http://m.feedbooks.com/', parent, detail_item)
|
||||||
d.setWindowTitle('Feedbooks')
|
d.setWindowTitle(self.name)
|
||||||
d = d.exec_()
|
d = d.exec_()
|
||||||
|
|
||||||
def search(self, query, max_results=10, timeout=60):
|
def search(self, query, max_results=10, timeout=60):
|
||||||
|
@ -22,7 +22,7 @@ class GutenbergStore(StorePlugin):
|
|||||||
def open(self, gui, parent=None, detail_item=None):
|
def open(self, gui, parent=None, detail_item=None):
|
||||||
from calibre.gui2.store.web_store_dialog import WebStoreDialog
|
from calibre.gui2.store.web_store_dialog import WebStoreDialog
|
||||||
d = WebStoreDialog(gui, 'http://m.gutenberg.org/', parent, detail_item)
|
d = WebStoreDialog(gui, 'http://m.gutenberg.org/', parent, detail_item)
|
||||||
d.setWindowTitle('Project Gutenberg')
|
d.setWindowTitle(self.name)
|
||||||
d = d.exec_()
|
d = d.exec_()
|
||||||
|
|
||||||
def search(self, query, max_results=10, timeout=60):
|
def search(self, query, max_results=10, timeout=60):
|
||||||
|
@ -4,6 +4,7 @@ __license__ = 'GPL 3'
|
|||||||
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
import re
|
||||||
import urllib2
|
import urllib2
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ class ManyBooksStore(StorePlugin):
|
|||||||
def open(self, gui, parent=None, detail_item=None):
|
def open(self, gui, parent=None, detail_item=None):
|
||||||
from calibre.gui2.store.web_store_dialog import WebStoreDialog
|
from calibre.gui2.store.web_store_dialog import WebStoreDialog
|
||||||
d = WebStoreDialog(gui, 'http://manybooks.net/', parent, detail_item)
|
d = WebStoreDialog(gui, 'http://manybooks.net/', parent, detail_item)
|
||||||
d.setWindowTitle('ManyBooks')
|
d.setWindowTitle(self.name)
|
||||||
d = d.exec_()
|
d = d.exec_()
|
||||||
|
|
||||||
def search(self, query, max_results=10, timeout=60):
|
def search(self, query, max_results=10, timeout=60):
|
||||||
@ -51,6 +52,7 @@ class ManyBooksStore(StorePlugin):
|
|||||||
if '/titles/' not in url:
|
if '/titles/' not in url:
|
||||||
continue
|
continue
|
||||||
id = url.split('/')[-1]
|
id = url.split('/')[-1]
|
||||||
|
id = id.strip()
|
||||||
|
|
||||||
heading = ''.join(url_a.xpath('text()'))
|
heading = ''.join(url_a.xpath('text()'))
|
||||||
title, _, author = heading.partition('by')
|
title, _, author = heading.partition('by')
|
||||||
@ -58,13 +60,12 @@ class ManyBooksStore(StorePlugin):
|
|||||||
price = '$0.00'
|
price = '$0.00'
|
||||||
|
|
||||||
cover_url = ''
|
cover_url = ''
|
||||||
with closing(br.open('http://manybooks.net/titles/%s' % id.strip(), timeout=timeout)) as f_i:
|
mo = re.match('^\D+', id)
|
||||||
doc_i = html.fromstring(f_i.read())
|
if mo:
|
||||||
for img in doc_i.xpath('//img'):
|
cover_name = mo.group()
|
||||||
src = img.get('src', None)
|
cover_name = cover_name.replace('etext', '')
|
||||||
if src and src.endswith('-thumb.jpg'):
|
cover_id = id.split('.')[0]
|
||||||
cover_url = src
|
cover_url = 'http://manybooks_images.s3.amazonaws.com/original_covers/' + id[0] + '/' + cover_name + '/' + cover_id + '-thumb.jpg'
|
||||||
print cover_url
|
|
||||||
|
|
||||||
counter -= 1
|
counter -= 1
|
||||||
|
|
||||||
@ -73,6 +74,6 @@ class ManyBooksStore(StorePlugin):
|
|||||||
s.title = title.strip()
|
s.title = title.strip()
|
||||||
s.author = author.strip()
|
s.author = author.strip()
|
||||||
s.price = price.strip()
|
s.price = price.strip()
|
||||||
s.detail_item = '/titles/' + id.strip()
|
s.detail_item = '/titles/' + id
|
||||||
|
|
||||||
yield s
|
yield s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user