mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Update 2 store plugins: Mills & Boon and Beam Ebooks
This commit is contained in:
parent
90101bd663
commit
a07cf434c2
@ -1,7 +1,7 @@
|
|||||||
# -*- 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 = 2 # Needed for dynamic plugin loading
|
store_version = 3 # Needed for dynamic plugin loading
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
||||||
@ -28,12 +28,11 @@ class BeamEBooksDEStore(BasicStoreConfig, StorePlugin):
|
|||||||
url = 'http://klick.affiliwelt.net/klick.php?bannerid=10072&pid=32307&prid=908'
|
url = 'http://klick.affiliwelt.net/klick.php?bannerid=10072&pid=32307&prid=908'
|
||||||
url_details = ('http://klick.affiliwelt.net/klick.php?'
|
url_details = ('http://klick.affiliwelt.net/klick.php?'
|
||||||
'bannerid=66830&pid=32307&prid=908&'
|
'bannerid=66830&pid=32307&prid=908&'
|
||||||
'url=http://www.beam-ebooks.de/ebook/{0}')
|
'url={0}')
|
||||||
|
|
||||||
if external or self.config.get('open_external', False):
|
if external or self.config.get('open_external', False):
|
||||||
if detail_item:
|
if detail_item:
|
||||||
url = url_details.format(detail_item)
|
url = url_details.format(detail_item)
|
||||||
|
|
||||||
open_url(QUrl(url))
|
open_url(QUrl(url))
|
||||||
else:
|
else:
|
||||||
detail_url = None
|
detail_url = None
|
||||||
@ -45,37 +44,26 @@ class BeamEBooksDEStore(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://www.beam-ebooks.de/suchergebnis.php?Type=&limit={0}&sw={1}'.format(
|
url = 'https://www.beam-shop.de/search?saltFieldLimitation=all&sSearch=' + urllib2.quote(query)
|
||||||
max_results, urllib2.quote(query))
|
print(url)
|
||||||
br = browser()
|
br = browser()
|
||||||
|
|
||||||
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('//table[tr/td/div[@class="stil2"]]'):
|
for data in doc.xpath('//div[contains(@class, "product--box")]'):
|
||||||
if counter <= 0:
|
if counter <= 0:
|
||||||
break
|
break
|
||||||
|
|
||||||
id_ = ''.join(data.xpath('./tr/td[1]/a/@href')).strip()
|
id_ = ''.join(data.xpath('./div/div[contains(@class, "product--info")]/a/@href')).strip()
|
||||||
if not id_:
|
if not id_:
|
||||||
continue
|
continue
|
||||||
id_ = id_[7:]
|
cover_url = ''.join(data.xpath('./div/div[contains(@class, "product--info")]/a//img/@srcset'))
|
||||||
cover_url = ''.join(data.xpath('./tr/td[1]/a/img/@src'))
|
|
||||||
if cover_url:
|
if cover_url:
|
||||||
cover_url = 'http://www.beam-ebooks.de' + cover_url
|
cover_url = cover_url.split(',')[0].strip()
|
||||||
temp = ''.join(data.xpath('./tr/td[1]/a/img/@alt'))
|
author = data.xpath('.//a[@class="product--author"]/text()')[0].strip()
|
||||||
colon = temp.find(':')
|
title = data.xpath('.//a[@class="product--title"]/text()')[0].strip()
|
||||||
if not temp.startswith('eBook') or colon < 0:
|
price = data.xpath('.//div[@class="product--price"]/span/text()')[0].strip()
|
||||||
continue
|
|
||||||
author = temp[5:colon]
|
|
||||||
title = temp[colon+1:]
|
|
||||||
price = ''.join(data.xpath('./tr/td[3]/text()'))
|
|
||||||
pdf = data.xpath(
|
|
||||||
'boolean(./tr/td[3]/a/img[contains(@alt, "PDF")]/@alt)')
|
|
||||||
epub = data.xpath(
|
|
||||||
'boolean(./tr/td[3]/a/img[contains(@alt, "ePub")]/@alt)')
|
|
||||||
mobi = data.xpath(
|
|
||||||
'boolean(./tr/td[3]/a/img[contains(@alt, "Mobipocket")]/@alt)')
|
|
||||||
counter -= 1
|
counter -= 1
|
||||||
|
|
||||||
s = SearchResult()
|
s = SearchResult()
|
||||||
@ -85,14 +73,6 @@ class BeamEBooksDEStore(BasicStoreConfig, StorePlugin):
|
|||||||
s.price = price
|
s.price = price
|
||||||
s.drm = SearchResult.DRM_UNLOCKED
|
s.drm = SearchResult.DRM_UNLOCKED
|
||||||
s.detail_item = id_
|
s.detail_item = id_
|
||||||
formats = []
|
# s.formats = None
|
||||||
if epub:
|
|
||||||
formats.append('ePub')
|
|
||||||
if pdf:
|
|
||||||
formats.append('PDF')
|
|
||||||
if mobi:
|
|
||||||
formats.append('MOBI')
|
|
||||||
s.formats = ', '.join(formats)
|
|
||||||
|
|
||||||
yield s
|
yield s
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# -*- 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 = 2 # Needed for dynamic plugin loading
|
store_version = 3 # Needed for dynamic plugin loading
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
||||||
@ -25,26 +25,26 @@ from calibre.gui2.store.web_store_dialog import WebStoreDialog
|
|||||||
class MillsBoonUKStore(BasicStoreConfig, StorePlugin):
|
class MillsBoonUKStore(BasicStoreConfig, StorePlugin):
|
||||||
|
|
||||||
def open(self, parent=None, detail_item=None, external=False):
|
def open(self, parent=None, detail_item=None, external=False):
|
||||||
url = 'http://www.awin1.com/awclick.php?mid=1150&id=120917'
|
url = 'https://www.awin1.com/awclick.php?mid=1150&id=120917&clickref=mbhome'
|
||||||
detail_url = 'http://www.awin1.com/cread.php?awinmid=1150&awinaffid=120917&clickref=&p='
|
detail_url = 'https://www.awin1.com/cread.php?awinmid=1150&awinaffid=120917&clickref=mbdetail&p='
|
||||||
|
|
||||||
if external or self.config.get('open_external', False):
|
if external or self.config.get('open_external', False):
|
||||||
if detail_item:
|
if detail_item:
|
||||||
url = detail_url + detail_item
|
url = detail_url + detail_item
|
||||||
open_url(QUrl(url_slash_cleaner(url)))
|
open_url(QUrl(url_slash_cleaner(url)))
|
||||||
else:
|
else:
|
||||||
detail_url = None
|
|
||||||
if detail_item:
|
if detail_item:
|
||||||
detail_url = url + detail_item
|
detail_url = detail_url + detail_item
|
||||||
|
else:
|
||||||
|
detail_url = None
|
||||||
d = WebStoreDialog(self.gui, url, parent, detail_url)
|
d = WebStoreDialog(self.gui, url, parent, detail_url)
|
||||||
d.setWindowTitle(self.name)
|
d.setWindowTitle(self.name)
|
||||||
d.set_tags(self.config.get('tags', ''))
|
d.set_tags(self.config.get('tags', ''))
|
||||||
d.exec_()
|
d.exec_()
|
||||||
|
|
||||||
def search(self, query, max_results=10, timeout=60):
|
def search(self, query, max_results=10, timeout=60):
|
||||||
base_url = 'http://www.millsandboon.co.uk'
|
base_url = 'https://www.millsandboon.co.uk'
|
||||||
url = base_url + '/search?format=ebook&q=' + urllib2.quote(query)
|
url = base_url + '/search.aspx??format=ebook&searchText=' + urllib2.quote(query)
|
||||||
# print(url)
|
|
||||||
br = browser()
|
br = browser()
|
||||||
|
|
||||||
counter = max_results
|
counter = max_results
|
||||||
@ -54,14 +54,13 @@ class MillsBoonUKStore(BasicStoreConfig, StorePlugin):
|
|||||||
if counter <= 0:
|
if counter <= 0:
|
||||||
break
|
break
|
||||||
id_ = ''.join(data.xpath('.//div[@class="img-wrapper"]/a/@href')).strip()
|
id_ = ''.join(data.xpath('.//div[@class="img-wrapper"]/a/@href')).strip()
|
||||||
id_ = base_url + id_
|
|
||||||
if not id_:
|
if not id_:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
cover_url = ''.join(data.xpath('.//div[@class="img-wrapper"]/a/img/@src'))
|
cover_url = ''.join(data.xpath('.//div[@class="img-wrapper"]/a/img/@src'))
|
||||||
title = ''.join(data.xpath('.//div[@class="img-wrapper"]/a/img/@alt')).strip()
|
title = ''.join(data.xpath('.//div[@class="img-wrapper"]/a/img/@alt')).strip()
|
||||||
author = ''.join(data.xpath('.//a[@class="author"]/text()'))
|
author = ''.join(data.xpath('.//a[@class="author"]/text()'))
|
||||||
price = ''.join(data.xpath('.//li[@class="productAttribute" and child::span[text()="eBook"]]/input/@value'))
|
price = ''.join(data.xpath('.//div[@class="type-wrapper"]/ul/li[child::span[text()="eBook"]]/a/text()'))
|
||||||
format_ = ''.join(data.xpath('.//p[@class="doc-meta-format"]/span[last()]/text()'))
|
format_ = ''.join(data.xpath('.//p[@class="doc-meta-format"]/span[last()]/text()'))
|
||||||
drm = SearchResult.DRM_LOCKED
|
drm = SearchResult.DRM_LOCKED
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user