mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
a8bbb8f01e
@ -26,6 +26,7 @@ class Perfil(BasicNewsRecipe):
|
|||||||
.foto1 h1{font-size: x-small}
|
.foto1 h1{font-size: x-small}
|
||||||
h1{font-family: Georgia,"Times New Roman",serif}
|
h1{font-family: Georgia,"Times New Roman",serif}
|
||||||
img{margin-bottom: 0.4em}
|
img{margin-bottom: 0.4em}
|
||||||
|
.hora{font-size: x-small; color: red}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
conversion_options = {
|
conversion_options = {
|
||||||
@ -60,7 +61,26 @@ class Perfil(BasicNewsRecipe):
|
|||||||
,(u'Tecnologia' , u'http://www.perfil.com/rss/tecnologia.xml' )
|
,(u'Tecnologia' , u'http://www.perfil.com/rss/tecnologia.xml' )
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def get_article_url(self, article):
|
||||||
|
return article.get('guid', None)
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
for item in soup.findAll(style=True):
|
for item in soup.findAll(style=True):
|
||||||
del item['style']
|
del item['style']
|
||||||
|
for item in soup.findAll('a'):
|
||||||
|
limg = item.find('img')
|
||||||
|
if item.string is not None:
|
||||||
|
str = item.string
|
||||||
|
item.replaceWith(str)
|
||||||
|
else:
|
||||||
|
if limg:
|
||||||
|
item.name = 'div'
|
||||||
|
item.attrs = []
|
||||||
|
else:
|
||||||
|
str = self.tag_to_string(item)
|
||||||
|
item.replaceWith(str)
|
||||||
|
for item in soup.findAll('img'):
|
||||||
|
if not item.has_key('alt'):
|
||||||
|
item['alt'] = 'image'
|
||||||
return soup
|
return soup
|
||||||
|
|
@ -51,7 +51,7 @@ class WallStreetJournal(BasicNewsRecipe):
|
|||||||
br['password'] = self.password
|
br['password'] = self.password
|
||||||
res = br.submit()
|
res = br.submit()
|
||||||
raw = res.read()
|
raw = res.read()
|
||||||
if 'Welcome,' not in raw:
|
if 'Welcome,' not in raw and '>Logout<' not in raw:
|
||||||
raise ValueError('Failed to log in to wsj.com, check your '
|
raise ValueError('Failed to log in to wsj.com, check your '
|
||||||
'username and password')
|
'username and password')
|
||||||
return br
|
return br
|
||||||
|
@ -61,7 +61,7 @@ class LIBREAIR(N516):
|
|||||||
|
|
||||||
BCD = [0x399]
|
BCD = [0x399]
|
||||||
VENDOR_NAME = 'ALURATEK'
|
VENDOR_NAME = 'ALURATEK'
|
||||||
WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = '_FILE-STOR_GADGET'
|
WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = 'FILE-STOR_GADGET'
|
||||||
EBOOK_DIR_MAIN = 'Books'
|
EBOOK_DIR_MAIN = 'Books'
|
||||||
|
|
||||||
class ALEX(N516):
|
class ALEX(N516):
|
||||||
|
@ -432,6 +432,10 @@ class JobsDialog(QDialog, Ui_JobsDialog):
|
|||||||
self.jobs_view.horizontalHeader().restoreState(QByteArray(state))
|
self.jobs_view.horizontalHeader().restoreState(QByteArray(state))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
idx = self.jobs_view.model().index(0, 0)
|
||||||
|
if idx.isValid():
|
||||||
|
sm = self.jobs_view.selectionModel()
|
||||||
|
sm.select(idx, sm.ClearAndSelect|sm.Rows)
|
||||||
|
|
||||||
def save_state(self):
|
def save_state(self):
|
||||||
try:
|
try:
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Greg Riker'
|
__copyright__ = '2010, Greg Riker'
|
||||||
|
|
||||||
import codecs, datetime, htmlentitydefs, os, re, shutil, time, zlib
|
import codecs, datetime, htmlentitydefs, os, re, shutil, zlib
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from xml.sax.saxutils import escape
|
from xml.sax.saxutils import escape
|
||||||
@ -25,7 +25,7 @@ from calibre.utils.html2text import html2text
|
|||||||
from calibre.utils.icu import capitalize
|
from calibre.utils.icu import capitalize
|
||||||
from calibre.utils.logging import default_log as log
|
from calibre.utils.logging import default_log as log
|
||||||
from calibre.utils.magick.draw import thumbnail
|
from calibre.utils.magick.draw import thumbnail
|
||||||
from calibre.utils.zipfile import ZipFile, ZipInfo
|
from calibre.utils.zipfile import ZipFile
|
||||||
|
|
||||||
FIELDS = ['all', 'title', 'title_sort', 'author_sort', 'authors', 'comments',
|
FIELDS = ['all', 'title', 'title_sort', 'author_sort', 'authors', 'comments',
|
||||||
'cover', 'formats','id', 'isbn', 'ondevice', 'pubdate', 'publisher',
|
'cover', 'formats','id', 'isbn', 'ondevice', 'pubdate', 'publisher',
|
||||||
@ -4704,24 +4704,33 @@ Author '{0}':
|
|||||||
to be replaced.
|
to be replaced.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
def open_archive(mode='r'):
|
||||||
|
try:
|
||||||
|
return ZipFile(self.__archive_path, mode=mode)
|
||||||
|
except:
|
||||||
|
# Happens on windows if the file is opened by another
|
||||||
|
# process
|
||||||
|
pass
|
||||||
|
|
||||||
# Generate crc for current cover
|
# Generate crc for current cover
|
||||||
#self.opts.log.info(" generateThumbnail():")
|
#self.opts.log.info(" generateThumbnail():")
|
||||||
data = open(title['cover'], 'rb').read()
|
with open(title['cover'], 'rb') as f:
|
||||||
|
data = f.read()
|
||||||
cover_crc = hex(zlib.crc32(data))
|
cover_crc = hex(zlib.crc32(data))
|
||||||
|
|
||||||
# Test cache for uuid
|
# Test cache for uuid
|
||||||
with ZipFile(self.__archive_path, mode='r') as zfr:
|
zf = open_archive()
|
||||||
|
if zf is not None:
|
||||||
|
with zf:
|
||||||
try:
|
try:
|
||||||
t_info = zfr.getinfo(title['uuid'])
|
zf.getinfo(title['uuid']+cover_crc)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if t_info.comment == cover_crc:
|
|
||||||
# uuid found in cache with matching crc
|
# uuid found in cache with matching crc
|
||||||
thumb_data = zfr.read(title['uuid'])
|
thumb_data = zf.read(title['uuid'])
|
||||||
zfr.extract(title['uuid'],image_dir)
|
with open(os.path.join(image_dir, thumb_file), 'wb') as f:
|
||||||
os.rename(os.path.join(image_dir,title['uuid']),
|
f.write(thumb_data)
|
||||||
os.path.join(image_dir,thumb_file))
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
@ -4732,10 +4741,13 @@ Author '{0}':
|
|||||||
f.write(thumb_data)
|
f.write(thumb_data)
|
||||||
|
|
||||||
# Save thumb to archive
|
# Save thumb to archive
|
||||||
t_info = ZipInfo(title['uuid'],time.localtime()[0:6])
|
if zf is not None: # Ensure that the read succeeded
|
||||||
t_info.comment = cover_crc
|
# If we failed to open the zip file for reading,
|
||||||
with ZipFile(self.__archive_path, mode='a') as zfw:
|
# we dont know if it contained the thumb or not
|
||||||
zfw.writestr(t_info, thumb_data)
|
zf = open_archive('a')
|
||||||
|
if zf is not None:
|
||||||
|
with zf:
|
||||||
|
zf.writestr(title['uuid']+cover_crc, thumb_data)
|
||||||
|
|
||||||
def getFriendlyGenreTag(self, genre):
|
def getFriendlyGenreTag(self, genre):
|
||||||
# Find the first instance of friendly_tag matching genre
|
# Find the first instance of friendly_tag matching genre
|
||||||
|
Loading…
x
Reference in New Issue
Block a user