mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-30 23:00:21 -04:00
formats section rewritten
This commit is contained in:
parent
0194b4937d
commit
60d606910d
@ -9,6 +9,7 @@ __docformat__ = 'restructuredtext en'
|
||||
import re
|
||||
import urllib
|
||||
from contextlib import closing
|
||||
import copy
|
||||
|
||||
from lxml import html
|
||||
|
||||
@ -66,13 +67,6 @@ class WoblinkStore(BasicStoreConfig, StorePlugin):
|
||||
price = ''.join(data.xpath('.//div[@class="prices"]/span[1]/span/text()'))
|
||||
price = re.sub('\.', ',', price)
|
||||
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.cover_url = 'http://woblink.com' + cover_url
|
||||
@ -83,12 +77,8 @@ class WoblinkStore(BasicStoreConfig, StorePlugin):
|
||||
|
||||
# MOBI should be send first,
|
||||
if 'MOBI' in formats:
|
||||
t = SearchResult()
|
||||
t.cover_url = s.cover_url
|
||||
t.title = s.title +' MOBI'
|
||||
t.author = s.author
|
||||
t.price = s.price
|
||||
t.detail_item = s.detail_item
|
||||
t = copy.copy(s)
|
||||
t.title += ' MOBI'
|
||||
t.drm = SearchResult.DRM_UNLOCKED
|
||||
t.formats = 'MOBI'
|
||||
formats.remove('MOBI')
|
||||
@ -98,15 +88,14 @@ class WoblinkStore(BasicStoreConfig, StorePlugin):
|
||||
|
||||
# and the remaining formats (if any) next
|
||||
if formats:
|
||||
s = SearchResult()
|
||||
s.cover_url = 'http://woblink.com' + cover_url
|
||||
s.title = title.strip()
|
||||
s.author = author.strip()
|
||||
s.price = price + ' zł'
|
||||
s.detail_item = id.strip()
|
||||
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')
|
||||
|
||||
s.drm = SearchResult.DRM_LOCKED
|
||||
s.formats = ', '.join(formats)
|
||||
s.formats = ', '.join(formats).upper()
|
||||
|
||||
counter -= 1
|
||||
yield s
|
||||
|
Loading…
x
Reference in New Issue
Block a user