mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Store: Documentation. Return value for get_details. Formats for more stores.
This commit is contained in:
parent
4695840b2c
commit
b17ecef767
@ -96,7 +96,7 @@ class StorePlugin(object): # {{{
|
|||||||
|
|
||||||
:param query: The string query search with.
|
:param query: The string query search with.
|
||||||
:param max_results: The maximum number of results to return.
|
:param max_results: The maximum number of results to return.
|
||||||
:param timeout: The maximum amount of time in seconds to spend download the search results.
|
:param timeout: The maximum amount of time in seconds to spend downloading data for search results.
|
||||||
|
|
||||||
:return: :class:`calibre.gui2.store.search_result.SearchResult` objects
|
:return: :class:`calibre.gui2.store.search_result.SearchResult` objects
|
||||||
item_data is plugin specific and is used in :meth:`open` to open to a specifc place in the store.
|
item_data is plugin specific and is used in :meth:`open` to open to a specifc place in the store.
|
||||||
@ -116,8 +116,13 @@ class StorePlugin(object): # {{{
|
|||||||
take extra time to load. Splitting retrieving data that takes longer
|
take extra time to load. Splitting retrieving data that takes longer
|
||||||
to load into a separate function will give the illusion of the search
|
to load into a separate function will give the illusion of the search
|
||||||
being faster.
|
being faster.
|
||||||
|
|
||||||
|
:param search_result: A search result that need details set.
|
||||||
|
:param timeout: The maximum amount of time in seconds to spend downloading details.
|
||||||
|
|
||||||
|
:return: True if the search_result was modified otherwise False
|
||||||
'''
|
'''
|
||||||
pass
|
return False
|
||||||
|
|
||||||
def get_settings(self):
|
def get_settings(self):
|
||||||
'''
|
'''
|
||||||
|
@ -185,5 +185,6 @@ class AmazonKindleStore(StorePlugin):
|
|||||||
search_result.drm = SearchResult.DRM_UNKNOWN
|
search_result.drm = SearchResult.DRM_UNKNOWN
|
||||||
else:
|
else:
|
||||||
search_result.drm = SearchResult.DRM_LOCKED
|
search_result.drm = SearchResult.DRM_LOCKED
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
@ -99,3 +99,5 @@ class BeWriteStore(BasicStoreConfig, StorePlugin):
|
|||||||
if idata.xpath('boolean(//div[@id="content"]//td[contains(text(), "MOBI")])'):
|
if idata.xpath('boolean(//div[@id="content"]//td[contains(text(), "MOBI")])'):
|
||||||
formats.add('MOBI')
|
formats.add('MOBI')
|
||||||
search_result.formats = ', '.join(list(formats))
|
search_result.formats = ', '.join(list(formats))
|
||||||
|
|
||||||
|
return True
|
||||||
|
@ -99,3 +99,4 @@ class DieselEbooksStore(BasicStoreConfig, StorePlugin):
|
|||||||
search_result.drm = SearchResult.DRM_UNLOCKED
|
search_result.drm = SearchResult.DRM_UNLOCKED
|
||||||
else:
|
else:
|
||||||
search_result.drm = SearchResult.DRM_LOCKED
|
search_result.drm = SearchResult.DRM_LOCKED
|
||||||
|
return True
|
||||||
|
@ -117,3 +117,4 @@ class EbookscomStore(BasicStoreConfig, StorePlugin):
|
|||||||
search_result.formats = fdata
|
search_result.formats = fdata
|
||||||
|
|
||||||
search_result.price = price.strip()
|
search_result.price = price.strip()
|
||||||
|
return True
|
||||||
|
@ -101,3 +101,4 @@ class EHarlequinStore(BasicStoreConfig, StorePlugin):
|
|||||||
else:
|
else:
|
||||||
drm = SearchResult.DRM_UNLOCKED
|
drm = SearchResult.DRM_UNLOCKED
|
||||||
search_result.drm = drm
|
search_result.drm = drm
|
||||||
|
return True
|
||||||
|
@ -72,8 +72,10 @@ class FeedbooksStore(BasicStoreConfig, StorePlugin):
|
|||||||
title = ''.join(data.xpath('//h5//a/text()'))
|
title = ''.join(data.xpath('//h5//a/text()'))
|
||||||
author = ''.join(data.xpath('//h6//a/text()'))
|
author = ''.join(data.xpath('//h6//a/text()'))
|
||||||
price = ''.join(data.xpath('//a[@class="buy"]/text()'))
|
price = ''.join(data.xpath('//a[@class="buy"]/text()'))
|
||||||
|
formats = 'EPUB'
|
||||||
if not price:
|
if not price:
|
||||||
price = '$0.00'
|
price = '$0.00'
|
||||||
|
formats = 'EPUB, MOBI, PDF'
|
||||||
cover_url = ''
|
cover_url = ''
|
||||||
cover_url_img = data.xpath('//img')
|
cover_url_img = data.xpath('//img')
|
||||||
if cover_url_img:
|
if cover_url_img:
|
||||||
@ -88,6 +90,7 @@ class FeedbooksStore(BasicStoreConfig, StorePlugin):
|
|||||||
s.author = author.strip()
|
s.author = author.strip()
|
||||||
s.price = price.replace(' ', '').strip()
|
s.price = price.replace(' ', '').strip()
|
||||||
s.detail_item = id.strip()
|
s.detail_item = id.strip()
|
||||||
|
s.formats = formats
|
||||||
|
|
||||||
yield s
|
yield s
|
||||||
|
|
||||||
@ -101,3 +104,4 @@ class FeedbooksStore(BasicStoreConfig, StorePlugin):
|
|||||||
search_result.drm = SearchResult.DRM_LOCKED
|
search_result.drm = SearchResult.DRM_LOCKED
|
||||||
else:
|
else:
|
||||||
search_result.drm = SearchResult.DRM_UNLOCKED
|
search_result.drm = SearchResult.DRM_UNLOCKED
|
||||||
|
return True
|
||||||
|
@ -82,3 +82,12 @@ class GutenbergStore(BasicStoreConfig, StorePlugin):
|
|||||||
s.drm = SearchResult.DRM_UNLOCKED
|
s.drm = SearchResult.DRM_UNLOCKED
|
||||||
|
|
||||||
yield s
|
yield s
|
||||||
|
|
||||||
|
def get_details(self, search_result, timeout):
|
||||||
|
url = 'http://m.gutenberg.org/'
|
||||||
|
|
||||||
|
br = browser()
|
||||||
|
with closing(br.open(url + search_result.detail_item, timeout=timeout)) as nf:
|
||||||
|
idata = html.fromstring(nf.read())
|
||||||
|
search_result.formats = ', '.join(idata.xpath('//a[@type!="application/atom+xml"]//span[@class="title"]/text()'))
|
||||||
|
return True
|
@ -82,5 +82,6 @@ class KoboStore(BasicStoreConfig, StorePlugin):
|
|||||||
s.price = price.strip()
|
s.price = price.strip()
|
||||||
s.detail_item = '?url=http://www.kobobooks.com/' + id.strip()
|
s.detail_item = '?url=http://www.kobobooks.com/' + id.strip()
|
||||||
s.drm = SearchResult.DRM_LOCKED if drm else SearchResult.DRM_UNLOCKED
|
s.drm = SearchResult.DRM_LOCKED if drm else SearchResult.DRM_UNLOCKED
|
||||||
|
s.formats = 'EPUB'
|
||||||
|
|
||||||
yield s
|
yield s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user