diff --git a/src/calibre/ebooks/lrf/comic/convert_from.py b/src/calibre/ebooks/lrf/comic/convert_from.py index fa004d1a16..0569bf3733 100755 --- a/src/calibre/ebooks/lrf/comic/convert_from.py +++ b/src/calibre/ebooks/lrf/comic/convert_from.py @@ -443,7 +443,7 @@ def do_convert(path_to_file, opts, notification=lambda m, p: p, output_format='l if output_format == 'pdf': create_pdf(pages, opts.profile, opts, thumbnail=thumbnail) shutil.rmtree(tdir) - if not opts.no_process: + if not getattr(opts, 'no_process', False): shutil.rmtree(tdir2) @@ -457,7 +457,7 @@ def main(args=sys.argv, notification=None, output_format='lrf'): if not callable(notification): pb = ProgressBar(terminal_controller, _('Rendering comic pages...'), - no_progress_bar=opts.no_progress_bar) + no_progress_bar=opts.no_progress_bar or getattr(opts, 'no_process', False)) notification = pb.update source = os.path.abspath(args[1]) diff --git a/src/calibre/gui2/lrf_renderer/document.py b/src/calibre/gui2/lrf_renderer/document.py index 691e1481ee..76c94d23f1 100644 --- a/src/calibre/gui2/lrf_renderer/document.py +++ b/src/calibre/gui2/lrf_renderer/document.py @@ -406,7 +406,8 @@ class Document(QGraphicsScene): for font in lrf.font_map: fdata = QByteArray(lrf.font_map[font].data) id = QFontDatabase.addApplicationFontFromData(fdata) - font_map[font] = [str(i) for i in QFontDatabase.applicationFontFamilies(id)][0] + if id != -1: + font_map[font] = [str(i) for i in QFontDatabase.applicationFontFamilies(id)][0] if load_substitutions: from calibre.ebooks.lrf.fonts.liberation import LiberationMono_BoldItalic diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index 97ad934eeb..1bb252e97d 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -889,6 +889,9 @@ class Main(MainWindow, Ui_MainWindow): ids = [id for id in ids if self.library_view.model().db.has_id(id)] files = [self.library_view.model().db.format(id, prefs['output_format'], index_is_id=True, as_file=True) for id in ids] files = [f for f in files if f is not None] + if not files: + dynamic.set('news_to_be_synced', set([])) + return metadata = self.library_view.model().get_metadata(ids, rows_are_ids=True) names = [] for mi in metadata: diff --git a/src/calibre/library/database.py b/src/calibre/library/database.py index f14a1174fc..ecf272618f 100644 --- a/src/calibre/library/database.py +++ b/src/calibre/library/database.py @@ -1551,9 +1551,6 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE; - def has_book(self, mi): - return bool(self.conn.get('SELECT id FROM books where title=?', (mi.title,), all=False)) - def has_id(self, id): return self.conn.get('SELECT id FROM books where id=?', (id,), all=False) is not None diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index d3cefa47fa..da41dba57f 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -217,7 +217,11 @@ class ResultCache(SearchQueryParser): return self.index(id) def has_id(self, id): - return self._data[id] is not None + try: + return self._data[id] is not None + except IndexError: + pass + return False def refresh_ids(self, conn, ids): for id in ids: @@ -557,7 +561,15 @@ class LibraryDatabase2(LibraryDatabase): img.loadFromData(f.read()) return img return f if as_file else f.read() - + + def has_book(self, mi): + title = mi.title + if title: + if not isinstance(title, unicode): + title = title.decode(preferred_encoding, 'replace') + return bool(self.conn.get('SELECT id FROM books where title=?', (title,), all=False)) + return False + def has_cover(self, index, index_is_id=False): id = index if index_is_id else self.id(index) path = os.path.join(self.library_path, self.path(id, index_is_id=True), 'cover.jpg') diff --git a/src/calibre/web/feeds/recipes/__init__.py b/src/calibre/web/feeds/recipes/__init__.py index 362bfeeafc..0c6e48131e 100644 --- a/src/calibre/web/feeds/recipes/__init__.py +++ b/src/calibre/web/feeds/recipes/__init__.py @@ -21,7 +21,7 @@ recipe_modules = ['recipe_' + r for r in ( 'linux_magazine', 'telegraph_uk', 'utne', 'sciencedaily', 'forbes', 'time_magazine', 'endgadget', 'fudzilla', 'nspm_int', 'nspm', 'pescanik', 'spiegel_int', 'themarketticker', 'tomshardware', 'xkcd', 'ftd', 'zdnet', - 'joelonsoftware', 'telepolis', 'common_dreams', + 'joelonsoftware', 'telepolis', 'common_dreams', 'nin', )] import re, imp, inspect, time, os diff --git a/src/calibre/web/feeds/recipes/recipe_nin.py b/src/calibre/web/feeds/recipes/recipe_nin.py new file mode 100644 index 0000000000..65195b5616 --- /dev/null +++ b/src/calibre/web/feeds/recipes/recipe_nin.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python + +__license__ = 'GPL v3' +__copyright__ = '2008, Darko Miletic ' +''' +nin.co.yu +''' + +import re, urllib +from calibre.web.feeds.news import BasicNewsRecipe + +class Nin(BasicNewsRecipe): + title = 'NIN online' + __author__ = 'Darko Miletic' + description = 'Nedeljne informativne novine' + no_stylesheets = True + oldest_article = 15 + simultaneous_downloads = 1 + delay = 1 + encoding = 'utf8' + needs_subscription = True + PREFIX = 'http://www.nin.co.yu' + INDEX = PREFIX + '/?change_lang=ls' + LOGIN = PREFIX + '/?logout=true' + html2lrf_options = [ + '--comment' , description + , '--category' , 'news, politics, Serbia' + , '--publisher' , 'NIN' + ] + + preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')] + + def get_browser(self): + br = BasicNewsRecipe.get_browser() + br.open(self.INDEX) + if self.username is not None and self.password is not None: + data = urllib.urlencode({ 'login_name':self.username + ,'login_password':self.password + ,'imageField.x':'32' + ,'imageField.y':'15' + }) + br.open(self.LOGIN,data) + return br + + keep_only_tags =[dict(name='td', attrs={'width':'520'})] + remove_tags_after =dict(name='html') + feeds =[(u'NIN', u'http://www.nin.co.yu/misc/rss.php?feed=RSS2.0')] + + def get_cover_url(self): + cover_url = None + soup = self.index_to_soup(self.INDEX) + link_item = soup.find('img',attrs={'width':'100','height':'137','border':'0'}) + if link_item: + cover_url = self.PREFIX + link_item['src'] + return cover_url