Get Books: Update Virtualo plugin for website changes

Merge branch 'master' of https://github.com/t3d/calibre
This commit is contained in:
Kovid Goyal 2017-02-14 07:25:55 +05:30
commit e256f0f5ee
2 changed files with 9 additions and 9 deletions

View File

@ -1808,7 +1808,7 @@ class StorePublioStore(StoreBase):
class StoreRW2010Store(StoreBase): class StoreRW2010Store(StoreBase):
name = 'RW2010' name = 'RW2010'
description = u'Polski serwis self-publishingowy. Pliki PDF, EPUB i MOBI. Maksymalna cena utworu nie przekracza u nas 10 złotych!' description = u'Polski serwis self-publishingowy. Pliki PDF, EPUB i MOBI.'
actual_plugin = 'calibre.gui2.store.stores.rw2010_plugin:RW2010Store' actual_plugin = 'calibre.gui2.store.stores.rw2010_plugin:RW2010Store'
author = u'Tomasz Długosz' author = u'Tomasz Długosz'

View File

@ -1,10 +1,10 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import (unicode_literals, division, absolute_import, print_function) from __future__ import (unicode_literals, division, absolute_import, print_function)
store_version = 7 # Needed for dynamic plugin loading store_version = 8 # Needed for dynamic plugin loading
__license__ = 'GPL 3' __license__ = 'GPL 3'
__copyright__ = '2011-2016, Tomasz Długosz <tomek3d@gmail.com>' __copyright__ = '2011-2017, Tomasz Długosz <tomek3d@gmail.com>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import re import re
@ -54,19 +54,19 @@ 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[@id="content"]//li[@class="product "]'): for data in doc.xpath('//div[@class="products-list-wrapper"]//li[@class="product "]'):
if counter <= 0: if counter <= 0:
break break
id = ''.join(data.xpath('.//div[@class="title"]//a/@href')).split(r'?q=')[0] id = ''.join(data.xpath('.//div[@class="cover-wrapper"]//a/@href')).split(r'?q=')[0]
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="information"]//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('.//div[@class="title"]/a/text()')) title = ''.join(data.xpath('.//div[@class="title"]/a//text()'))
author = ', '.join(data.xpath('.//div[@class="information"]//div[@class="authors"]/a/text()')) author = ', '.join(data.xpath('.//div[@class="information"]//div[@class="authors"]/a//text()'))
formats = [form.strip() for form in data.xpath('.//div[@class="information"]//div[@class="format"]/a/text()')] formats = [form.strip() for form in data.xpath('.//div[@class="information"]//div[@class="format"]/a//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()')))
counter -= 1 counter -= 1
@ -76,7 +76,7 @@ class VirtualoStore(BasicStoreConfig, StorePlugin):
s.title = title.strip() s.title = title.strip()
s.author = author.strip() s.author = author.strip()
s.price = re.sub('\.',',',price.strip()) s.price = re.sub('\.',',',price.strip())
s.detail_item = 'http://virtualo.pl' + id.strip().split('http://')[0] s.detail_item = 'http://virtualo.pl' + id
s.formats = ', '.join(formats).upper() s.formats = ', '.join(formats).upper()
s.drm = SearchResult.DRM_UNLOCKED if nodrm else SearchResult.DRM_LOCKED s.drm = SearchResult.DRM_UNLOCKED if nodrm else SearchResult.DRM_LOCKED