mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
draft version of improved virtualo plugin
This commit is contained in:
parent
ebc1f0e347
commit
467f0be76f
@ -40,29 +40,25 @@ 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 = ', '#.join(data.xpath('.//div[2]/div[3]//div[@class="list_vertical_wrap_middle"]/img/@src()'))
|
||||||
formats = ', '.join(data.xpath('.//span[@class="format"]/a/text()'))
|
drm = not no_drm_pattern.search(formats)
|
||||||
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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user