mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Store: List of stores that do not want to be included. Weightless Books plugin.
This commit is contained in:
parent
dd56bb7b6d
commit
fb493ff8de
@ -1096,6 +1096,11 @@ class StoreAmazonKindleStore(StoreBase):
|
|||||||
description = _('Kindle books from Amazon')
|
description = _('Kindle books from Amazon')
|
||||||
actual_plugin = 'calibre.gui2.store.amazon_plugin:AmazonKindleStore'
|
actual_plugin = 'calibre.gui2.store.amazon_plugin:AmazonKindleStore'
|
||||||
|
|
||||||
|
class StoreAmazonDEKindleStore(StoreBase):
|
||||||
|
name = 'Amazon DE Kindle'
|
||||||
|
description = _('Kindle eBooks')
|
||||||
|
actual_plugin = 'calibre.gui2.store.amazon_de_plugin:AmazonDEKindleStore'
|
||||||
|
|
||||||
class StoreAmazonUKKindleStore(StoreBase):
|
class StoreAmazonUKKindleStore(StoreBase):
|
||||||
name = 'Amazon UK Kindle'
|
name = 'Amazon UK Kindle'
|
||||||
description = _('Kindle books from Amazon.uk')
|
description = _('Kindle books from Amazon.uk')
|
||||||
@ -1136,6 +1141,11 @@ class StoreFeedbooksStore(StoreBase):
|
|||||||
description = _('Read anywhere.')
|
description = _('Read anywhere.')
|
||||||
actual_plugin = 'calibre.gui2.store.feedbooks_plugin:FeedbooksStore'
|
actual_plugin = 'calibre.gui2.store.feedbooks_plugin:FeedbooksStore'
|
||||||
|
|
||||||
|
class StoreFoylesUKStore(StoreBase):
|
||||||
|
name = 'Foyles UK'
|
||||||
|
description = _('Foyles of London, online')
|
||||||
|
actual_plugin = 'calibre.gui2.store.foyles_uk_plugin:FoylesUKStore'
|
||||||
|
|
||||||
class StoreGutenbergStore(StoreBase):
|
class StoreGutenbergStore(StoreBase):
|
||||||
name = 'Project Gutenberg'
|
name = 'Project Gutenberg'
|
||||||
description = _('The first producer of free ebooks.')
|
description = _('The first producer of free ebooks.')
|
||||||
@ -1171,23 +1181,18 @@ class StoreWaterstonesUKStore(StoreBase):
|
|||||||
description = _('Feel every word')
|
description = _('Feel every word')
|
||||||
actual_plugin = 'calibre.gui2.store.waterstones_uk_plugin:WaterstonesUKStore'
|
actual_plugin = 'calibre.gui2.store.waterstones_uk_plugin:WaterstonesUKStore'
|
||||||
|
|
||||||
class StoreFoylesUKStore(StoreBase):
|
class StoreWeightlessBooksStore(StoreBase):
|
||||||
name = 'Foyles UK'
|
name = 'Weightless Books'
|
||||||
description = _('Foyles of London, online')
|
description = '(e)Books That Don\'t Weigh You Down'
|
||||||
actual_plugin = 'calibre.gui2.store.foyles_uk_plugin:FoylesUKStore'
|
actual_plugin = 'calibre.gui2.store.weightless_books_plugin:WeightlessBooksStore'
|
||||||
|
|
||||||
class AmazonDEKindleStore(StoreBase):
|
plugins += [StoreAmazonKindleStore, StoreAmazonDEKindleStore, StoreAmazonUKKindleStore,
|
||||||
name = 'Amazon DE Kindle'
|
|
||||||
description = _('Kindle eBooks')
|
|
||||||
actual_plugin = 'calibre.gui2.store.amazon_de_plugin:AmazonDEKindleStore'
|
|
||||||
|
|
||||||
plugins += [StoreAmazonKindleStore, AmazonDEKindleStore, StoreAmazonUKKindleStore,
|
|
||||||
StoreBaenWebScriptionStore, StoreBNStore,
|
StoreBaenWebScriptionStore, StoreBNStore,
|
||||||
StoreBeWriteStore,
|
StoreBeWriteStore,
|
||||||
StoreDieselEbooksStore, StoreEbookscomStore,
|
StoreDieselEbooksStore, StoreEbookscomStore,
|
||||||
StoreEHarlequinStoretore, StoreFeedbooksStore,
|
StoreEHarlequinStoretore, StoreFeedbooksStore,
|
||||||
StoreFoylesUKStore, StoreGutenbergStore, StoreKoboStore, StoreManyBooksStore,
|
StoreFoylesUKStore, StoreGutenbergStore, StoreKoboStore, StoreManyBooksStore,
|
||||||
StoreMobileReadStore, StoreOpenLibraryStore, StoreSmashwordsStore,
|
StoreMobileReadStore, StoreOpenLibraryStore, StoreSmashwordsStore,
|
||||||
StoreWaterstonesUKStore]
|
StoreWaterstonesUKStore, StoreWeightlessBooksStore]
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
5
src/calibre/gui2/store/declined.txt
Normal file
5
src/calibre/gui2/store/declined.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
This is a list of stores that objected, declined
|
||||||
|
or asked not to be included in the store integration.
|
||||||
|
|
||||||
|
* Borders (http://www.borders.com/)
|
||||||
|
* WH Smith (http://www.whsmith.co.uk/)
|
76
src/calibre/gui2/store/weightless_books_plugin.py
Normal file
76
src/calibre/gui2/store/weightless_books_plugin.py
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# -*- 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 urllib
|
||||||
|
from contextlib import closing
|
||||||
|
|
||||||
|
from lxml import html
|
||||||
|
|
||||||
|
from PyQt4.Qt import QUrl
|
||||||
|
|
||||||
|
from calibre import browser, url_slash_cleaner
|
||||||
|
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 WeightlessBooksStore(BasicStoreConfig, StorePlugin):
|
||||||
|
|
||||||
|
def open(self, parent=None, detail_item=None, external=False):
|
||||||
|
url = 'http://weightlessbooks.com/'
|
||||||
|
|
||||||
|
if external or self.config.get('open_external', False):
|
||||||
|
open_url(QUrl(url_slash_cleaner(detail_item if detail_item else url)))
|
||||||
|
else:
|
||||||
|
d = WebStoreDialog(self.gui, url, parent, detail_item)
|
||||||
|
d.setWindowTitle(self.name)
|
||||||
|
d.set_tags(self.config.get('tags', ''))
|
||||||
|
d.exec_()
|
||||||
|
|
||||||
|
def search(self, query, max_results=10, timeout=60):
|
||||||
|
url = 'http://weightlessbooks.com/?s=' + urllib.quote_plus(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[@id="product"]'):
|
||||||
|
if counter <= 0:
|
||||||
|
break
|
||||||
|
|
||||||
|
id = ''.join(data.xpath('.//div[@class="cover"]/a/@href'))
|
||||||
|
if not id:
|
||||||
|
continue
|
||||||
|
|
||||||
|
cover_url = ''.join(data.xpath('.//div[@class="cover"]/a/img/@src'))
|
||||||
|
|
||||||
|
price = ''.join(data.xpath('.//div[@class="buy_buttons"]/b[1]/text()'))
|
||||||
|
if not price:
|
||||||
|
continue
|
||||||
|
|
||||||
|
formats = ', '.join(data.xpath('.//select[@class="eStore_variation"]//option//text()'))
|
||||||
|
formats = formats.upper()
|
||||||
|
|
||||||
|
title = ''.join(data.xpath('.//h3/a/text()'))
|
||||||
|
author = ''.join(data.xpath('.//h3//text()'))
|
||||||
|
author = author.replace(title, '')
|
||||||
|
|
||||||
|
counter -= 1
|
||||||
|
|
||||||
|
s = SearchResult()
|
||||||
|
s.cover_url = cover_url
|
||||||
|
s.title = title.strip()
|
||||||
|
s.author = author.strip()
|
||||||
|
s.price = price.strip()
|
||||||
|
s.detail_item = id.strip()
|
||||||
|
s.drm = SearchResult.DRM_UNLOCKED
|
||||||
|
s.formats = formats
|
||||||
|
|
||||||
|
yield s
|
Loading…
x
Reference in New Issue
Block a user