mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
update Woblink Store
This commit is contained in:
parent
ac32649262
commit
5c078cac2a
@ -41,7 +41,7 @@ class WoblinkStore(BasicStoreConfig, StorePlugin):
|
|||||||
d.exec_()
|
d.exec_()
|
||||||
|
|
||||||
def search(self, query, max_results=10, timeout=60):
|
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 > 10:
|
||||||
if max_results > 20:
|
if max_results > 20:
|
||||||
url += '&limit=30'
|
url += '&limit=30'
|
||||||
@ -53,20 +53,20 @@ class WoblinkStore(BasicStoreConfig, StorePlugin):
|
|||||||
counter = max_results
|
counter = max_results
|
||||||
with closing(br.open(url, timeout=timeout)) as f:
|
with closing(br.open(url, timeout=timeout)) as f:
|
||||||
doc = html.fromstring(f.read())
|
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:
|
if counter <= 0:
|
||||||
break
|
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:
|
if not id:
|
||||||
continue
|
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()'))
|
title = ''.join(data.xpath('.//h2[@class="title"]/a[1]/text()'))
|
||||||
author = ', '.join(data.xpath('.//p[@class="author"]/a/text()'))
|
author = ', '.join(data.xpath('.//td[@class="va-t"]/h3/a/text()'))
|
||||||
price = ''.join(data.xpath('.//div[@class="prices"]/span[1]/span/text()'))
|
price = ''.join(data.xpath('.//div[@class="prices"]/span[1]/strong/span/text()'))
|
||||||
price = re.sub('\.', ',', price)
|
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 = SearchResult()
|
||||||
s.cover_url = 'http://woblink.com' + cover_url
|
s.cover_url = 'http://woblink.com' + cover_url
|
||||||
@ -75,26 +75,23 @@ class WoblinkStore(BasicStoreConfig, StorePlugin):
|
|||||||
s.price = price + ' zł'
|
s.price = price + ' zł'
|
||||||
s.detail_item = id.strip()
|
s.detail_item = id.strip()
|
||||||
|
|
||||||
# MOBI should be send first,
|
if 'epub_drm' in formats:
|
||||||
if 'MOBI' in formats:
|
s.drm = SearchResult.DRM_LOCKED
|
||||||
t = copy.copy(s)
|
s.formats = 'EPUB'
|
||||||
t.title += ' MOBI'
|
|
||||||
t.drm = SearchResult.DRM_UNLOCKED
|
|
||||||
t.formats = 'MOBI'
|
|
||||||
formats.remove('MOBI')
|
|
||||||
|
|
||||||
counter -= 1
|
counter -= 1
|
||||||
yield t
|
yield s
|
||||||
|
elif 'pdf' in formats:
|
||||||
# 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')
|
|
||||||
|
|
||||||
s.drm = SearchResult.DRM_LOCKED
|
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()
|
s.formats = ', '.join(formats).upper()
|
||||||
|
|
||||||
counter -= 1
|
counter -= 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user