mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
update Woblink Store
This commit is contained in:
parent
ac32649262
commit
5c078cac2a
@ -41,7 +41,7 @@ class WoblinkStore(BasicStoreConfig, StorePlugin):
|
||||
d.exec_()
|
||||
|
||||
def search(self, query, max_results=10, timeout=60):
|
||||
url = 'http://woblink.com/publication?query=' + urllib.quote_plus(query.encode('utf-8'))
|
||||
url = 'http://woblink.com/katalog-e-book?query=' + urllib.quote_plus(query.encode('utf-8'))
|
||||
if max_results > 10:
|
||||
if max_results > 20:
|
||||
url += '&limit=30'
|
||||
@ -53,20 +53,20 @@ class WoblinkStore(BasicStoreConfig, StorePlugin):
|
||||
counter = max_results
|
||||
with closing(br.open(url, timeout=timeout)) as f:
|
||||
doc = html.fromstring(f.read())
|
||||
for data in doc.xpath('//div[@class="book-item"]'):
|
||||
for data in doc.xpath('//div[@class="book-item backgroundmix"]'):
|
||||
if counter <= 0:
|
||||
break
|
||||
|
||||
id = ''.join(data.xpath('.//td[@class="w10 va-t"]/a[1]/@href'))
|
||||
id = ''.join(data.xpath('.//td[@class="w10 va-t mYHaveItYes"]/a[1]/@href'))
|
||||
if not id:
|
||||
continue
|
||||
|
||||
cover_url = ''.join(data.xpath('.//td[@class="w10 va-t"]/a[1]/img/@src'))
|
||||
cover_url = ''.join(data.xpath('.//td[@class="w10 va-t mYHaveItYes"]/a[1]/img/@src'))
|
||||
title = ''.join(data.xpath('.//h2[@class="title"]/a[1]/text()'))
|
||||
author = ', '.join(data.xpath('.//p[@class="author"]/a/text()'))
|
||||
price = ''.join(data.xpath('.//div[@class="prices"]/span[1]/span/text()'))
|
||||
author = ', '.join(data.xpath('.//td[@class="va-t"]/h3/a/text()'))
|
||||
price = ''.join(data.xpath('.//div[@class="prices"]/span[1]/strong/span/text()'))
|
||||
price = re.sub('\.', ',', price)
|
||||
formats = [ form[8:-4].split('_')[0] for form in data.xpath('.//p[3]/img/@src')]
|
||||
formats = [ form[8:-4].split('.')[0] for form in data.xpath('.//p[3]/img/@src')]
|
||||
|
||||
s = SearchResult()
|
||||
s.cover_url = 'http://woblink.com' + cover_url
|
||||
@ -75,27 +75,24 @@ class WoblinkStore(BasicStoreConfig, StorePlugin):
|
||||
s.price = price + ' zł'
|
||||
s.detail_item = id.strip()
|
||||
|
||||
# MOBI should be send first,
|
||||
if 'MOBI' in formats:
|
||||
t = copy.copy(s)
|
||||
t.title += ' MOBI'
|
||||
t.drm = SearchResult.DRM_UNLOCKED
|
||||
t.formats = 'MOBI'
|
||||
formats.remove('MOBI')
|
||||
|
||||
counter -= 1
|
||||
yield t
|
||||
|
||||
# and the remaining formats (if any) next
|
||||
if formats:
|
||||
if 'epub' in formats:
|
||||
formats.remove('epub')
|
||||
formats.append('WOBLINK')
|
||||
if 'E Ink' in data.xpath('.//div[@class="prices"]/img/@title'):
|
||||
formats.insert(0, 'EPUB')
|
||||
|
||||
if 'epub_drm' in formats:
|
||||
s.drm = SearchResult.DRM_LOCKED
|
||||
s.formats = ', '.join(formats).upper()
|
||||
|
||||
s.formats = 'EPUB'
|
||||
|
||||
counter -= 1
|
||||
yield s
|
||||
elif 'pdf' in formats:
|
||||
s.drm = SearchResult.DRM_LOCKED
|
||||
s.formats = 'PDF'
|
||||
|
||||
counter -= 1
|
||||
yield s
|
||||
else:
|
||||
s.drm = SearchResult.DRM_UNLOCKED
|
||||
if 'MOBI_nieb' in formats:
|
||||
formats.remove('MOBI_nieb')
|
||||
formats.append('MOBI')
|
||||
s.formats = ', '.join(formats).upper()
|
||||
|
||||
counter -= 1
|
||||
yield s
|
||||
|
Loading…
x
Reference in New Issue
Block a user