mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
Add epubbuy. Continue a bit with beam.
This commit is contained in:
parent
5f626b1f26
commit
e219f7214d
@ -1126,7 +1126,7 @@ class StoreEbookscomStore(StoreBase):
|
||||
description = _('The digital bookstore.')
|
||||
actual_plugin = 'calibre.gui2.store.ebooks_com_plugin:EbookscomStore'
|
||||
|
||||
class StoreEHarlequinStoretore(StoreBase):
|
||||
class StoreEHarlequinStore(StoreBase):
|
||||
name = 'eHarlequin'
|
||||
description = _('entertain, enrich, inspire.')
|
||||
actual_plugin = 'calibre.gui2.store.eharlequin_plugin:EHarlequinStore'
|
||||
@ -1183,14 +1183,19 @@ class StoreAmazonDEKindleStore(StoreBase):
|
||||
|
||||
class StoreBeamEBooksDEStore(StoreBase):
|
||||
name = 'Beam EBooks DE'
|
||||
description = _('Kindle eBooks')
|
||||
description = _('der eBook Shop')
|
||||
actual_plugin = 'calibre.gui2.store.beam_ebooks_de_plugin:BeamEBooksDEStore'
|
||||
|
||||
class StoreEPubBuyDEStore(StoreBase):
|
||||
name = 'EPUBBuy DE'
|
||||
description = _('EPUBReaders eBook Shop')
|
||||
actual_plugin = 'calibre.gui2.store.epubbuy_de_plugin:EPubBuyDEStore'
|
||||
|
||||
plugins += [StoreAmazonKindleStore, StoreAmazonDEKindleStore,
|
||||
StoreAmazonUKKindleStore,
|
||||
StoreBaenWebScriptionStore, StoreBNStore, StoreBeamEBooksDEStore,
|
||||
StoreBeWriteStore, StoreDieselEbooksStore, StoreEbookscomStore,
|
||||
StoreEHarlequinStoretore, StoreFeedbooksStore,
|
||||
StoreEPubBuyDEStore, StoreEHarlequinStore, StoreFeedbooksStore,
|
||||
StoreFoylesUKStore, StoreGutenbergStore, StoreKoboStore, StoreManyBooksStore,
|
||||
StoreMobileReadStore, StoreOpenLibraryStore, StoreSmashwordsStore,
|
||||
StoreWaterstonesUKStore]
|
||||
|
@ -23,8 +23,8 @@ from calibre.gui2.store.web_store_dialog import WebStoreDialog
|
||||
class BeamEBooksDEStore(BasicStoreConfig, StorePlugin):
|
||||
|
||||
def open(self, parent=None, detail_item=None, external=False):
|
||||
url = 'http://www.beam-ebooks.de'
|
||||
url_details = 'http://www.beam-ebooks.de{0}'
|
||||
url = 'http://www.affiliwelt.net/klick.php?log=no&prid=908&pid=2&bannerid=10072&url=http://www.beam-ebooks.de'
|
||||
url_details = 'http://www.affiliwelt.net/klick.php?log=no&prid=908&pid=2&bannerid=10072&url=http://www.beam-ebooks.de{0}'
|
||||
|
||||
if external or self.config.get('open_external', False):
|
||||
if detail_item:
|
||||
@ -34,6 +34,7 @@ class BeamEBooksDEStore(BasicStoreConfig, StorePlugin):
|
||||
detail_url = None
|
||||
if detail_item:
|
||||
detail_url = url_details.format(detail_item)
|
||||
print(detail_url)
|
||||
d = WebStoreDialog(self.gui, url, parent, detail_url)
|
||||
d.setWindowTitle(self.name)
|
||||
d.set_tags(self.config.get('tags', ''))
|
||||
|
73
src/calibre/gui2/store/epubbuy_de_plugin.py
Normal file
73
src/calibre/gui2/store/epubbuy_de_plugin.py
Normal file
@ -0,0 +1,73 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
__license__ = 'GPL 3'
|
||||
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import urllib2
|
||||
from contextlib import closing
|
||||
|
||||
from lxml import html
|
||||
|
||||
from PyQt4.Qt import QUrl
|
||||
|
||||
from calibre import browser
|
||||
from calibre.gui2 import open_url
|
||||
from calibre.gui2.store import StorePlugin
|
||||
from calibre.gui2.store.basic_config import BasicStoreConfig
|
||||
from calibre.gui2.store.search_result import SearchResult
|
||||
from calibre.gui2.store.web_store_dialog import WebStoreDialog
|
||||
|
||||
class EPubBuyDEStore(BasicStoreConfig, StorePlugin):
|
||||
|
||||
def open(self, parent=None, detail_item=None, external=False):
|
||||
url = 'http://www.epubbuy.com/'
|
||||
url_details = '{0}'
|
||||
|
||||
if external or self.config.get('open_external', False):
|
||||
if detail_item:
|
||||
url = url_details.format(detail_item)
|
||||
open_url(QUrl(url))
|
||||
else:
|
||||
detail_url = None
|
||||
if detail_item:
|
||||
detail_url = url_details.format(detail_item)
|
||||
d = WebStoreDialog(self.gui, url, parent, detail_url)
|
||||
d.setWindowTitle(self.name)
|
||||
d.set_tags(self.config.get('tags', ''))
|
||||
d.exec_()
|
||||
|
||||
def search(self, query, max_results=10, timeout=60):
|
||||
url = 'http://www.epubbuy.com/search.php?search_query=' + urllib2.quote(query)
|
||||
br = browser()
|
||||
|
||||
counter = max_results
|
||||
with closing(br.open(url, timeout=timeout)) as f:
|
||||
doc = html.fromstring(f.read())
|
||||
for data in doc.xpath('//li[contains(@class, "ajax_block_product")]'):
|
||||
if counter <= 0:
|
||||
break
|
||||
|
||||
id = ''.join(data.xpath('./div[@class="center_block"]/a[@class="product_img_link"]/@href')).strip()
|
||||
if not id:
|
||||
continue
|
||||
cover_url = ''.join(data.xpath('./div[@class="center_block"]/a[@class="product_img_link"]/img/@src'))
|
||||
if cover_url:
|
||||
cover_url = 'http://www.epubbuy.com' + cover_url
|
||||
title = ''.join(data.xpath('./div[@class="center_block"]/a[@class="product_img_link"]/@title'))
|
||||
author = ''.join(data.xpath('./div[@class="center_block"]/a[2]/text()'))
|
||||
price = ''.join(data.xpath('.//span[@class="price"]/text()'))
|
||||
counter -= 1
|
||||
|
||||
s = SearchResult()
|
||||
s.cover_url = cover_url
|
||||
s.title = title.strip()
|
||||
s.author = author.strip()
|
||||
s.price = price
|
||||
s.drm = SearchResult.DRM_UNLOCKED
|
||||
s.detail_item = id
|
||||
s.formats = 'ePub'
|
||||
|
||||
yield s
|
Loading…
x
Reference in New Issue
Block a user