diff --git a/recipes/perfil.recipe b/recipes/perfil.recipe index 1104202318..af7072c6f6 100644 --- a/recipes/perfil.recipe +++ b/recipes/perfil.recipe @@ -26,6 +26,7 @@ class Perfil(BasicNewsRecipe): .foto1 h1{font-size: x-small} h1{font-family: Georgia,"Times New Roman",serif} img{margin-bottom: 0.4em} + .hora{font-size: x-small; color: red} """ conversion_options = { @@ -60,7 +61,26 @@ class Perfil(BasicNewsRecipe): ,(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): for item in soup.findAll(style=True): 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 + \ No newline at end of file diff --git a/recipes/wsj.recipe b/recipes/wsj.recipe index cf84722bac..a3bc041d25 100644 --- a/recipes/wsj.recipe +++ b/recipes/wsj.recipe @@ -51,7 +51,7 @@ class WallStreetJournal(BasicNewsRecipe): br['password'] = self.password res = br.submit() 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 ' 'username and password') return br diff --git a/src/calibre/devices/hanvon/driver.py b/src/calibre/devices/hanvon/driver.py index 3798257c2d..3ce0fedac0 100644 --- a/src/calibre/devices/hanvon/driver.py +++ b/src/calibre/devices/hanvon/driver.py @@ -61,7 +61,7 @@ class LIBREAIR(N516): BCD = [0x399] 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' class ALEX(N516): diff --git a/src/calibre/gui2/jobs.py b/src/calibre/gui2/jobs.py index 20154a298b..589b28d520 100644 --- a/src/calibre/gui2/jobs.py +++ b/src/calibre/gui2/jobs.py @@ -432,6 +432,10 @@ class JobsDialog(QDialog, Ui_JobsDialog): self.jobs_view.horizontalHeader().restoreState(QByteArray(state)) except: 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): try: diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index 97454c90e2..006b381214 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -3,7 +3,7 @@ __license__ = 'GPL v3' __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 copy import deepcopy 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.logging import default_log as log 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', 'cover', 'formats','id', 'isbn', 'ondevice', 'pubdate', 'publisher', @@ -4704,24 +4704,33 @@ Author '{0}': 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 #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)) # Test cache for uuid - with ZipFile(self.__archive_path, mode='r') as zfr: - try: - t_info = zfr.getinfo(title['uuid']) - except: - pass - else: - if t_info.comment == cover_crc: + zf = open_archive() + if zf is not None: + with zf: + try: + zf.getinfo(title['uuid']+cover_crc) + except: + pass + else: # uuid found in cache with matching crc - thumb_data = zfr.read(title['uuid']) - zfr.extract(title['uuid'],image_dir) - os.rename(os.path.join(image_dir,title['uuid']), - os.path.join(image_dir,thumb_file)) + thumb_data = zf.read(title['uuid']) + with open(os.path.join(image_dir, thumb_file), 'wb') as f: + f.write(thumb_data) return @@ -4732,10 +4741,13 @@ Author '{0}': f.write(thumb_data) # Save thumb to archive - t_info = ZipInfo(title['uuid'],time.localtime()[0:6]) - t_info.comment = cover_crc - with ZipFile(self.__archive_path, mode='a') as zfw: - zfw.writestr(t_info, thumb_data) + if zf is not None: # Ensure that the read succeeded + # If we failed to open the zip file for reading, + # we dont know if it contained the thumb or not + zf = open_archive('a') + if zf is not None: + with zf: + zf.writestr(title['uuid']+cover_crc, thumb_data) def getFriendlyGenreTag(self, genre): # Find the first instance of friendly_tag matching genre