Merge changes from lp:~tomek3d/calibre/store.

This commit is contained in:
John Schember 2012-03-27 19:00:40 -04:00
commit a09e67b3f2
4 changed files with 18 additions and 32 deletions

View File

@ -1460,7 +1460,7 @@ class StoreNextoStore(StoreBase):
actual_plugin = 'calibre.gui2.store.stores.nexto_plugin:NextoStore' actual_plugin = 'calibre.gui2.store.stores.nexto_plugin:NextoStore'
headquarters = 'PL' headquarters = 'PL'
formats = ['EPUB', 'PDF'] formats = ['EPUB', 'MOBI', 'PDF']
affiliate = True affiliate = True
class StoreOpenBooksStore(StoreBase): class StoreOpenBooksStore(StoreBase):

View File

@ -3,7 +3,7 @@
from __future__ import (unicode_literals, division, absolute_import, print_function) from __future__ import (unicode_literals, division, absolute_import, print_function)
__license__ = 'GPL 3' __license__ = 'GPL 3'
__copyright__ = '2011, Tomasz Długosz <tomek3d@gmail.com>' __copyright__ = '2011-2012, Tomasz Długosz <tomek3d@gmail.com>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import re import re
@ -64,9 +64,7 @@ class EbookpointStore(BasicStoreConfig, StorePlugin):
author = ''.join(data.xpath('.//p[@class="author"]/text()')) author = ''.join(data.xpath('.//p[@class="author"]/text()'))
price = ''.join(data.xpath('.//p[@class="price"]/ins/text()')) price = ''.join(data.xpath('.//p[@class="price"]/ins/text()'))
with closing(br.open(id.strip(), timeout=timeout)) as nf: formats = ', '.join(data.xpath('.//div[@class="ikony"]/span/text()'))
idata = html.fromstring(nf.read())
formats = ', '.join(idata.xpath('//dd[@class="radio-line"]/label/text()'))
counter -= 1 counter -= 1
@ -77,6 +75,6 @@ class EbookpointStore(BasicStoreConfig, StorePlugin):
s.price = re.sub(r'\.',',',price) s.price = re.sub(r'\.',',',price)
s.detail_item = id.strip() s.detail_item = id.strip()
s.drm = SearchResult.DRM_UNLOCKED s.drm = SearchResult.DRM_UNLOCKED
s.formats = formats.upper().strip() s.formats = formats.upper()
yield s yield s

View File

@ -68,8 +68,8 @@ class NextoStore(BasicStoreConfig, StorePlugin):
title = ''.join(data.xpath('.//a[@class="title"]/text()')) title = ''.join(data.xpath('.//a[@class="title"]/text()'))
title = re.sub(r' - ebook$', '', title) title = re.sub(r' - ebook$', '', title)
formats = ', '.join(data.xpath('.//ul[@class="formats_available"]/li//b/text()')) formats = ', '.join(data.xpath('.//ul[@class="formats_available"]/li//b/text()'))
DrmFree = re.search(r'bez.DRM', formats) DrmFree = re.search(r'znak', formats)
formats = re.sub(r'\(.+\)', '', formats) formats = re.sub(r'\ ?\(.+?\)', '', formats)
author = '' author = ''
with closing(br.open('http://www.nexto.pl/' + id.strip(), timeout=timeout/4)) as nf: with closing(br.open('http://www.nexto.pl/' + id.strip(), timeout=timeout/4)) as nf:

View File

@ -6,6 +6,7 @@ __license__ = 'GPL 3'
__copyright__ = '2011-2012, Tomasz Długosz <tomek3d@gmail.com>' __copyright__ = '2011-2012, Tomasz Długosz <tomek3d@gmail.com>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import copy
import re import re
import urllib import urllib
from contextlib import closing from contextlib import closing
@ -66,13 +67,6 @@ class WoblinkStore(BasicStoreConfig, StorePlugin):
price = ''.join(data.xpath('.//div[@class="prices"]/span[1]/span/text()')) price = ''.join(data.xpath('.//div[@class="prices"]/span[1]/span/text()'))
price = re.sub('\.', ',', price) price = re.sub('\.', ',', price)
formats = [ form[8:-4].split('_')[0] for form in data.xpath('.//p[3]/img/@src')] formats = [ form[8:-4].split('_')[0] for form in data.xpath('.//p[3]/img/@src')]
if 'epub' in formats:
formats.remove('epub')
formats.append('WOBLINK')
if 'E Ink' in data.xpath('.//div[@class="prices"]/img/@title'):
formats.insert(0, 'EPUB')
if 'pdf' in formats:
formats[formats.index('pdf')] = 'PDF'
s = SearchResult() s = SearchResult()
s.cover_url = 'http://woblink.com' + cover_url s.cover_url = 'http://woblink.com' + cover_url
@ -83,31 +77,25 @@ class WoblinkStore(BasicStoreConfig, StorePlugin):
# MOBI should be send first, # MOBI should be send first,
if 'MOBI' in formats: if 'MOBI' in formats:
s = SearchResult() t = copy.copy(s)
s.cover_url = 'http://woblink.com' + cover_url t.title += ' MOBI'
s.title = title.strip() t.drm = SearchResult.DRM_UNLOCKED
s.author = author.strip() t.formats = 'MOBI'
s.price = price + ''
s.detail_item = id.strip()
s.drm = SearchResult.DRM_UNLOCKED
s.formats = 'MOBI'
formats.remove('MOBI') formats.remove('MOBI')
counter -= 1 counter -= 1
yield s yield t
# and the remaining formats (if any) next # and the remaining formats (if any) next
if formats: if formats:
s = SearchResult() if 'epub' in formats:
s.cover_url = 'http://woblink.com' + cover_url formats.remove('epub')
s.title = title.strip() formats.append('WOBLINK')
s.author = author.strip() if 'E Ink' in data.xpath('.//div[@class="prices"]/img/@title'):
s.price = price + '' formats.insert(0, 'EPUB')
s.detail_item = id.strip()
s.drm = SearchResult.DRM_LOCKED s.drm = SearchResult.DRM_LOCKED
s.formats = ', '.join(formats) s.formats = ', '.join(formats).upper()
counter -= 1 counter -= 1
yield s yield s