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 re
|
||||||
import urllib
|
import urllib
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
|
import copy
|
||||||
|
|
||||||
from lxml import html
|
from lxml import html
|
||||||
|
|
||||||
@ -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,12 +77,8 @@ class WoblinkStore(BasicStoreConfig, StorePlugin):
|
|||||||
|
|
||||||
# MOBI should be send first,
|
# MOBI should be send first,
|
||||||
if 'MOBI' in formats:
|
if 'MOBI' in formats:
|
||||||
t = SearchResult()
|
t = copy.copy(s)
|
||||||
t.cover_url = s.cover_url
|
t.title += ' MOBI'
|
||||||
t.title = s.title +' MOBI'
|
|
||||||
t.author = s.author
|
|
||||||
t.price = s.price
|
|
||||||
t.detail_item = s.detail_item
|
|
||||||
t.drm = SearchResult.DRM_UNLOCKED
|
t.drm = SearchResult.DRM_UNLOCKED
|
||||||
t.formats = 'MOBI'
|
t.formats = 'MOBI'
|
||||||
formats.remove('MOBI')
|
formats.remove('MOBI')
|
||||||
@ -98,15 +88,14 @@ class WoblinkStore(BasicStoreConfig, StorePlugin):
|
|||||||
|
|
||||||
# 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 + ' zł'
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user