mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge changes from lp:~tomek3d/calibre/store.
This commit is contained in:
commit
15a451fe63
@ -40,39 +40,35 @@ class VirtualoStore(BasicStoreConfig, StorePlugin):
|
|||||||
url = 'http://virtualo.pl/?q=' + urllib.quote(query) + '&f=format_id:4,6,3'
|
url = 'http://virtualo.pl/?q=' + urllib.quote(query) + '&f=format_id:4,6,3'
|
||||||
|
|
||||||
br = browser()
|
br = browser()
|
||||||
drm_pattern = re.compile("ADE")
|
no_drm_pattern = re.compile("Znak wodny")
|
||||||
|
|
||||||
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[@id="product_list"]/div/div[@class="column"]'):
|
for data in doc.xpath('//div[@id="content"]//div[@class="list_box list_box_border"]'):
|
||||||
if counter <= 0:
|
if counter <= 0:
|
||||||
break
|
break
|
||||||
|
|
||||||
id = ''.join(data.xpath('.//table/tr[1]/td[1]/a/@href'))
|
id = ''.join(data.xpath('.//div[@class="list_middle_left"]//a/@href'))
|
||||||
if not id:
|
if not id:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
price = ''.join(data.xpath('.//span[@class="price"]/text() | .//span[@class="price abbr"]/text()'))
|
price = ''.join(data.xpath('.//span[@class="price"]/text() | .//span[@class="price abbr"]/text()'))
|
||||||
cover_url = ''.join(data.xpath('.//table/tr[1]/td[1]/a/img/@src'))
|
cover_url = ''.join(data.xpath('.//div[@class="list_middle_left"]//a/img/@src'))
|
||||||
title = ''.join(data.xpath('.//div[@class="title"]/a/text()'))
|
title = ''.join(data.xpath('.//div[@class="list_title list_text_left"]/a/text()'))
|
||||||
title = re.sub(r'\ WM', '', title)
|
author = ', '.join(data.xpath('.//div[@class="list_authors list_text_left"]/a/text()'))
|
||||||
author = ', '.join(data.xpath('.//div[@class="authors"]/a/text()'))
|
formats = [ form.split('_')[-1].replace('.png', '') for form in data.xpath('.//div[@style="width:55%;float:left;text-align:left;height:18px;"]//img/@src')]
|
||||||
formats = ', '.join(data.xpath('.//span[@class="format"]/a/text()'))
|
nodrm = no_drm_pattern.search(''.join(data.xpath('.//div[@style="width:45%;float:right;text-align:right;height:18px;"]/div/div/text()')))
|
||||||
formats = re.sub(r'(, )?ONLINE(, )?', '', formats)
|
|
||||||
drm = drm_pattern.search(formats)
|
|
||||||
formats = re.sub(r'(, )?ADE(, )?', '', formats)
|
|
||||||
formats = re.sub(r'\ WM', '', formats)
|
|
||||||
|
|
||||||
counter -= 1
|
counter -= 1
|
||||||
|
|
||||||
s = SearchResult()
|
s = SearchResult()
|
||||||
s.cover_url = cover_url.split('.jpg')[0] + '.jpg'
|
s.cover_url = cover_url.split('.jpg')[0] + '.jpg'
|
||||||
s.title = title.strip() + ' ' + formats
|
s.title = title.strip()
|
||||||
s.author = author.strip()
|
s.author = author.strip()
|
||||||
s.price = price + ' zł'
|
s.price = price + ' zł'
|
||||||
s.detail_item = 'http://virtualo.pl' + id.strip().split('http://')[0]
|
s.detail_item = 'http://virtualo.pl' + id.strip().split('http://')[0]
|
||||||
s.formats = formats.upper().strip()
|
s.formats = ', '.join(formats).upper()
|
||||||
s.drm = SearchResult.DRM_LOCKED if drm else SearchResult.DRM_UNLOCKED
|
s.drm = SearchResult.DRM_UNLOCKED if nodrm else SearchResult.DRM_UNKNOWN
|
||||||
|
|
||||||
yield s
|
yield s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user