mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Get books: update Virtualo store
This commit is contained in:
parent
5722a4a3b0
commit
85974bba56
@ -1,10 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
store_version = 10 # Needed for dynamic plugin loading
|
store_version = 11 # Needed for dynamic plugin loading
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2011-2019, Tomasz Długosz <tomek3d@gmail.com>'
|
__copyright__ = '2011-2023, Tomasz Długosz <tomek3d@gmail.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import re
|
import re
|
||||||
@ -41,7 +41,7 @@ class VirtualoStore(BasicStoreConfig, StorePlugin):
|
|||||||
def open(self, parent=None, detail_item=None, external=False):
|
def open(self, parent=None, detail_item=None, external=False):
|
||||||
aff_root = 'https://www.a4b-tracking.com/pl/stat-click-text-link/12/58/'
|
aff_root = 'https://www.a4b-tracking.com/pl/stat-click-text-link/12/58/'
|
||||||
|
|
||||||
url = 'http://virtualo.pl/ebook/c2/'
|
url = 'http://virtualo.pl/ebooki/'
|
||||||
|
|
||||||
aff_url = aff_root + as_base64(url)
|
aff_url = aff_root + as_base64(url)
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ class VirtualoStore(BasicStoreConfig, StorePlugin):
|
|||||||
d.exec()
|
d.exec()
|
||||||
|
|
||||||
def search(self, query, max_results=12, timeout=60):
|
def search(self, query, max_results=12, timeout=60):
|
||||||
url = 'http://virtualo.pl/?q=' + quote(query)
|
url = 'http://virtualo.pl/?cat=1&q=' + quote(query)
|
||||||
|
|
||||||
br = browser()
|
br = browser()
|
||||||
no_drm_pattern = re.compile(r'Watermark|brak')
|
no_drm_pattern = re.compile(r'Watermark|brak')
|
||||||
@ -66,7 +66,7 @@ class VirtualoStore(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="products-list-wrapper"]//li[@class="product "]'):
|
for data in doc.xpath('//div[@class="products-list-wrapper"]//li[@class="product"]'):
|
||||||
if counter <= 0:
|
if counter <= 0:
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -74,10 +74,10 @@ class VirtualoStore(BasicStoreConfig, StorePlugin):
|
|||||||
if not id:
|
if not id:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
price = ''.join(data.xpath('.//div[@class="information"]//div[@class="price"]/text()'))
|
price = ''.join(data.xpath('.//div[@class="info"]//div[@class="price"]/text()'))
|
||||||
cover_url = ''.join(data.xpath('.//img[@class="cover"]/@src'))
|
cover_url = ''.join(data.xpath('.//img[@class="cover"]/@src'))
|
||||||
title = ''.join(data.xpath('.//h3[@class="title"]/a//text()'))
|
title = ''.join(data.xpath('.//h3[@class="title"]/a//text()'))
|
||||||
author = ', '.join(data.xpath('.//div[@class="information"]//div[@class="authors"]/a//text()'))
|
author = ', '.join(data.xpath('.//div[@class="info"]//div[@class="authors"]/a//text()'))
|
||||||
formats = [form.strip() for form in data.xpath('.//div[@class="text-wrapper"]//div[@class="format"]/span[@class="prompt_preview"]/text()')]
|
formats = [form.strip() for form in data.xpath('.//div[@class="text-wrapper"]//div[@class="format"]/span[@class="prompt_preview"]/text()')]
|
||||||
nodrm = no_drm_pattern.search(''.join(data.xpath('.//div[@class="protection"]/text()')))
|
nodrm = no_drm_pattern.search(''.join(data.xpath('.//div[@class="protection"]/text()')))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user