diff --git a/resources/catalog/section_list_templates.py b/resources/catalog/section_list_templates.py new file mode 100644 index 0000000000..7f92fad6ac --- /dev/null +++ b/resources/catalog/section_list_templates.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python +# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai + +__license__ = 'GPL v3' +__copyright__ = '2010, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + +''' + These templates control the content of titles displayed in the various sections + + Available fields: + {title} Title of the book + {series} Series name + {series_index} Number of the book in the series + {rating} Rating + {rating_parens} Rating, in parentheses + {pubyear} Year the book was published + {pubyear_parens} Year the book was published, in parentheses + +''' +# Books by Author +by_authors_normal_title_template = '{title} {pubyear_parens}' +by_authors_series_title_template = '[{series_index}] {title} {pubyear_parens}' + +# Books by Title +by_titles_normal_title_template = '{title}' +by_titles_series_title_template = '{title} ({series} [{series_index}])' + +# Books by Series +by_series_title_template = '[{series_index}] {title} {pubyear_parens}' + +# Books by Genre +by_genres_normal_title_template = '{title} {pubyear_parens}' +by_genres_series_title_template = '{series_index}. {title} {pubyear_parens}' + +# Recently Added +by_recently_added_normal_title_template = '{title}' +by_recently_added_series_title_template = '{title} ({series} [{series_index}])' + +# By Month added +by_month_added_normal_title_template = '{title} {pubyear_parens}' +by_month_added_series_title_template = '[{series_index}] {title} {pubyear_parens}' \ No newline at end of file diff --git a/resources/recipes/ars_technica.recipe b/resources/recipes/ars_technica.recipe index 3997ee4645..3a955d5e15 100644 --- a/resources/recipes/ars_technica.recipe +++ b/resources/recipes/ars_technica.recipe @@ -1,6 +1,5 @@ - __license__ = 'GPL v3' -__copyright__ = '2008-2010, Darko Miletic ' +__copyright__ = '2008-2011, Darko Miletic ' ''' arstechnica.com ''' @@ -9,19 +8,26 @@ import re from calibre.web.feeds.news import BasicNewsRecipe from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag -class ArsTechnica2(BasicNewsRecipe): +class ArsTechnica(BasicNewsRecipe): title = u'Ars Technica' language = 'en' - __author__ = 'Darko Miletic and Sujata Raman' + __author__ = 'Darko Miletic, Sujata Raman, Alexis Rohou' description = 'The art of technology' publisher = 'Ars Technica' category = 'news, IT, technology' - oldest_article = 2 + oldest_article = 5 max_articles_per_feed = 100 no_stylesheets = True encoding = 'utf-8' use_embedded_content = False - extra_css = ' body {font-family: Arial,Helvetica,sans-serif} .title{text-align: left} .byline{font-weight: bold; line-height: 1em; font-size: 0.625em; text-decoration: none} ' + extra_css = ''' + body {font-family: Arial,Helvetica,sans-serif} + .title{text-align: left} + .byline{font-weight: bold; line-height: 1em; font-size: 0.625em; text-decoration: none} + .news-item-figure-caption-text{font-size:small; font-style:italic} + .news-item-figure-caption-byline{font-size:small; font-style:italic; font-weight:bold} + ''' + ignoreEtcArticles = True # Etc feed items can be ignored, as they're not real stories conversion_options = { 'comments' : description @@ -31,10 +37,10 @@ class ArsTechnica2(BasicNewsRecipe): } - preprocess_regexps = [ - (re.compile(r'
.*?', re.DOTALL|re.IGNORECASE),lambda match: '') - ] + #preprocess_regexps = [ + # (re.compile(r'
.*?', re.DOTALL|re.IGNORECASE),lambda match: '') + # ] keep_only_tags = [dict(name='div', attrs={'id':['story','etc-story']})] @@ -42,7 +48,7 @@ class ArsTechnica2(BasicNewsRecipe): dict(name=['object','link','embed']) ,dict(name='div', attrs={'class':'read-more-link'}) ] - remove_attributes=['width','height'] + #remove_attributes=['width','height'] feeds = [ (u'Infinite Loop (Apple content)' , u'http://feeds.arstechnica.com/arstechnica/apple/' ) @@ -56,6 +62,7 @@ class ArsTechnica2(BasicNewsRecipe): ,(u'Law & Disorder (Tech policy content)' , u'http://feeds.arstechnica.com/arstechnica/tech-policy/') ] + # This deals with multi-page stories def append_page(self, soup, appendtag, position): pager = soup.find('div',attrs={'class':'pager'}) if pager: @@ -81,6 +88,7 @@ class ArsTechnica2(BasicNewsRecipe): def preprocess_html(self, soup): + # Adds line breaks near the byline (not sure why this is needed) ftag = soup.find('div', attrs={'class':'byline'}) if ftag: brtag = Tag(soup,'br') @@ -88,12 +96,33 @@ class ArsTechnica2(BasicNewsRecipe): ftag.insert(4,brtag) ftag.insert(5,brtag2) + # Remove style items for item in soup.findAll(style=True): del item['style'] + # Remove id + for item in soup.findAll(id=True): + del item['id'] + + # For some reason, links to authors don't have the domainname + a_author = soup.find('a',{'href':re.compile("^/author")}) + if a_author: + a_author['href'] = 'http://arstechnica.com'+a_author['href'] + + # within div class news-item-figure, we need to grab images + + # Deal with multi-page stories self.append_page(soup, soup.body, 3) return soup def get_article_url(self, article): + # If the article title starts with Etc:, don't return it + if self.ignoreEtcArticles: + article_title = article.get('title',None) + if re.match('Etc: ',article_title) is not None: + return None + + # The actual article is in a guid tag return article.get('guid', None).rpartition('?')[0] + diff --git a/resources/recipes/dilbert.recipe b/resources/recipes/dilbert.recipe index 2c3268da2f..56aa4af8c9 100644 --- a/resources/recipes/dilbert.recipe +++ b/resources/recipes/dilbert.recipe @@ -28,7 +28,7 @@ class DilbertBig(BasicNewsRecipe): ,'publisher' : publisher } - feeds = [(u'Dilbert', u'http://feeds.dilbert.com/DilbertDailyStrip' )] + feeds = [(u'Dilbert', u'http://feed.dilbert.com/dilbert/daily_strip' )] def get_article_url(self, article): return article.get('feedburner_origlink', None) diff --git a/resources/recipes/economist.recipe b/resources/recipes/economist.recipe index 01ee8e0baf..95b4a2ae05 100644 --- a/resources/recipes/economist.recipe +++ b/resources/recipes/economist.recipe @@ -9,7 +9,7 @@ from calibre.web.feeds.news import BasicNewsRecipe from calibre.ebooks.BeautifulSoup import BeautifulSoup from calibre.ebooks.BeautifulSoup import Tag, NavigableString -import mechanize, string, urllib, time, re +import string, time, re class Economist(BasicNewsRecipe): @@ -18,19 +18,19 @@ class Economist(BasicNewsRecipe): __author__ = "Kovid Goyal" INDEX = 'http://www.economist.com/printedition' - description = ('Global news and current affairs from a European perspective.' - ' Needs a subscription from ')+INDEX + description = 'Global news and current affairs from a European perspective.' oldest_article = 7.0 cover_url = 'http://www.economist.com/images/covers/currentcoverus_large.jpg' remove_tags = [dict(name=['script', 'noscript', 'title', 'iframe', 'cf_floatingcontent']), dict(attrs={'class':['dblClkTrk', 'ec-article-info']})] keep_only_tags = [dict(id='ec-article-body')] - needs_subscription = True + needs_subscription = False no_stylesheets = True preprocess_regexps = [(re.compile('.*', re.DOTALL), lambda x:'')] + ''' def get_browser(self): br = BasicNewsRecipe.get_browser() br.open('http://www.economist.com') @@ -50,6 +50,7 @@ class Economist(BasicNewsRecipe): })) br.open(req).read() return br + ''' def parse_index(self): try: diff --git a/resources/recipes/economist_free.recipe b/resources/recipes/economist_free.recipe index 1a783521f6..321c7d29ce 100644 --- a/resources/recipes/economist_free.recipe +++ b/resources/recipes/economist_free.recipe @@ -7,12 +7,12 @@ from lxml import html class Economist(BasicNewsRecipe): - title = 'The Economist (free)' + title = 'The Economist (RSS)' language = 'en' __author__ = "Kovid Goyal" description = ('Global news and current affairs from a European perspective.' - ' Much slower than the subscription based version.') + ' Much slower than the print edition based version.') oldest_article = 7.0 cover_url = 'http://www.economist.com/images/covers/currentcoverus_large.jpg' diff --git a/resources/recipes/ihned.recipe b/resources/recipes/ihned.recipe new file mode 100644 index 0000000000..a74f9e5649 --- /dev/null +++ b/resources/recipes/ihned.recipe @@ -0,0 +1,182 @@ +import re, time +from calibre import strftime +from calibre.web.feeds.recipes import BasicNewsRecipe + +class IHNed(BasicNewsRecipe): + + + stahnout_vsechny = True + #True = stahuje vsechny z homepage + #False = stahuje pouze dnesni clanky (ze dne, kdy je skript spusten) + + title = 'iHNed' + __author__ = 'Karel Bílek' + language = 'cs' + description = 'Zprávy z iHNed.cz' + timefmt = ' [%a, %d %b, %Y]' + needs_subscription = False + remove_tags = [dict(attrs={'class':['borderbottom', 'web', 'foot', 'reklama', 'd-elm d-rellinks', 'd-elm']}), + dict(style=['text-align: center;']), + dict(id=['r-bfull']), + dict(name=['script', 'noscript', 'style'])] + encoding = 'windows-1250' + no_stylesheets = True + remove_tags_before = dict(attrs={'class':'d-nadtit'}) + remove_tags_after = dict(attrs={'class':'like'}) + + conversion_options = { + 'linearize_tables' : True, + } + + + + def preprocess_html(self, soup): + + def makeurl(wat): + return "http://ihned.cz"+wat; + + for h1 in soup.findAll('h1'): + a = h1.find('a') + if a: + string = a.string + if string: + soup.a.replaceWith(string) + for a in soup.findAll('a', href=True) : + cil = str(a['href']) + if cil.startswith("/") or cil.startswith("index"): + a['href'] = makeurl(cil) + return soup + + + def parse_index(self): + + def makeurl(wat): + if wat.startswith("/") or wat.startswith("index"): + return "http://ihned.cz"+wat; + else: + return wat + + + articles = {} #vysledek, asi + key = None #soucasna sekce + ans = [] #vsechny sekce + + articles["Hlavní"] = [] + ans.append("Hlavní") + + was = {} + + def parse_subpage(url, name): + articles[name] = [] + ans.append(name) + + + soup = self.index_to_soup(url) + otvirak = soup.find(True, attrs={'class':['otv']}) + if otvirak: + + #the code is copypasted here because I don't know python. simple as that. + a = otvirak.find('a', href=True) + title = self.tag_to_string(a, use_alt=True).strip() + txt = otvirak.find(True, attrs={'class':['txt']}) + description = '' + if txt: + match = re.match(r'
\s*([^<]*)\s*\s*([^<]*)\s*\s*([^<]*)\s*>> No class:'columnGroup first' found <<<") + except: + self.log("ERROR: One picture per article in postprocess_html") - if self.one_picture_per_article: - # Remove all images after first - largeImg = soup.find(True, {'class':'articleSpanImage'}) - inlineImgs = soup.findAll(True, {'class':'inlineImage module'}) - if largeImg: - for inlineImg in inlineImgs: - inlineImg.extract() - else: - if inlineImgs: - firstImg = inlineImgs[0] - for inlineImg in inlineImgs[1:]: - inlineImg.extract() - # Move firstImg before article body - cgFirst = soup.find(True, {'class':re.compile('columnGroup *first')}) - if cgFirst: - # Strip all sibling NavigableStrings: noise - navstrings = cgFirst.findAll(text=True, recursive=False) - [ns.extract() for ns in navstrings] - headline_found = False - tag = cgFirst.find(True) - insertLoc = 0 - while True: - insertLoc += 1 - if hasattr(tag,'class') and tag['class'] == 'articleHeadline': - headline_found = True - break - tag = tag.nextSibling - if not tag: - headline_found = False - break - if headline_found: - cgFirst.insert(insertLoc,firstImg) - else: - self.log(">>> No class:'columnGroup first' found <<<") + try: + # Change captions to italic + for caption in soup.findAll(True, {'class':'caption'}) : + if caption and len(caption) > 0: + cTag = Tag(soup, "p", [("class", "caption")]) + c = self.fixChars(self.tag_to_string(caption,use_alt=False)).strip() + mp_off = c.find("More Photos") + if mp_off >= 0: + c = c[:mp_off] + cTag.insert(0, c) + caption.replaceWith(cTag) + except: + self.log("ERROR: Problem in change captions to italic") - # Change captions to italic - for caption in soup.findAll(True, {'class':'caption'}) : - if caption and caption.contents[0]: - cTag = Tag(soup, "p", [("class", "caption")]) - c = self.fixChars(self.tag_to_string(caption,use_alt=False)).strip() - mp_off = c.find("More Photos") - if mp_off >= 0: - c = c[:mp_off] - cTag.insert(0, c) - caption.replaceWith(cTag) + try: + # Change to

+ h1 = soup.find('h1') + if h1: + headline = h1.find("nyt_headline") + if headline: + tag = Tag(soup, "h2") + tag['class'] = "headline" + tag.insert(0, self.fixChars(headline.contents[0])) + h1.replaceWith(tag) + else: + # Blog entry - replace headline, remove
tags + headline = soup.find('title') + if headline: + tag = Tag(soup, "h2") + tag['class'] = "headline" + tag.insert(0, self.fixChars(headline.contents[0])) + soup.insert(0, tag) + hrs = soup.findAll('hr') + for hr in hrs: + hr.extract() + except: + self.log("ERROR: Problem in Change to

") - # Change to

- h1 = soup.find('h1') - if h1: - headline = h1.find("nyt_headline") - if headline: - tag = Tag(soup, "h2") - tag['class'] = "headline" - tag.insert(0, self.fixChars(headline.contents[0])) - h1.replaceWith(tag) - else: - # Blog entry - replace headline, remove
tags - headline = soup.find('title') - if headline: - tag = Tag(soup, "h2") - tag['class'] = "headline" - tag.insert(0, self.fixChars(headline.contents[0])) - soup.insert(0, tag) - hrs = soup.findAll('hr') - for hr in hrs: - hr.extract() + try: + # Change

to

- used in editorial blogs + masthead = soup.find("h1") + if masthead: + # Nuke the href + if masthead.a: + del(masthead.a['href']) + tag = Tag(soup, "h3") + tag.insert(0, self.fixChars(masthead.contents[0])) + masthead.replaceWith(tag) + except: + self.log("ERROR: Problem in Change

to

- used in editorial blogs") - # Change

to

- used in editorial blogs - masthead = soup.find("h1") - if masthead: - # Nuke the href - if masthead.a: - del(masthead.a['href']) - tag = Tag(soup, "h3") - tag.insert(0, self.fixChars(masthead.contents[0])) - masthead.replaceWith(tag) + try: + # Change to + for subhead in soup.findAll(True, {'class':'bold'}) : + if subhead.contents: + bTag = Tag(soup, "b") + bTag.insert(0, subhead.contents[0]) + subhead.replaceWith(bTag) + except: + self.log("ERROR: Problem in Change

to

- used in editorial blogs") - # Change to - for subhead in soup.findAll(True, {'class':'bold'}) : - if subhead.contents: - bTag = Tag(soup, "b") - bTag.insert(0, subhead.contents[0]) - subhead.replaceWith(bTag) + try: + divTag = soup.find('div',attrs={'id':'articleBody'}) + if divTag: + divTag['class'] = divTag['id'] + except: + self.log("ERROR: Problem in soup.find(div,attrs={id:articleBody})") - divTag = soup.find('div',attrs={'id':'articleBody'}) - if divTag: - divTag['class'] = divTag['id'] + try: + # Add class="authorId" to
so we can format with CSS + divTag = soup.find('div',attrs={'id':'authorId'}) + if divTag and divTag.contents[0]: + tag = Tag(soup, "p") + tag['class'] = "authorId" + tag.insert(0, self.fixChars(self.tag_to_string(divTag.contents[0], + use_alt=False))) + divTag.replaceWith(tag) + except: + self.log("ERROR: Problem in Add class=authorId to
so we can format with CSS") - # Add class="authorId" to
so we can format with CSS - divTag = soup.find('div',attrs={'id':'authorId'}) - if divTag and divTag.contents[0]: - tag = Tag(soup, "p") - tag['class'] = "authorId" - tag.insert(0, self.fixChars(self.tag_to_string(divTag.contents[0], - use_alt=False))) - divTag.replaceWith(tag) - - return soup + return soup def populate_article_metadata(self, article, soup, first): shortparagraph = "" diff --git a/resources/recipes/nytimes_sub.recipe b/resources/recipes/nytimes_sub.recipe index 8ac7c735f7..8f92852237 100644 --- a/resources/recipes/nytimes_sub.recipe +++ b/resources/recipes/nytimes_sub.recipe @@ -586,105 +586,125 @@ class NYTimes(BasicNewsRecipe): return self.strip_anchors(soup) def postprocess_html(self,soup, True): + try: + if self.one_picture_per_article: + # Remove all images after first + largeImg = soup.find(True, {'class':'articleSpanImage'}) + inlineImgs = soup.findAll(True, {'class':'inlineImage module'}) + if largeImg: + for inlineImg in inlineImgs: + inlineImg.extract() + else: + if inlineImgs: + firstImg = inlineImgs[0] + for inlineImg in inlineImgs[1:]: + inlineImg.extract() + # Move firstImg before article body + cgFirst = soup.find(True, {'class':re.compile('columnGroup *first')}) + if cgFirst: + # Strip all sibling NavigableStrings: noise + navstrings = cgFirst.findAll(text=True, recursive=False) + [ns.extract() for ns in navstrings] + headline_found = False + tag = cgFirst.find(True) + insertLoc = 0 + while True: + insertLoc += 1 + if hasattr(tag,'class') and tag['class'] == 'articleHeadline': + headline_found = True + break + tag = tag.nextSibling + if not tag: + headline_found = False + break + if headline_found: + cgFirst.insert(insertLoc,firstImg) + else: + self.log(">>> No class:'columnGroup first' found <<<") + except: + self.log("ERROR: One picture per article in postprocess_html") + + try: + # Change captions to italic + for caption in soup.findAll(True, {'class':'caption'}) : + if caption and len(caption) > 0: + cTag = Tag(soup, "p", [("class", "caption")]) + c = self.fixChars(self.tag_to_string(caption,use_alt=False)).strip() + mp_off = c.find("More Photos") + if mp_off >= 0: + c = c[:mp_off] + cTag.insert(0, c) + caption.replaceWith(cTag) + except: + self.log("ERROR: Problem in change captions to italic") + + try: + # Change to

+ h1 = soup.find('h1') + if h1: + headline = h1.find("nyt_headline") + if headline: + tag = Tag(soup, "h2") + tag['class'] = "headline" + tag.insert(0, self.fixChars(headline.contents[0])) + h1.replaceWith(tag) + else: + # Blog entry - replace headline, remove
tags + headline = soup.find('title') + if headline: + tag = Tag(soup, "h2") + tag['class'] = "headline" + tag.insert(0, self.fixChars(headline.contents[0])) + soup.insert(0, tag) + hrs = soup.findAll('hr') + for hr in hrs: + hr.extract() + except: + self.log("ERROR: Problem in Change to

") - if self.one_picture_per_article: - # Remove all images after first - largeImg = soup.find(True, {'class':'articleSpanImage'}) - inlineImgs = soup.findAll(True, {'class':'inlineImage module'}) - if largeImg: - for inlineImg in inlineImgs: - inlineImg.extract() - else: - if inlineImgs: - firstImg = inlineImgs[0] - for inlineImg in inlineImgs[1:]: - inlineImg.extract() - # Move firstImg before article body - cgFirst = soup.find(True, {'class':re.compile('columnGroup *first')}) - if cgFirst: - # Strip all sibling NavigableStrings: noise - navstrings = cgFirst.findAll(text=True, recursive=False) - [ns.extract() for ns in navstrings] - headline_found = False - tag = cgFirst.find(True) - insertLoc = 0 - while True: - insertLoc += 1 - if hasattr(tag,'class') and tag['class'] == 'articleHeadline': - headline_found = True - break - tag = tag.nextSibling - if not tag: - headline_found = False - break - if headline_found: - cgFirst.insert(insertLoc,firstImg) - else: - self.log(">>> No class:'columnGroup first' found <<<") + try: + # Change

to

- used in editorial blogs + masthead = soup.find("h1") + if masthead: + # Nuke the href + if masthead.a: + del(masthead.a['href']) + tag = Tag(soup, "h3") + tag.insert(0, self.fixChars(masthead.contents[0])) + masthead.replaceWith(tag) + except: + self.log("ERROR: Problem in Change

to

- used in editorial blogs") - # Change captions to italic - for caption in soup.findAll(True, {'class':'caption'}) : - if caption and caption.contents[0]: - cTag = Tag(soup, "p", [("class", "caption")]) - c = self.fixChars(self.tag_to_string(caption,use_alt=False)).strip() - mp_off = c.find("More Photos") - if mp_off >= 0: - c = c[:mp_off] - cTag.insert(0, c) - caption.replaceWith(cTag) - - # Change to

- h1 = soup.find('h1') - if h1: - headline = h1.find("nyt_headline") - if headline: - tag = Tag(soup, "h2") - tag['class'] = "headline" - tag.insert(0, self.fixChars(headline.contents[0])) - h1.replaceWith(tag) - else: - # Blog entry - replace headline, remove
tags - headline = soup.find('title') - if headline: - tag = Tag(soup, "h2") - tag['class'] = "headline" - tag.insert(0, self.fixChars(headline.contents[0])) - soup.insert(0, tag) - hrs = soup.findAll('hr') - for hr in hrs: - hr.extract() - - # Change

to

- used in editorial blogs - masthead = soup.find("h1") - if masthead: - # Nuke the href - if masthead.a: - del(masthead.a['href']) - tag = Tag(soup, "h3") - tag.insert(0, self.fixChars(masthead.contents[0])) - masthead.replaceWith(tag) - - # Change to - for subhead in soup.findAll(True, {'class':'bold'}) : - if subhead.contents: - bTag = Tag(soup, "b") - bTag.insert(0, subhead.contents[0]) - subhead.replaceWith(bTag) - - divTag = soup.find('div',attrs={'id':'articleBody'}) - if divTag: - divTag['class'] = divTag['id'] - - # Add class="authorId" to
so we can format with CSS - divTag = soup.find('div',attrs={'id':'authorId'}) - if divTag and divTag.contents[0]: - tag = Tag(soup, "p") - tag['class'] = "authorId" - tag.insert(0, self.fixChars(self.tag_to_string(divTag.contents[0], - use_alt=False))) - divTag.replaceWith(tag) - - return soup + try: + # Change to + for subhead in soup.findAll(True, {'class':'bold'}) : + if subhead.contents: + bTag = Tag(soup, "b") + bTag.insert(0, subhead.contents[0]) + subhead.replaceWith(bTag) + except: + self.log("ERROR: Problem in Change

to

- used in editorial blogs") + + try: + divTag = soup.find('div',attrs={'id':'articleBody'}) + if divTag: + divTag['class'] = divTag['id'] + except: + self.log("ERROR: Problem in soup.find(div,attrs={id:articleBody})") + + try: + # Add class="authorId" to
so we can format with CSS + divTag = soup.find('div',attrs={'id':'authorId'}) + if divTag and divTag.contents[0]: + tag = Tag(soup, "p") + tag['class'] = "authorId" + tag.insert(0, self.fixChars(self.tag_to_string(divTag.contents[0], + use_alt=False))) + divTag.replaceWith(tag) + except: + self.log("ERROR: Problem in Add class=authorId to
so we can format with CSS") + + return soup def populate_article_metadata(self, article, soup, first): shortparagraph = "" try: diff --git a/resources/recipes/seattle_times.recipe b/resources/recipes/seattle_times.recipe index 7fcea9cae5..cd7f96fc8b 100644 --- a/resources/recipes/seattle_times.recipe +++ b/resources/recipes/seattle_times.recipe @@ -21,16 +21,53 @@ class SeattleTimes(BasicNewsRecipe): encoding = 'cp1252' language = 'en' - - html2lrf_options = [ - '--comment' , description - , '--category' , category - , '--publisher', publisher - ] - - html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"' - - feeds = [(u'Articles', u'http://seattletimes.nwsource.com/rss/seattletimes.xml')] + feeds = [ + (u'Top Stories', + u'http://seattletimes.nwsource.com/rss/home.xml'), + #(u'Articles', u'http://seattletimes.nwsource.com/rss/seattletimes.xml') + (u'Business & Technology', + u'http://seattletimes.nwsource.com/rss/businesstechnology.xml'), + (u'Personal Technology', + u'http://seattletimes.nwsource.com/rss/personaltechnology.xml'), + (u'Entertainment & the Arts', + u'http://seattletimes.nwsource.com/rss/artsentertainment.xml'), + (u'Health', + u'http://seattletimes.nwsource.com/rss/health.xml'), + (u'Living', + u'http://seattletimes.nwsource.com/rss/living.xml'), + (u'Local News', + u'http://seattletimes.nwsource.com/rss/localnews.xml'), + (u'Nation & World', + u'http://seattletimes.nwsource.com/rss/nationworld.xml'), + (u'Opinion', + u'http://seattletimes.nwsource.com/rss/opinion.xml'), + (u'Politics', + u'http://seattletimes.nwsource.com/rss/politics.xml'), + (u'Sports', + u'http://seattletimes.nwsource.com/rss/sports.xml'), + (u'Nicole Brodeur', + u'http://seattletimes.nwsource.com/rss/nicolebrodeur.xml'), + (u'Danny Westneat', + u'http://seattletimes.nwsource.com/rss/dannywestneat.xml'), + (u'Jerry Large', + u'http://seattletimes.nwsource.com/rss/jerrylarge.xml'), + (u'Ron Judd', + u'http://seattletimes.nwsource.com/rss/ronjudd.xml'), + (u'Education', + u'http://seattletimes.nwsource.com/rss/education.xml'), + (u'Letters to the Editor', + u'http://seattletimes.nwsource.com/rss/northwestvoices.xml'), + (u'Travel', + u'http://seattletimes.nwsource.com/rss/travel.xml'), + (u'Outdoors', + u'http://seattletimes.nwsource.com/rss/outdoors.xml'), + (u'Steve Kelley', + u'http://seattletimes.nwsource.com/rss/stevekelley.xml'), + (u'Jerry Brewer', + u'http://seattletimes.nwsource.com/rss/jerrybrewer.xml'), + (u'Most Read Articles', + u'http://seattletimes.nwsource.com/rss/mostreadarticles.xml'), + ] remove_tags = [ dict(name=['object','link','script']) diff --git a/src/calibre/devices/android/driver.py b/src/calibre/devices/android/driver.py index 5a82882dfa..277070020b 100644 --- a/src/calibre/devices/android/driver.py +++ b/src/calibre/devices/android/driver.py @@ -36,7 +36,7 @@ class ANDROID(USBMS): # Google 0x18d1 : { 0x4e11 : [0x0100, 0x226, 0x227], 0x4e12: [0x0100, 0x226, - 0x227], 0x4e21: [0x0100, 0x226, 0x227]}, + 0x227], 0x4e21: [0x0100, 0x226, 0x227], 0xb058: [0x0222]}, # Samsung 0x04e8 : { 0x681d : [0x0222, 0x0223, 0x0224, 0x0400], @@ -64,12 +64,13 @@ class ANDROID(USBMS): EXTRA_CUSTOMIZATION_DEFAULT = ', '.join(EBOOK_DIR_MAIN) VENDOR_NAME = ['HTC', 'MOTOROLA', 'GOOGLE_', 'ANDROID', 'ACER', - 'GT-I5700', 'SAMSUNG', 'DELL', 'LINUX', 'GOOGLE', 'ARCHOS'] + 'GT-I5700', 'SAMSUNG', 'DELL', 'LINUX', 'GOOGLE', 'ARCHOS', + 'TELECHIP'] WINDOWS_MAIN_MEM = ['ANDROID_PHONE', 'A855', 'A853', 'INC.NEXUS_ONE', '__UMS_COMPOSITE', '_MB200', 'MASS_STORAGE', '_-_CARD', 'SGH-I897', 'GT-I9000', 'FILE-STOR_GADGET', 'SGH-T959', 'SAMSUNG_ANDROID', 'SCH-I500_CARD', 'SPH-D700_CARD', 'MB810', 'GT-P1000', 'DESIRE', - 'SGH-T849', '_MB300', 'A70S'] + 'SGH-T849', '_MB300', 'A70S', 'S_ANDROID'] WINDOWS_CARD_A_MEM = ['ANDROID_PHONE', 'GT-I9000_CARD', 'SGH-I897', 'FILE-STOR_GADGET', 'SGH-T959', 'SAMSUNG_ANDROID', 'GT-P1000_CARD', 'A70S'] diff --git a/src/calibre/devices/eb600/driver.py b/src/calibre/devices/eb600/driver.py index 3201229699..95f6dc6ab0 100644 --- a/src/calibre/devices/eb600/driver.py +++ b/src/calibre/devices/eb600/driver.py @@ -178,7 +178,7 @@ class INVESBOOK(EB600): class BOOQ(EB600): name = 'Booq Device Interface' - gui_name = 'Booq' + gui_name = 'bq Reader' FORMATS = ['epub', 'mobi', 'prc', 'fb2', 'pdf', 'doc', 'rtf', 'txt', 'html'] diff --git a/src/calibre/devices/misc.py b/src/calibre/devices/misc.py index ecd12ac61d..9f8dbcb379 100644 --- a/src/calibre/devices/misc.py +++ b/src/calibre/devices/misc.py @@ -33,8 +33,8 @@ class PALMPRE(USBMS): class AVANT(USBMS): name = 'Booq Avant Device Interface' - gui_name = 'Avant' - description = _('Communicate with the Booq Avant') + gui_name = 'bq Avant' + description = _('Communicate with the Bq Avant') author = 'Kovid Goyal' supported_platforms = ['windows', 'osx', 'linux'] @@ -193,6 +193,9 @@ class LUMIREAD(USBMS): THUMBNAIL_HEIGHT = 200 + VENDOR_NAME = 'ACER' + WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = 'LUMIREAD_600' + def upload_cover(self, path, filename, metadata, filepath): if metadata.thumbnail and metadata.thumbnail[-1]: cfilepath = filepath.replace('/', os.sep) diff --git a/src/calibre/devices/sne/driver.py b/src/calibre/devices/sne/driver.py index 04e5cd0d76..bb8d34c59c 100644 --- a/src/calibre/devices/sne/driver.py +++ b/src/calibre/devices/sne/driver.py @@ -33,6 +33,6 @@ class SNE(USBMS): STORAGE_CARD_VOLUME_LABEL = 'SNE Storage Card' EBOOK_DIR_MAIN = EBOOK_DIR_CARD_A = 'Books' - SUPPORTS_SUB_DIRS = False + SUPPORTS_SUB_DIRS = True diff --git a/src/calibre/ebooks/conversion/preprocess.py b/src/calibre/ebooks/conversion/preprocess.py index 08a46cb8d9..56c3077118 100644 --- a/src/calibre/ebooks/conversion/preprocess.py +++ b/src/calibre/ebooks/conversion/preprocess.py @@ -360,7 +360,7 @@ class HTMLPreProcessor(object): (re.compile(r'((?<=)\s*file:////?[A-Z].*
|file:////?[A-Z].*
(?=\s*
))', re.IGNORECASE), lambda match: ''), # Center separator lines - (re.compile(u'
\s*(?P([*#•✦]+\s*)+)\s*
'), lambda match: '

\n

' + match.group(1) + '

'), + (re.compile(u'
\s*(?P([*#•✦=]+\s*)+)\s*
'), lambda match: '

\n

' + match.group(1) + '

'), # Remove page links (re.compile(r'', re.IGNORECASE), lambda match: ''), @@ -480,7 +480,7 @@ class HTMLPreProcessor(object): end_rules.append((re.compile(u'(?<=.{%i}[–—])\s*

\s*(?=[[a-z\d])' % length), lambda match: '')) end_rules.append( # Un wrap using punctuation - (re.compile(u'(?<=.{%i}([a-zäëïöüàèìòùáćéíóńśúâêîôûçąężıãõñæøþðß,:)\IA\u00DF]|(?)?\s*(

\s*

\s*)+\s*(?=(<(i|b|u)>)?\s*[\w\d$(])' % length, re.UNICODE), wrap_lines), + (re.compile(u'(?<=.{%i}([a-zäëïöüàèìòùáćéíóńśúâêîôûçąężıãõñæøþðßě,:)\IA\u00DF]|(?)?\s*(

\s*

\s*)+\s*(?=(<(i|b|u)>)?\s*[\w\d$(])' % length, re.UNICODE), wrap_lines), ) for rule in self.PREPROCESS + start_rules: diff --git a/src/calibre/ebooks/conversion/utils.py b/src/calibre/ebooks/conversion/utils.py index dac93fa2e2..7732bb2b4d 100644 --- a/src/calibre/ebooks/conversion/utils.py +++ b/src/calibre/ebooks/conversion/utils.py @@ -151,13 +151,13 @@ class PreProcessor(object): n_lookahead_open = "\s+(?!" n_lookahead_close = ")" - default_title = r"(<[ibu][^>]*>)?\s{0,3}([\w\'\"-]+\s{0,3}){1,5}?(]*>)?(?=<)" + default_title = r"(<[ibu][^>]*>)?\s{0,3}([\w\:\'\"-]+\s{0,3}){1,5}?(]*>)?(?=<)" chapter_types = [ [r"[^'\"]?(Introduction|Synopsis|Acknowledgements|Chapter|Kapitel|Epilogue|Volume\s|Prologue|Book\s|Part\s|Dedication|Preface)\s*([\d\w-]+\:?\'?\s*){0,5}", True, "Searching for common Chapter Headings"], + [r"([A-Z-]\s+){3,}\s*([\d\w-]+\s*){0,3}\s*", True, "Searching for letter spaced headings"], # Spaced Lettering [r"]*>\s*(]*>)?\s*(?!([*#•]+\s*)+)(\s*(?=[\d.\w#\-*\s]+<)([\d.\w#-*]+\s*){1,5}\s*)(?!\.)()?\s*", True, "Searching for emphasized lines"], # Emphasized lines [r"[^'\"]?(\d+(\.|:)|CHAPTER)\s*([\dA-Z\-\'\"#,]+\s*){0,7}\s*", True, "Searching for numeric chapter headings"], # Numeric Chapters - [r"([A-Z]\s+){3,}\s*([\d\w-]+\s*){0,3}\s*", True, "Searching for letter spaced headings"], # Spaced Lettering [r"[^'\"]?(\d+\.?\s+([\d\w-]+\:?\'?-?\s?){0,5})\s*", True, "Searching for numeric chapters with titles"], # Numeric Titles [r"[^'\"]?(\d+|CHAPTER)\s*([\dA-Z\-\'\"\?!#,]+\s*){0,7}\s*", True, "Searching for simple numeric chapter headings"], # Numeric Chapters, no dot or colon [r"\s*[^'\"]?([A-Z#]+(\s|-){0,3}){1,5}\s*", False, "Searching for chapters with Uppercase Characters" ] # Uppercase Chapters @@ -186,7 +186,7 @@ class PreProcessor(object): def punctuation_unwrap(self, length, content, format): # define the pieces of the regex - lookahead = "(?<=.{"+str(length)+"}([a-zäëïöüàèìòùáćéíóńśúâêîôûçąężıãõñæøþðß,:)\IA\u00DF]|(?\s*()?" blanklines = "\s*(?P<(p|span|div)[^>]*>\s*(<(p|span|div)[^>]*>\s*\s*)\s*){0,3}\s*" line_opening = "<(span|div|p)[^>]*>\s*(<(span|div|p)[^>]*>)?\s*" @@ -357,6 +357,6 @@ class PreProcessor(object): html = blankreg.sub('\n'+r'\g'+u'\u00a0'+r'\g', html) # Center separator lines - html = re.sub(u'<(?Pp|div)[^>]*>\s*(<(?Pfont|span|[ibu])[^>]*>)?\s*(<(?Pfont|span|[ibu])[^>]*>)?\s*(<(?Pfont|span|[ibu])[^>]*>)?\s*(?P([*#•]+\s*)+)\s*()?\s*()?\s*()?\s*', '

' + '\g' + '

', html) + html = re.sub(u'<(?Pp|div)[^>]*>\s*(<(?Pfont|span|[ibu])[^>]*>)?\s*(<(?Pfont|span|[ibu])[^>]*>)?\s*(<(?Pfont|span|[ibu])[^>]*>)?\s*(?P([*#•=✦]+\s*)+)\s*()?\s*()?\s*()?\s*', '

' + '\g' + '

', html) return html diff --git a/src/calibre/ebooks/mobi/writer.py b/src/calibre/ebooks/mobi/writer.py index cd6674c2e2..ed102ecc80 100644 --- a/src/calibre/ebooks/mobi/writer.py +++ b/src/calibre/ebooks/mobi/writer.py @@ -251,7 +251,7 @@ class Serializer(object): tag = prefixname(elem.tag, nsrmap) # Previous layers take care of @name id = elem.attrib.pop('id', None) - if id is not None: + if id: href = '#'.join((item.href, id)) offset = self.anchor_offset or buffer.tell() self.id_offsets[urlnormalize(href)] = offset diff --git a/src/calibre/ebooks/txt/input.py b/src/calibre/ebooks/txt/input.py index 0b0bd6d570..cca9a74250 100644 --- a/src/calibre/ebooks/txt/input.py +++ b/src/calibre/ebooks/txt/input.py @@ -34,7 +34,7 @@ class TXTInput(InputFormatPlugin): 'starts a paragraph.' '* unformatted: Most lines have hard line breaks, few/no blank lines or indents.')), OptionRecommendation(name='formatting_type', recommended_value='auto', - choices=['auto', 'none', 'heuristic', 'markdown'], + choices=['auto', 'none', 'heuristic', 'textile', 'markdown'], help=_('Formatting used within the document.' '* auto: Automatically decide which formatting processor to use.\n' '* none: Do not process the document formatting. Everything is a ' diff --git a/src/calibre/gui2/actions/add.py b/src/calibre/gui2/actions/add.py index 9917c542ae..6fa53d6290 100644 --- a/src/calibre/gui2/actions/add.py +++ b/src/calibre/gui2/actions/add.py @@ -91,13 +91,14 @@ class AddAction(InterfaceAction): self.gui.library_view.model().db.import_book(MetaInformation(None), []) self.gui.library_view.model().books_added(num) - def add_isbns(self, books): + def add_isbns(self, books, add_tags=[]): from calibre.ebooks.metadata import MetaInformation ids = set([]) + db = self.gui.library_view.model().db + for x in books: mi = MetaInformation(None) mi.isbn = x['isbn'] - db = self.gui.library_view.model().db if x['path'] is not None: ids.add(db.import_book(mi, [x['path']])) else: @@ -109,6 +110,8 @@ class AddAction(InterfaceAction): self.gui.iactions['Edit Metadata'].do_download_metadata(ids) finally: config['overwrite_author_title_metadata'] = orig + if add_tags and ids: + db.bulk_modify_tags(ids, add=add_tags) def files_dropped(self, paths): @@ -166,7 +169,7 @@ class AddAction(InterfaceAction): from calibre.gui2.dialogs.add_from_isbn import AddFromISBN d = AddFromISBN(self.gui) if d.exec_() == d.Accepted: - self.add_isbns(d.books) + self.add_isbns(d.books, add_tags=d.set_tags) def add_books(self, *args): ''' diff --git a/src/calibre/gui2/actions/catalog.py b/src/calibre/gui2/actions/catalog.py index 6d3bb539a2..9903801c6e 100644 --- a/src/calibre/gui2/actions/catalog.py +++ b/src/calibre/gui2/actions/catalog.py @@ -5,11 +5,11 @@ __license__ = 'GPL v3' __copyright__ = '2010, Kovid Goyal ' __docformat__ = 'restructuredtext en' -import os, shutil +import re, os, shutil from PyQt4.Qt import QModelIndex -from calibre.gui2 import error_dialog, choose_dir +from calibre.gui2 import choose_dir, error_dialog, warning_dialog from calibre.gui2.tools import generate_catalog from calibre.utils.config import dynamic from calibre.gui2.actions import InterfaceAction @@ -55,10 +55,18 @@ class GenerateCatalogAction(InterfaceAction): def catalog_generated(self, job): if job.result: - # Error during catalog generation - return error_dialog(self.gui, _('Catalog generation terminated'), - job.result, - show=True) + # Problems during catalog generation + # jobs.results is a list - the first entry is the intended title for the dialog + # Subsequent strings are error messages + dialog_title = job.result.pop(0) + if re.match('warning:', job.result[0].lower()): + job.result.append("Catalog generation complete.") + warning_dialog(self.gui, dialog_title, '\n'.join(job.result), show=True) + else: + job.result.append("Catalog generation terminated.") + error_dialog(self.gui, dialog_title,'\n'.join(job.result),show=True) + return + if job.failed: return self.gui.job_exception(job) id = self.gui.library_view.model().add_catalog(job.catalog_file_path, job.catalog_title) diff --git a/src/calibre/gui2/comments_editor.py b/src/calibre/gui2/comments_editor.py index 013d13f9e7..04bc5284ed 100644 --- a/src/calibre/gui2/comments_editor.py +++ b/src/calibre/gui2/comments_editor.py @@ -593,6 +593,11 @@ class Editor(QWidget): # {{{ def code_dirtied(self, *args): self.source_dirty = True + def hide_toolbars(self): + self.toolbar1.setVisible(False) + self.toolbar2.setVisible(False) + self.toolbar3.setVisible(False) + # }}} if __name__ == '__main__': diff --git a/src/calibre/gui2/convert/metadata.py b/src/calibre/gui2/convert/metadata.py index 5f39202e26..23cac74cf8 100644 --- a/src/calibre/gui2/convert/metadata.py +++ b/src/calibre/gui2/convert/metadata.py @@ -18,6 +18,7 @@ from calibre.ebooks.metadata.opf2 import metadata_to_opf from calibre.ptempfile import PersistentTemporaryFile from calibre.gui2.convert import Widget from calibre.utils.icu import sort_key +from calibre.library.comments import comments_to_html def create_opf_file(db, book_id): mi = db.get_metadata(book_id, index_is_id=True) @@ -57,6 +58,7 @@ class MetadataWidget(Widget, Ui_Form): self.initialize_metadata_options() self.initialize_options(get_option, get_help, db, book_id) self.connect(self.cover_button, SIGNAL("clicked()"), self.select_cover) + self.comment.hide_toolbars() def deduce_author_sort(self, *args): au = unicode(self.author.currentText()) @@ -79,7 +81,7 @@ class MetadataWidget(Widget, Ui_Form): self.author_sort.setText(mi.author_sort if mi.author_sort else '') self.tags.setText(', '.join(mi.tags if mi.tags else [])) self.tags.update_items_cache(self.db.all_tags()) - self.comment.setPlainText(mi.comments if mi.comments else '') + self.comment.html = comments_to_html(mi.comments) if mi.comments else '' if mi.series: self.series.setCurrentIndex(self.series.findText(mi.series)) if mi.series_index is not None: @@ -154,7 +156,7 @@ class MetadataWidget(Widget, Ui_Form): author_sort = unicode(self.author_sort.text()).strip() if author_sort: mi.author_sort = author_sort - comments = unicode(self.comment.toPlainText()).strip() + comments = self.comment.html if comments: mi.comments = comments mi.series_index = float(self.series_index.value()) diff --git a/src/calibre/gui2/convert/metadata.ui b/src/calibre/gui2/convert/metadata.ui index 8db4cfa2a1..61c27594c4 100644 --- a/src/calibre/gui2/convert/metadata.ui +++ b/src/calibre/gui2/convert/metadata.ui @@ -20,30 +20,6 @@ Book Cover - - - - - - - 0 - 0 - - - - - - - - - - Use cover from &source file - - - true - - - @@ -95,6 +71,30 @@ + + + + Use cover from &source file + + + true + + + + + + + + + + 0 + 0 + + + + + + opt_prefer_metadata_cover @@ -264,35 +264,7 @@ - - - - 0 - 0 - - - - - 16777215 - 200 - - - - Comments - - - - - - - 16777215 - 180 - - - - - - + @@ -325,6 +297,12 @@
calibre/gui2/widgets.h
1 + + Editor + QWidget +
calibre/gui2/comments_editor.h
+ 1 +
title @@ -334,7 +312,6 @@ tags series series_index - comment cover_path cover_button opt_prefer_metadata_cover diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py index 944ce03305..734d8cd56c 100644 --- a/src/calibre/gui2/device.py +++ b/src/calibre/gui2/device.py @@ -1018,7 +1018,8 @@ class DeviceMixin(object): # {{{ ids = [self.library_view.model().id(r) \ for r in self.library_view.selectionModel().selectedRows()] \ if send_ids is None else send_ids - if not self.device_manager or not ids or len(ids) == 0: + if not self.device_manager or not ids or len(ids) == 0 or \ + not self.device_manager.is_device_connected: return settings = self.device_manager.device.settings() diff --git a/src/calibre/gui2/dialogs/add_from_isbn.py b/src/calibre/gui2/dialogs/add_from_isbn.py index f93cddecd5..433b70291c 100644 --- a/src/calibre/gui2/dialogs/add_from_isbn.py +++ b/src/calibre/gui2/dialogs/add_from_isbn.py @@ -12,6 +12,7 @@ from PyQt4.Qt import QDialog, QApplication from calibre.gui2.dialogs.add_from_isbn_ui import Ui_Dialog from calibre.ebooks.metadata import check_isbn from calibre.constants import iswindows +from calibre.gui2 import gprefs class AddFromISBN(QDialog, Ui_Dialog): @@ -25,7 +26,9 @@ class AddFromISBN(QDialog, Ui_Dialog): self.isbns = [] self.books = [] + self.set_tags = [] self.paste_button.clicked.connect(self.paste) + self.add_tags.setText(', '.join(gprefs.get('add from ISBN tags', []))) def paste(self, *args): app = QApplication.instance() @@ -37,6 +40,10 @@ class AddFromISBN(QDialog, Ui_Dialog): self.isbn_box.setPlainText(new) def accept(self, *args): + tags = unicode(self.add_tags.text()).strip().split(',') + tags = list(filter(None, [x.strip() for x in tags])) + gprefs['add from ISBN tags'] = tags + self.set_tags = tags for line in unicode(self.isbn_box.toPlainText()).strip().splitlines(): line = line.strip() if not line: diff --git a/src/calibre/gui2/dialogs/add_from_isbn.ui b/src/calibre/gui2/dialogs/add_from_isbn.ui index e37c4ed769..f598e6f1d8 100644 --- a/src/calibre/gui2/dialogs/add_from_isbn.ui +++ b/src/calibre/gui2/dialogs/add_from_isbn.ui @@ -18,8 +18,19 @@ :/images/add_book.png:/images/add_book.png - - + + + + + + + + + &Paste from clipboard + + + + @@ -34,6 +45,36 @@ + + + + + + &Tags to set on created book entries: + + + add_tags + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + @@ -44,13 +85,6 @@ - - - - &Paste from clipboard - - - diff --git a/src/calibre/gui2/dialogs/metadata_bulk.py b/src/calibre/gui2/dialogs/metadata_bulk.py index 2b3a319663..6e6b553dba 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.py +++ b/src/calibre/gui2/dialogs/metadata_bulk.py @@ -49,7 +49,6 @@ def get_cover_data(path): # {{{ return cdata, area # }}} - class MyBlockingBusy(QDialog): # {{{ do_one_signal = pyqtSignal() @@ -134,7 +133,7 @@ class MyBlockingBusy(QDialog): # {{{ do_autonumber, do_remove_format, remove_format, do_swap_ta, \ do_remove_conv, do_auto_author, series, do_series_restart, \ series_start_value, do_title_case, cover_action, clear_series, \ - pubdate = self.args + pubdate, adddate = self.args # first loop: do author and title. These will commit at the end of each @@ -214,6 +213,9 @@ class MyBlockingBusy(QDialog): # {{{ if pubdate is not None: self.db.set_pubdate(id, pubdate, notify=False, commit=False) + if adddate is not None: + self.db.set_timestamp(id, adddate, notify=False, commit=False) + if do_series: if do_series_restart: if self.series_start_value is None: @@ -300,6 +302,10 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog): self.pubdate.setSpecialValueText(_('Undefined')) self.clear_pubdate_button.clicked.connect(self.clear_pubdate) self.pubdate.dateChanged.connect(self.do_apply_pubdate) + self.adddate.setMinimumDate(UNDEFINED_QDATE) + self.adddate.setSpecialValueText(_('Undefined')) + self.clear_adddate_button.clicked.connect(self.clear_adddate) + self.adddate.dateChanged.connect(self.do_apply_adddate) if len(self.db.custom_field_keys(include_composites=False)) == 0: self.central_widget.removeTab(1) @@ -322,6 +328,12 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog): def clear_pubdate(self, *args): self.pubdate.setDate(UNDEFINED_QDATE) + def do_apply_adddate(self, *args): + self.apply_adddate.setChecked(True) + + def clear_adddate(self, *args): + self.adddate.setDate(UNDEFINED_QDATE) + def button_clicked(self, which): if which == self.button_box.button(QDialogButtonBox.Apply): self.do_again = True @@ -726,7 +738,7 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog): name = name.strip().replace('|', ',') self.authors.addItem(name) self.authors.setEditText('') - + self.authors.set_separator('&') self.authors.set_space_before_sep(True) self.authors.update_items_cache(self.db.all_author_names()) @@ -805,9 +817,11 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog): do_remove_conv = self.remove_conversion_settings.isChecked() do_auto_author = self.auto_author_sort.isChecked() do_title_case = self.change_title_to_title_case.isChecked() - pubdate = None + pubdate = adddate = None if self.apply_pubdate.isChecked(): pubdate = qt_to_dt(self.pubdate.date()) + if self.apply_adddate.isChecked(): + adddate = qt_to_dt(self.adddate.date()) cover_action = None if self.cover_remove.isChecked(): @@ -821,7 +835,7 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog): do_autonumber, do_remove_format, remove_format, do_swap_ta, do_remove_conv, do_auto_author, series, do_series_restart, series_start_value, do_title_case, cover_action, clear_series, - pubdate) + pubdate, adddate) bb = MyBlockingBusy(_('Applying changes to %d books.\nPhase {0} {1}%%.') %len(self.ids), args, self.db, self.ids, diff --git a/src/calibre/gui2/dialogs/metadata_bulk.ui b/src/calibre/gui2/dialogs/metadata_bulk.ui index 8db74b343d..f8ae926be6 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.ui +++ b/src/calibre/gui2/dialogs/metadata_bulk.ui @@ -347,6 +347,51 @@ from the value in the box + + + + &Date: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + adddate + + + + + + + + + d MMM yyyy + + + true + + + + + + + ... + + + + :/images/trash.png:/images/trash.png + + + + + + + + + &Apply date + + + @@ -395,6 +440,42 @@ from the value in the box + + + + Remove &format: + + + remove_format + + + + + + + + 120 + 16777215 + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 15 + + + + @@ -478,42 +559,6 @@ Future conversion of these books will use the default settings. - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 15 - - - - - - - - Remove &format: - - - remove_format - - - - - - - - 120 - 16777215 - - - - diff --git a/src/calibre/gui2/library/delegates.py b/src/calibre/gui2/library/delegates.py index ea614aa817..e9b9255c64 100644 --- a/src/calibre/gui2/library/delegates.py +++ b/src/calibre/gui2/library/delegates.py @@ -353,6 +353,17 @@ class CcCommentsDelegate(QStyledItemDelegate): # {{{ model.setData(index, QVariant(editor.textbox.html), Qt.EditRole) # }}} +class DelegateCB(QComboBox): # {{{ + + def __init__(self, parent): + QComboBox.__init__(self, parent) + + def event(self, e): + if e.type() == e.ShortcutOverride: + e.accept() + return QComboBox.event(self, e) +# }}} + class CcBoolDelegate(QStyledItemDelegate): # {{{ def __init__(self, parent): ''' @@ -361,7 +372,7 @@ class CcBoolDelegate(QStyledItemDelegate): # {{{ QStyledItemDelegate.__init__(self, parent) def createEditor(self, parent, option, index): - editor = QComboBox(parent) + editor = DelegateCB(parent) items = [_('Y'), _('N'), ' '] icons = [I('ok.png'), I('list_remove.png'), I('blank.png')] if tweaks['bool_custom_columns_are_tristate'] == 'no': diff --git a/src/calibre/gui2/preferences/plugins.py b/src/calibre/gui2/preferences/plugins.py index c53c634ab4..b00a485566 100644 --- a/src/calibre/gui2/preferences/plugins.py +++ b/src/calibre/gui2/preferences/plugins.py @@ -196,6 +196,12 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): def modify_plugin(self, op=''): index = self.plugin_view.currentIndex() if index.isValid(): + if not index.parent().isValid(): + name = unicode(index.data().toString()) + return error_dialog(self, _('Error'), '

'+ + _('Select an actual plugin under %s to customize')%name, + show=True, show_copy_button=False) + plugin = self._plugin_model.index_to_plugin(index) if op == 'toggle': if not plugin.can_be_disabled: diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index 9eb202d761..6c6e41e0a5 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -485,7 +485,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ if 'calibre.ebooks.DRMError' in job.details: if not minz: from calibre.gui2.dialogs.drm_error import DRMErrorMessage - d = DRMErrorMessage(self, job.description.split(':')[-1]) + d = DRMErrorMessage(self, _('Cannot convert') + ' ' + + job.description.split(':')[-1].partition('(')[-1][:-1]) d.setModal(False) d.show() self._modeless_dialogs.append(d) diff --git a/src/calibre/gui2/wizard/__init__.py b/src/calibre/gui2/wizard/__init__.py index 4e5e79bbdf..8144dcabf3 100644 --- a/src/calibre/gui2/wizard/__init__.py +++ b/src/calibre/gui2/wizard/__init__.py @@ -111,7 +111,7 @@ class Kobo(Device): id = 'kobo' class Booq(Device): - name = 'Booq Reader' + name = 'bq Classic' manufacturer = 'Booq' output_profile = 'sony' output_format = 'EPUB' @@ -125,7 +125,18 @@ class TheBook(Device): id = 'thebook' class Avant(Booq): - name = 'Booq Avant' + name = 'bq Avant' + +class AvantXL(Booq): + name = 'bq Avant XL' + output_profile = 'ipad' + +class BooqPocketPlus(Booq): + name = 'bq Pocket Plus' + output_profile = 'sony300' + +class BooqCervantes(Booq): + name = 'bq Cervantes' class Sony300(Sony505): diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index 087d40c4eb..ea02c29fa7 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -19,6 +19,7 @@ from calibre.ebooks.oeb.base import XHTML_NS from calibre.ptempfile import PersistentTemporaryDirectory from calibre.utils.config import config_dir from calibre.utils.date import format_date, isoformat, now as nowf +from calibre.utils.icu import capitalize from calibre.utils.logging import default_log as log from calibre.utils.zipfile import ZipFile, ZipInfo from calibre.utils.magick.draw import thumbnail @@ -546,9 +547,9 @@ class EPUB_MOBI(CatalogPlugin): name = 'Catalog_EPUB_MOBI' description = 'EPUB/MOBI catalog generator' supported_platforms = ['windows', 'osx', 'linux'] - minimum_calibre_version = (0, 6, 34) + minimum_calibre_version = (0, 7, 40) author = 'Greg Riker' - version = (0, 0, 1) + version = (1, 0, 0) file_types = set(['epub','mobi']) THUMB_SMALLEST = "1.0" @@ -900,15 +901,7 @@ class EPUB_MOBI(CatalogPlugin): ''' Generates catalog source files from calibre database - Implementation notes - - 'Marker tags' in a book's metadata are used to flag special conditions: - (Defaults) - '~' : Do not catalog this book - '+' : Mark this book as read (check mark) in lists - '*' : Display trailing text as 'Note: ' in top frame next to cover - '[] : Source of content (e.g., Amazon, Project Gutenberg). Do not create genre - - - Program flow + Flow of control: gui2.actions.catalog:generate_catalog() gui2.tools:generate_catalog() or library.cli:command_catalog() called from gui2.convert.gui_conversion:gui_catalog() @@ -953,7 +946,7 @@ class EPUB_MOBI(CatalogPlugin): self.__creator = opts.creator self.__db = db self.__descriptionClip = opts.descriptionClip - self.__error = None + self.__error = [] self.__generateForKindle = True if (self.opts.fmt == 'mobi' and \ self.opts.output_profile and \ self.opts.output_profile.startswith("kindle")) else False @@ -1033,6 +1026,17 @@ class EPUB_MOBI(CatalogPlugin): # +1 thumbs self.__totalSteps += 3 + # Load section list templates + templates = [] + with open(P('catalog/section_list_templates.py'), 'r') as f: + for line in f: + t = re.match("(by_.+_template)",line) + if t: + templates.append(t.group(1)) + execfile(P('catalog/section_list_templates.py'), locals()) + for t in templates: + setattr(self,t,eval(t)) + # Accessors if True: ''' @@ -1352,6 +1356,7 @@ class EPUB_MOBI(CatalogPlugin): return False self.fetchBookmarks() if self.opts.generate_descriptions: + self.generateThumbnails() self.generateHTMLDescriptions() self.generateHTMLByAuthor() if self.opts.generate_titles: @@ -1364,8 +1369,7 @@ class EPUB_MOBI(CatalogPlugin): self.generateHTMLByDateAdded() if self.generateRecentlyRead: self.generateHTMLByDateRead() - if self.opts.generate_descriptions: - self.generateThumbnails() + self.generateOPF() self.generateNCXHeader() self.generateNCXByAuthor("Authors") @@ -1420,29 +1424,36 @@ class EPUB_MOBI(CatalogPlugin): ''' self.updateProgressFullStep("Sorting database") - - ''' - # Sort titles case-insensitive, by author - self.booksByAuthor = sorted(self.booksByTitle, - key=lambda x:(x['author_sort'].upper(), x['author_sort'].upper())) - ''' - self.booksByAuthor = list(self.booksByTitle) - self.booksByAuthor.sort(self.author_compare) - if False and self.verbose: - self.opts.log.info("fetchBooksByAuthor(): %d books" % len(self.booksByAuthor)) - self.opts.log.info(" %-30s %-20s %s" % ('title', 'series', 'series_index')) - for title in self.booksByAuthor: - self.opts.log.info((u" %-30s %-20s%5s " % \ - (title['title'][:30], - title['series'][:20] if title['series'] else '', - title['series_index'], - )).encode('utf-8')) - raise SystemExit + # Test for author_sort mismatches + self.booksByAuthor = sorted(self.booksByAuthor, key=self.booksByAuthorSorter_author) + # Build the unique_authors set from existing data + authors = [(record['author'], record['author_sort']) for record in self.booksByAuthor] + current_author = authors[0] + for (i,author) in enumerate(authors): + if author != current_author and i: + # Exit if author matches previous, but author_sort doesn't match + if author[0] == current_author[0]: + error_msg = _(''' +Inconsistent Author Sort values for Author '{0}': +'{1}' <> '{2}', +unable to build catalog.\n +Select all books by '{0}', apply correct Author Sort value in Edit Metadata dialog, +then rebuild the catalog.\n''').format(author[0],author[1],current_author[1]) + self.opts.log.warn('\n*** Metadata error ***') + self.opts.log.warn(error_msg) + + self.error.append('Metadata error') + self.error.append(error_msg) + return False + current_author = author + + + self.booksByAuthor = sorted(self.booksByAuthor, key=self.booksByAuthorSorter_author_sort) # Build the unique_authors set from existing data - authors = [(record['author'], record['author_sort'].capitalize()) for record in self.booksByAuthor] + authors = [(record['author'], capitalize(record['author_sort'])) for record in self.booksByAuthor] # authors[] contains a list of all book authors, with multiple entries for multiple books by author # authors[]: (([0]:friendly [1]:sort)) @@ -1456,19 +1467,6 @@ class EPUB_MOBI(CatalogPlugin): # Note that current_author and author are tuples: (friendly, sort) multiple_authors = True - if author != current_author and i: - # Warn, exit if friendly matches previous, but sort doesn't - if author[0] == current_author[0]: - error_msg = _(''' -\n*** Metadata error *** -Inconsistent Author Sort values for Author '{0}', unable to continue building catalog. -Select all books by '{0}', apply correct Author Sort value in Edit Metadata dialog, -then rebuild the catalog.\n''').format(author[0]) - - self.opts.log.warn(error_msg) - self.error = error_msg - return False - # New author, save the previous author/sort/count unique_authors.append((current_author[0], icu_title(current_author[1]), books_by_current_author)) @@ -1496,16 +1494,8 @@ then rebuild the catalog.\n''').format(author[0]) return True def fetchBooksByTitle(self): - self.updateProgressFullStep("Fetching database") - # Get the database as a dictionary - # Sort by title - # Search is a string like this: - # not tag: author:"Riker" - # So we need to merge opts.exclude_tag with opts.search_text - # not tag:"~" author:"Riker" - self.opts.sort_by = 'title' # Merge opts.exclude_tags with opts.search_text @@ -1528,7 +1518,6 @@ then rebuild the catalog.\n''').format(author[0]) else: self.opts.search_text = search_phrase - #print "fetchBooksByTitle(): opts.search_text: %s" % self.opts.search_text # Fetch the database as a dictionary data = self.plugin.search_sort_db(self.db, self.opts) data = self.processExclusions(data) @@ -1536,8 +1525,6 @@ then rebuild the catalog.\n''').format(author[0]) # Populate this_title{} from data[{},{}] titles = [] for record in data: - if False: - print "available record metadata:\n%s" % sorted(record.keys()) this_title = {} this_title['id'] = record['id'] @@ -1547,7 +1534,6 @@ then rebuild the catalog.\n''').format(author[0]) if record['series']: this_title['series'] = record['series'] this_title['series_index'] = record['series_index'] - this_title['title'] = self.generateSeriesTitle(this_title) else: this_title['series'] = None this_title['series_index'] = 0.0 @@ -1572,7 +1558,12 @@ then rebuild the catalog.\n''').format(author[0]) this_title['publisher'] = re.sub('&', '&', record['publisher']) this_title['rating'] = record['rating'] if record['rating'] else 0 - this_title['date'] = strftime(u'%B %Y', record['pubdate'].timetuple()) + + if re.match('0101-01-01',str(record['pubdate'].date())): + this_title['date'] = None + else: + this_title['date'] = strftime(u'%B %Y', record['pubdate'].timetuple()) + this_title['timestamp'] = record['timestamp'] if record['comments']: @@ -1646,7 +1637,10 @@ then rebuild the catalog.\n''').format(author[0]) title['title_sort'][0:40])).decode('mac-roman')) return True else: - self.error = _("No books found to catalog.\nCheck 'Excluded books' criteria in E-book options.") + error_msg = _("No books found to catalog.\nCheck 'Excluded books' criteria in E-book options.\n") + self.opts.log.error('*** ' + error_msg + ' ***') + self.error.append(_('No books available to include in catalog')) + self.error.append(error_msg) return False def fetchBookmarks(self): @@ -1748,13 +1742,12 @@ then rebuild the catalog.\n''').format(author[0]) self.bookmarked_books = {} def generateHTMLDescriptions(self): - # Write each title to a separate HTML file in contentdir + ''' + Write each title to a separate HTML file in contentdir + ''' self.updateProgressFullStep("'Descriptions'") for (title_num, title) in enumerate(self.booksByTitle): - if False: - self.opts.log.info("%3s: %s - %s" % (title['id'], title['title'], title['author'])) - self.updateProgressMicroStep("Description %d of %d" % \ (title_num, len(self.booksByTitle)), float(title_num*100/len(self.booksByTitle))/100) @@ -1768,8 +1761,9 @@ then rebuild the catalog.\n''').format(author[0]) outfile.close() def generateHTMLByTitle(self): - # Write books by title A-Z to HTML file - + ''' + Write books by title A-Z to HTML file + ''' self.updateProgressFullStep("'Titles'") soup = self.generateHTMLEmptyHeader("Books By Alpha Title") @@ -1807,22 +1801,11 @@ then rebuild the catalog.\n''').format(author[0]) current_letter = "" # Re-sort title list without leading series/series_index + # Incoming title : if not self.useSeriesPrefixInTitlesSection: nspt = deepcopy(self.booksByTitle) - for book in nspt: - if book['series']: - tokens = book['title'].partition(':') - book['title'] = '%s (%s)' % (tokens[2].strip(), tokens[0]) - book['title_sort'] = self.generateSortTitle(book['title']) - nspt = sorted(nspt, - key=lambda x:(x['title_sort'].upper(), x['title_sort'].upper())) + nspt = sorted(nspt, key=lambda x:(x['title_sort'].upper(), x['title_sort'].upper())) self.booksByTitle_noSeriesPrefix = nspt - if False and self.verbose: - self.opts.log.info("no_series_prefix_titles: %d books" % len(nspt)) - self.opts.log.info(" %-40s %-40s" % ('title', 'title_sort')) - for title in nspt: - self.opts.log.info((u" %-40s %-40s" % (title['title'][0:40], - title['title_sort'][0:40])).encode('utf-8')) # Loop through the books by title title_list = self.booksByTitle @@ -1878,7 +1861,14 @@ then rebuild the catalog.\n''').format(author[0]) aTag = Tag(soup, "a") if self.opts.generate_descriptions: aTag['href'] = "book_%d.html" % (int(float(book['id']))) - aTag.insert(0,escape(book['title'])) + + # Generate the title from the template + args = self.generateFormatArgs(book) + if book['series']: + formatted_title = self.by_titles_series_title_template.format(**args).rstrip() + else: + formatted_title = self.by_titles_normal_title_template.format(**args).rstrip() + aTag.insert(0,NavigableString(escape(formatted_title))) pBookTag.insert(ptc, aTag) ptc += 1 @@ -1916,7 +1906,9 @@ then rebuild the catalog.\n''').format(author[0]) self.htmlFileList_1.append("content/ByAlphaTitle.html") def generateHTMLByAuthor(self): - # Write books by author A-Z + ''' + Write books by author A-Z + ''' self.updateProgressFullStep("'Authors'") friendly_name = "Authors" @@ -1953,7 +1945,9 @@ then rebuild the catalog.\n''').format(author[0]) current_author = '' current_letter = '' current_series = None + #for book in sorted(self.booksByAuthor, key = self.booksByAuthorSorter_author_sort): for book in self.booksByAuthor: + book_count += 1 if self.letter_or_symbol(book['author_sort'][0].upper()) != current_letter : # Start a new letter with Index letter @@ -2067,14 +2061,18 @@ then rebuild the catalog.\n''').format(author[0]) aTag = Tag(soup, "a") if self.opts.generate_descriptions: aTag['href'] = "book_%d.html" % (int(float(book['id']))) - # Use series, series index if avail else title, + year of publication + + # Generate the title from the template + args = self.generateFormatArgs(book) if current_series: - aTag.insert(0,'%s (%s)' % (escape(book['title'][len(book['series'])+1:]), - book['date'].split()[1])) + #aTag.insert(0,'%s%s' % (escape(book['title'][len(book['series'])+1:]),pubyear)) + formatted_title = self.by_authors_series_title_template.format(**args).rstrip() else: - aTag.insert(0,'%s (%s)' % (escape(book['title']), - book['date'].split()[1])) + #aTag.insert(0,'%s%s' % (escape(book['title']), pubyear)) + formatted_title = self.by_authors_normal_title_template.format(**args).rstrip() non_series_books += 1 + aTag.insert(0,NavigableString(escape(formatted_title))) + pBookTag.insert(ptc, aTag) ptc += 1 @@ -2111,7 +2109,6 @@ then rebuild the catalog.\n''').format(author[0]) # Add the divTag to the body body.insert(btc, divTag) - # Write the generated file to contentdir outfile_spec = "%s/ByAlphaAuthor.html" % (self.contentDir) outfile = open(outfile_spec, 'w') @@ -2120,13 +2117,15 @@ then rebuild the catalog.\n''').format(author[0]) self.htmlFileList_1.append("content/ByAlphaAuthor.html") def generateHTMLByDateAdded(self): - # Write books by reverse chronological order + ''' + Write books by reverse chronological order + ''' self.updateProgressFullStep("'Recently Added'") def add_books_to_HTML_by_month(this_months_list, dtc): if len(this_months_list): - this_months_list.sort(self.author_compare) + #this_months_list = sorted(this_months_list, key=self.booksByAuthorSorter_author_sort) # Create a new month anchor date_string = strftime(u'%B %Y', current_date.timetuple()) @@ -2156,16 +2155,6 @@ then rebuild the catalog.\n''').format(author[0]) divTag.insert(dtc,pAuthorTag) dtc += 1 - ''' - # Insert an <hr /> between non-series and series - if not current_series and non_series_books and new_entry['series']: - # Insert an <hr /> - hrTag = Tag(soup,'hr') - hrTag['class'] = "series_divider" - divTag.insert(dtc,hrTag) - dtc += 1 - ''' - # Check for series if new_entry['series'] and new_entry['series'] != current_series: # Start a new series @@ -2213,11 +2202,15 @@ then rebuild the catalog.\n''').format(author[0]) aTag = Tag(soup, "a") if self.opts.generate_descriptions: aTag['href'] = "book_%d.html" % (int(float(new_entry['id']))) + + # Generate the title from the template + args = self.generateFormatArgs(new_entry) if current_series: - aTag.insert(0,escape(new_entry['title'][len(new_entry['series'])+1:])) + formatted_title = self.by_month_added_series_title_template.format(**args).rstrip() else: - aTag.insert(0,escape(new_entry['title'])) + formatted_title = self.by_month_added_normal_title_template.format(**args).rstrip() non_series_books += 1 + aTag.insert(0,NavigableString(escape(formatted_title))) pBookTag.insert(ptc, aTag) ptc += 1 @@ -2265,7 +2258,14 @@ then rebuild the catalog.\n''').format(author[0]) aTag = Tag(soup, "a") if self.opts.generate_descriptions: aTag['href'] = "book_%d.html" % (int(float(new_entry['id']))) - aTag.insert(0,escape(new_entry['title'])) + + # Generate the title from the template + args = self.generateFormatArgs(new_entry) + if new_entry['series']: + formatted_title = self.by_recently_added_series_title_template.format(**args).rstrip() + else: + formatted_title = self.by_recently_added_normal_title_template.format(**args).rstrip() + aTag.insert(0,NavigableString(escape(formatted_title))) pBookTag.insert(ptc, aTag) ptc += 1 @@ -2323,17 +2323,12 @@ then rebuild the catalog.\n''').format(author[0]) divTag = Tag(soup, "div") dtc = 0 - # Add books by date range + # >>> Books by date range <<< if self.useSeriesPrefixInTitlesSection: self.booksByDateRange = sorted(self.booksByTitle, key=lambda x:(x['timestamp'], x['timestamp']),reverse=True) else: nspt = deepcopy(self.booksByTitle) - for book in nspt: - if book['series']: - tokens = book['title'].partition(':') - book['title'] = '%s (%s)' % (tokens[2].strip(), tokens[0]) - book['title_sort'] = self.generateSortTitle(book['title']) self.booksByDateRange = sorted(nspt, key=lambda x:(x['timestamp'], x['timestamp']),reverse=True) date_range_list = [] @@ -2356,15 +2351,6 @@ then rebuild the catalog.\n''').format(author[0]) dtc = add_books_to_HTML_by_date_range(date_range_list, date_range, dtc) date_range_list = [book] - ''' - if books_added_in_date_range: - # Add an <hr> separating date ranges from months - hrTag = Tag(soup,'hr') - hrTag['class'] = "description_divider" - divTag.insert(dtc,hrTag) - dtc += 1 - ''' - # >>>> Books by month <<<< # Sort titles case-insensitive for by month using series prefix self.booksByMonth = sorted(self.booksByTitle, @@ -2395,7 +2381,9 @@ then rebuild the catalog.\n''').format(author[0]) self.htmlFileList_2.append("content/ByDateAdded.html") def generateHTMLByDateRead(self): - # Write books by active bookmarks + ''' + Write books by active bookmarks + ''' friendly_name = 'Recently Read' self.updateProgressFullStep("'%s'" % friendly_name) if not self.bookmarked_books: @@ -2533,32 +2521,6 @@ then rebuild the catalog.\n''').format(author[0]) self.booksByDateRead = sorted(bookmarked_books, key=lambda x:(x['bookmark_timestamp'], x['bookmark_timestamp']),reverse=True) - ''' - # >>>> Recently by date range <<<< - date_range_list = [] - today_time = datetime.datetime.utcnow() - today_time.replace(hour=23, minute=59, second=59) - books_added_in_date_range = False - for (i, date) in enumerate(self.DATE_RANGE): - date_range_limit = self.DATE_RANGE[i] - if i: - date_range = '%d to %d days ago' % (self.DATE_RANGE[i-1], self.DATE_RANGE[i]) - else: - date_range = 'Last %d days' % (self.DATE_RANGE[i]) - - for book in self.booksByDateRead: - bookmark_time = datetime.datetime.utcfromtimestamp(book['bookmark_timestamp']) - delta = today_time-bookmark_time - if delta.days <= date_range_limit: - date_range_list.append(book) - books_added_in_date_range = True - else: - break - - dtc = add_books_to_HTML_by_date_range(date_range_list, date_range, dtc) - date_range_list = [book] - ''' - # >>>> Recently read by day <<<< current_date = datetime.date.fromordinal(1) todays_list = [] @@ -2713,10 +2675,15 @@ then rebuild the catalog.\n''').format(author[0]) # Use series, series index if avail else just title #aTag.insert(0,'%d. %s · %s' % (book['series_index'],escape(book['title']), ' & '.join(book['authors']))) - # Link to book - aTag.insert(0,'%d. %s (%s)' % (book['series_index'], - escape(book['title']), - strftime(u'%Y', book['pubdate'].timetuple()))) + # Reassert 'date' since this is the result of a new search + if re.match('0101-01-01',str(book['pubdate'].date())): + book['date'] = None + else: + book['date'] = strftime(u'%B %Y', book['pubdate'].timetuple()) + + args = self.generateFormatArgs(book) + formatted_title = self.by_series_title_template.format(**args).rstrip() + aTag.insert(0,NavigableString(escape(formatted_title))) pBookTag.insert(ptc, aTag) ptc += 1 @@ -2760,10 +2727,11 @@ then rebuild the catalog.\n''').format(author[0]) self.htmlFileList_1.append("content/BySeries.html") def generateHTMLByTags(self): - # Generate individual HTML files for each tag, e.g. Fiction, Nonfiction ... - # Note that special tags - ~+*[] - have already been filtered from books[] - # There may be synonomous tags - + ''' + Generate individual HTML files for each tag, e.g. Fiction, Nonfiction ... + Note that special tags - have already been filtered from books[] + There may be synonomous tags + ''' self.updateProgressFullStep("'Genres'") self.genre_tags_dict = self.filterDbTags(self.db.all_tags()) @@ -2782,11 +2750,13 @@ then rebuild the catalog.\n''').format(author[0]) this_book = {} this_book['author'] = book['author'] this_book['title'] = book['title'] - this_book['author_sort'] = book['author_sort'].capitalize() + this_book['author_sort'] = capitalize(book['author_sort']) this_book['read'] = book['read'] this_book['tags'] = book['tags'] this_book['id'] = book['id'] this_book['series'] = book['series'] + this_book['series_index'] = book['series_index'] + this_book['date'] = book['date'] normalized_tag = self.genre_tags_dict[friendly_tag] genre_tag_list = [key for genre in genre_list for key in genre] if normalized_tag in genre_tag_list: @@ -2843,13 +2813,7 @@ then rebuild the catalog.\n''').format(author[0]) unique_authors.append((current_author[0], current_author[1], books_by_current_author)) else: books_by_current_author += 1 - ''' - # Extract the unique entries - unique_authors = [] - for author in authors: - if not author in unique_authors: - unique_authors.append(author) - ''' + # Write the genre book list as an article titles_spanned = self.generateHTMLByGenre(genre, True if index==0 else False, genre_tag_set[genre], @@ -2863,18 +2827,14 @@ then rebuild the catalog.\n''').format(author[0]) 'books':genre_tag_set[genre], 'titles_spanned':titles_spanned}) - if False and self.opts.verbose: - for genre in master_genre_list: - print "genre['tag']: %s" % genre['tag'] - for book in genre['books']: - print book['title'] self.genres = master_genre_list def generateThumbnails(self): - # Generate a thumbnail per cover. If a current thumbnail exists, skip - # If a cover doesn't exist, use default - # Return list of active thumbs - + ''' + Generate a thumbnail per cover. If a current thumbnail exists, skip + If a cover doesn't exist, use default + Return list of active thumbs + ''' self.updateProgressFullStep("'Thumbnails'") thumbs = ['thumbnail_default.jpg'] image_dir = "%s/images" % self.catalogPath @@ -2886,45 +2846,52 @@ then rebuild the catalog.\n''').format(author[0]) thumb_file = 'thumbnail_%d.jpg' % int(title['id']) thumb_generated = True + valid_cover = True try: self.generateThumbnail(title, image_dir, thumb_file) thumbs.append("thumbnail_%d.jpg" % int(title['id'])) except: + if 'cover' in title and os.path.exists(title['cover']): + valid_cover = False + self.opts.log.warn(" *** Invalid cover file for '%s'***" % + (title['title'])) + if not self.error: + self.error.append('Invalid cover files') + self.error.append("Warning: invalid cover file for '%s', default cover substituted.\n" % (title['title'])) + thumb_generated = False - if not thumb_generated: - # Use default cover - if False and self.verbose: - self.opts.log.warn(" using default cover for '%s'" % \ - (title['title'])) - # Check to make sure default is current - # Check to see if thumbnail exists - thumb_fp = "%s/thumbnail_default.jpg" % (image_dir) - cover = "%s/DefaultCover.png" % (self.catalogPath) + self.opts.log.warn(" using default cover for '%s' (%d)" % (title['title'], title['id'])) + # Confirm thumb exists, default is current + default_thumb_fp = os.path.join(image_dir,"thumbnail_default.jpg") + cover = os.path.join(self.catalogPath, "DefaultCover.png") + title['cover'] = cover + if not os.path.exists(cover): shutil.copyfile(I('book.png'), cover) - if os.path.isfile(thumb_fp): + if os.path.isfile(default_thumb_fp): # Check to see if default cover is newer than thumbnail # os.path.getmtime() = modified time # os.path.ctime() = creation time cover_timestamp = os.path.getmtime(cover) - thumb_timestamp = os.path.getmtime(thumb_fp) + thumb_timestamp = os.path.getmtime(default_thumb_fp) if thumb_timestamp < cover_timestamp: if False and self.verbose: self.opts.log.warn("updating thumbnail_default for %s" % title['title']) - #title['cover'] = "%s/DefaultCover.jpg" % self.catalogPath - title['cover'] = cover - self.generateThumbnail(title, image_dir, "thumbnail_default.jpg") + self.generateThumbnail(title, image_dir, + "thumbnail_default.jpg" if valid_cover else thumb_file) else: if False and self.verbose: self.opts.log.warn(" generating new thumbnail_default.jpg") - #title['cover'] = "%s/DefaultCover.jpg" % self.catalogPath - title['cover'] = cover - self.generateThumbnail(title, image_dir, "thumbnail_default.jpg") + self.generateThumbnail(title, image_dir, + "thumbnail_default.jpg" if valid_cover else thumb_file) + # Clear the book's cover property + title['cover'] = None - # Write the thumb_width to the file validating cache contents + + # Write thumb_width to the file, validating cache contents # Allows detection of aborted catalog builds with ZipFile(self.__archive_path, mode='a') as zfw: zfw.writestr('thumb_width', self.opts.thumb_width) @@ -3162,15 +3129,17 @@ then rebuild the catalog.\n''').format(author[0]) navLabelTag = Tag(ncx_soup, "navLabel") textTag = Tag(ncx_soup, "text") if book['series']: - tokens = list(book['title'].partition(':')) + series_index = str(book['series_index']) + if series_index.endswith('.0'): + series_index = series_index[:-2] if self.generateForKindle: # Don't include Author for Kindle - textTag.insert(0, NavigableString(self.formatNCXText('%s (%s)' % \ - (tokens[2].strip(), tokens[0]), dest='title'))) + textTag.insert(0, NavigableString(self.formatNCXText('%s (%s [%s])' % + (book['title'], book['series'], series_index), dest='title'))) else: # Include Author for non-Kindle - textTag.insert(0, NavigableString(self.formatNCXText('%s · %s (%s)' % \ - (tokens[2].strip(), book['author'], tokens[0]), dest='title'))) + textTag.insert(0, NavigableString(self.formatNCXText('%s (%s [%s]) · %s ' % + (book['title'], book['series'], series_index, book['author']), dest='title'))) else: if self.generateForKindle: # Don't include Author for Kindle @@ -3199,8 +3168,13 @@ then rebuild the catalog.\n''').format(author[0]) # Add the author tag cmTag = Tag(ncx_soup, '%s' % 'calibre:meta') cmTag['name'] = "author" - navStr = '%s | %s' % (self.formatNCXText(book['author'], dest='author'), - book['date'].split()[1]) + + if book['date']: + navStr = '%s | %s' % (self.formatNCXText(book['author'], dest='author'), + book['date'].split()[1]) + else: + navStr = '%s' % (self.formatNCXText(book['author'], dest='author')) + if 'tags' in book and len(book['tags']): navStr = self.formatNCXText(navStr + ' | ' + ' · '.join(sorted(book['tags'])), dest='author') cmTag.insert(0, NavigableString(navStr)) @@ -3725,43 +3699,6 @@ then rebuild the catalog.\n''').format(author[0]) add_to_master_date_range_list(current_titles_list) current_titles_list = [book['title']] - ''' - # Add *article* entries for each populated date range - # master_date_range_list{}: [0]:titles list [1]:datestr - for books_by_date_range in master_date_range_list: - navPointByDateRangeTag = Tag(soup, 'navPoint') - navPointByDateRangeTag['class'] = "article" - navPointByDateRangeTag['id'] = "%s-ID" % books_by_date_range[1].replace(' ','') - navPointTag['playOrder'] = self.playOrder - self.playOrder += 1 - navLabelTag = Tag(soup, 'navLabel') - textTag = Tag(soup, 'text') - textTag.insert(0, NavigableString(books_by_date_range[1])) - navLabelTag.insert(0, textTag) - navPointByDateRangeTag.insert(0,navLabelTag) - contentTag = Tag(soup, 'content') - contentTag['src'] = "%s#bdr_%s" % (HTML_file, - books_by_date_range[1].replace(' ','')) - - navPointByDateRangeTag.insert(1,contentTag) - - if self.generateForKindle: - cmTag = Tag(soup, '%s' % 'calibre:meta') - cmTag['name'] = "description" - cmTag.insert(0, NavigableString(books_by_date_range[0])) - navPointByDateRangeTag.insert(2, cmTag) - - cmTag = Tag(soup, '%s' % 'calibre:meta') - cmTag['name'] = "author" - navStr = '%d titles' % books_by_date_range[2] if books_by_date_range[2] > 1 else \ - '%d title' % books_by_date_range[2] - cmTag.insert(0, NavigableString(navStr)) - navPointByDateRangeTag.insert(3, cmTag) - - navPointTag.insert(nptc, navPointByDateRangeTag) - nptc += 1 - ''' - # Create an NCX article entry for each populated day # Loop over the booksByDate list, find start of each month, # add description_preview_count titles @@ -3944,7 +3881,8 @@ then rebuild the catalog.\n''').format(author[0]) outfile = open("%s/%s.ncx" % (self.catalogPath, self.basename), 'w') outfile.write(self.ncxSoup.prettify()) - # Helpers + + # ======================== Helpers ======================== def author_to_author_sort(self, author): tokens = author.split() tokens = tokens[-1:] + tokens[:-1] @@ -3952,45 +3890,39 @@ then rebuild the catalog.\n''').format(author[0]) tokens[0] += ',' return ' '.join(tokens).capitalize() - def author_compare(self,x,y): - # Return -1 if x<y - # Return 0 if x==y - # Return 1 if x>y - - # Different authors - sort by author_sort - if x['author_sort'].capitalize() > y['author_sort'].capitalize(): - return 1 - elif x['author_sort'].capitalize() < y['author_sort'].capitalize(): - return -1 + def booksByAuthorSorter_author_sort(self, book): + ''' + Sort non-series books before series books + ''' + if not book['series']: + key = '%s %s' % (capitalize(book['author_sort']), + capitalize(book['title_sort'])) else: - # Same author - if x['series'] != y['series']: - # One title is a series, the other is not - if not x['series']: - # Sort regular titles < series titles - return -1 - elif not y['series']: - return 1 + index = book['series_index'] + integer = int(index) + fraction = index-integer + series_index = '%04d%s' % (integer, str('%0.4f' % fraction).lstrip('0')) + key = '%s ~%s %s' % (capitalize(book['author_sort']), + self.generateSortTitle(book['series']), + series_index) + return key - # Different series - if x['title_sort'].lstrip() > y['title_sort'].lstrip(): - return 1 - else: - return -1 - else: - # Same series - if x['series'] == y['series']: - if float(x['series_index']) > float(y['series_index']): - return 1 - elif float(x['series_index']) < float(y['series_index']): - return -1 - else: - return 0 - else: - if x['series'] > y['series']: - return 1 - else: - return -1 + def booksByAuthorSorter_author(self, book): + ''' + Sort non-series books before series books + ''' + if not book['series']: + key = '%s %s' % (self.author_to_author_sort(book['author']), + capitalize(book['title_sort'])) + else: + index = book['series_index'] + integer = int(index) + fraction = index-integer + series_index = '%04d%s' % (integer, str('%0.4f' % fraction).lstrip('0')) + key = '%s ~%s %s' % (self.author_to_author_sort(book['author']), + self.generateSortTitle(book['series']), + series_index) + return key def calculateThumbnailSize(self): ''' Calculate thumbnail dimensions based on device DPI. Scale Kindle by 50% ''' @@ -4155,6 +4087,20 @@ then rebuild the catalog.\n''').format(author[0]) # Strip white space to '' return re.sub("\W","", author) + def generateFormatArgs(self, book): + series_index = str(book['series_index']) + if series_index.endswith('.0'): + series_index = series_index[:-2] + args = dict( + title = book['title'], + series = book['series'], + series_index = series_index, + rating = self.generateRatingString(book), + rating_parens = '(%s)' % self.generateRatingString(book) if 'rating' in book else '', + pubyear = book['date'].split()[1] if book['date'] else '', + pubyear_parens = "(%s)" % book['date'].split()[1] if book['date'] else '') + return args + def generateHTMLByGenre(self, genre, section_head, books, outfile): # Write an HTML file of this genre's book list # Return a list with [(first_author, first_book), (last_author, last_book)] @@ -4201,16 +4147,6 @@ then rebuild the catalog.\n''').format(author[0]) divTag.insert(dtc,pAuthorTag) dtc += 1 - ''' - # Insert an <hr /> between non-series and series - if not current_series and non_series_books and book['series']: - # Insert an <hr /> - hrTag = Tag(soup,'hr') - hrTag['class'] = "series_divider" - divTag.insert(dtc,hrTag) - dtc += 1 - ''' - # Check for series if book['series'] and book['series'] != current_series: # Start a new series @@ -4235,17 +4171,6 @@ then rebuild the catalog.\n''').format(author[0]) pBookTag = Tag(soup, "p") ptc = 0 - ''' - # This if clause does not display MISSING_SYMBOL for wishlist items - # If this is the wishlist_tag genre, don't show missing symbols - # normalized_wishlist_tag = self.genre_tags_dict[self.opts.wishlist_tag] - if self.opts.wishlist_tag in book['tags'] and \ - self.genre_tags_dict[self.opts.wishlist_tag] != genre: - pBookTag['class'] = "wishlist_item" - pBookTag.insert(ptc,NavigableString(self.MISSING_SYMBOL)) - ptc += 1 - ''' - # book with read|reading|unread symbol or wishlist item if self.opts.wishlist_tag in book.get('tags', []): pBookTag['class'] = "wishlist_item" @@ -4271,12 +4196,18 @@ then rebuild the catalog.\n''').format(author[0]) aTag = Tag(soup, "a") if self.opts.generate_descriptions: aTag['href'] = "book_%d.html" % (int(float(book['id']))) - # Use series, series index if avail else just title + + # Generate the title from the template + args = self.generateFormatArgs(book) if current_series: - aTag.insert(0,escape(book['title'][len(book['series'])+1:])) + #aTag.insert(0,escape(book['title'][len(book['series'])+1:])) + formatted_title = self.by_genres_series_title_template.format(**args).rstrip() else: - aTag.insert(0,escape(book['title'])) + #aTag.insert(0,escape(book['title'])) + formatted_title = self.by_genres_normal_title_template.format(**args).rstrip() non_series_books += 1 + aTag.insert(0,NavigableString(escape(formatted_title))) + pBookTag.insert(ptc, aTag) ptc += 1 @@ -4327,31 +4258,16 @@ then rebuild the catalog.\n''').format(author[0]) generated_html = substitute_entites(generated_html) return BeautifulSoup(generated_html) - if False: - print "title metadata:\n%s" % ', '.join(sorted(book.keys())) - if False: - for item in sorted(book.keys()): - try: - print "%s: %s%s" % (item, book[item][:50], '...' if len(book[item])>50 else '') - except: - print "%s: %s" % (item, book[item]) - # Generate the template arguments css = P('catalog/stylesheet.css', data=True).decode('utf-8') - title_str = escape(book['title']) - - # Title/series + title_str = title = escape(book['title']) + series = '' + series_index = '' if book['series']: - series_id, _, title = book['title'].partition(':') - title = escape(title.strip()) series = escape(book['series']) series_index = str(book['series_index']) if series_index.endswith('.0'): series_index = series_index[:-2] - else: - title = escape(book['title']) - series = '' - series_index = '' # Author, author_prefix (read|reading|none symbol or missing symbol) author = book['author'] @@ -4391,13 +4307,16 @@ then rebuild the catalog.\n''').format(author[0]) formats = ' · '.join(formats) # Date of publication - pubdate = book['date'] - pubmonth, pubyear = pubdate.split(' ') + if book['date']: + pubdate = book['date'] + pubmonth, pubyear = pubdate.split() + else: + pubdate = pubyear = pubmonth = '' # Thumb _soup = BeautifulSoup('<html>',selfClosingTags=['img']) thumb = Tag(_soup,"img") - if 'cover' in book: + if 'cover' in book and book['cover']: thumb['src'] = "../images/thumbnail_%d.jpg" % int(book['id']) else: thumb['src'] = "../images/thumbnail_default.jpg" @@ -4562,16 +4481,19 @@ then rebuild the catalog.\n''').format(author[0]) draw.text((left, top), text, fill=(0,0,0), font=font) img.save(open(out_path, 'wb'), 'GIF') - def generateSeriesTitle(self, title): - if float(title['series_index']) - int(title['series_index']): - series_title = '%s %4.2f: %s' % (title['series'], - title['series_index'], - title['title']) - else: - series_title = '%s %d: %s' % (title['series'], - title['series_index'], - title['title']) - return series_title + def generateRatingString(self, book): + rating = '' + try: + if 'rating' in book: + stars = int(book['rating']) / 2 + if stars: + star_string = self.FULL_RATING_SYMBOL * stars + empty_stars = self.EMPTY_RATING_SYMBOL * (5 - stars) + rating = '%s%s' % (star_string,empty_stars) + except: + # Rating could be None + pass + return rating def generateShortDescription(self, description, dest=None): # Truncate the description, on word boundaries if necessary @@ -4610,9 +4532,11 @@ then rebuild the catalog.\n''').format(author[0]) raise RuntimeError def generateSortTitle(self, title): - # Generate a string suitable for sorting from the title - # Ignore leading stop words - # Optionally convert leading numbers to strings + ''' + Generate a string suitable for sorting from the title + Ignore leading stop words + Optionally convert leading numbers to strings + ''' from calibre.ebooks.metadata import title_sort # Strip stop words @@ -4641,7 +4565,7 @@ then rebuild the catalog.\n''').format(author[0]) if self.letter_or_symbol(word[0]) != word[0]: if word[0] > 'A' or (ord('9') < ord(word[0]) < ord('A')) : translated.append('/') - translated.append(word.capitalize()) + translated.append(capitalize(word)) else: if re.search('[0-9]+',word[0]): @@ -4910,13 +4834,6 @@ then rebuild the catalog.\n''').format(author[0]) self.progressInt = coarse_progress + fine_progress self.reporter(self.progressInt, self.progressString) - class NotImplementedError: - def __init__(self, error): - self.error = error - - def logerror(self): - self.opts.log.info('%s not implemented' % self.error) - def run(self, path_to_output, opts, db, notification=DummyReporter()): opts.log = log opts.fmt = self.fmt = path_to_output.rpartition('.')[2] @@ -4982,11 +4899,12 @@ then rebuild the catalog.\n''').format(author[0]) if opts_dict['ids']: build_log.append(" book count: %d" % len(opts_dict['ids'])) - sections_list = ['Authors'] ''' + sections_list = [] if opts.generate_authors: sections_list.append('Authors') ''' + sections_list = ['Authors'] if opts.generate_titles: sections_list.append('Titles') if opts.generate_genres: @@ -5042,7 +4960,7 @@ then rebuild the catalog.\n''').format(author[0]) if catalog_source_built: log.info(" Completed catalog source generation\n") else: - log.warn(" No database hits with supplied criteria") + log.warn(" *** Errors during catalog generation, check log for details ***") if catalog_source_built: recommendations = [] @@ -5072,8 +4990,6 @@ then rebuild the catalog.\n''').format(author[0]) abort_after_input_dump=False) plumber.merge_ui_recommendations(recommendations) plumber.run() - # returns to gui2.actions.catalog:catalog_generated() - return None - else: - # returns to gui2.actions.catalog:catalog_generated() - return catalog.error + + # returns to gui2.actions.catalog:catalog_generated() + return catalog.error diff --git a/src/calibre/library/cli.py b/src/calibre/library/cli.py index 31f5e73689..e93be187f9 100644 --- a/src/calibre/library/cli.py +++ b/src/calibre/library/cli.py @@ -693,14 +693,7 @@ def command_catalog(args, dbpath): } with plugin: - ret = plugin.run(args[1], opts, get_db(dbpath, opts)) - if ret is None: - ret = 0 - else: - ret = 1 - return ret - -# end of GR additions + return int(bool(plugin.run(args[1], opts, get_db(dbpath, opts)))) def parse_series_string(db, label, value): val = unicode(value).strip() diff --git a/src/calibre/manual/faq.rst b/src/calibre/manual/faq.rst index ee72bf6fdb..b473893673 100644 --- a/src/calibre/manual/faq.rst +++ b/src/calibre/manual/faq.rst @@ -101,6 +101,17 @@ We just need some information from you: Once you send us the output for a particular operating system, support for the device in that operating system will appear in the next release of |app|. +My device is not being detected by |app|? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Follow these steps to find the problem: + + * Make sure that you are connecting only a single device to your computer at a time. Do not have another |app| supported device like an iPhone/iPad etc. at the same time. + * Make sure you are running the latest version of |app|. The latest version can always be downloaded from `http://calibre-ebook.com/download`_. + * Ensure your operating system is seeing the device. That is, the device should be mounted as a disk that you can access using Windows explorer or whatever the file management program on your computer is + * In calibre, go to Preferences->Plugins->Device Interface plugin and make sure the plugin for your device is enabled. + * If all the above steps fail, go to Preferences->Miscellaneous and click debug device detection with your device attached and post the output as a ticket on `http://bugs.calibre-ebook.com`_. + How does |app| manage collections on my SONY reader? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/calibre/utils/smtplib.py b/src/calibre/utils/smtplib.py index d6f3fb0b69..9992039d00 100755 --- a/src/calibre/utils/smtplib.py +++ b/src/calibre/utils/smtplib.py @@ -554,6 +554,8 @@ class SMTP: def encode_cram_md5(challenge, user, password): challenge = base64.decodestring(challenge) + if isinstance(password, unicode): # Added by Kovid, see http://bugs.python.org/issue5285 + password = password.encode('utf-8') response = user + " " + hmac.HMAC(password, challenge).hexdigest() return encode_base64(response, eol="") diff --git a/src/calibre/web/feeds/news.py b/src/calibre/web/feeds/news.py index dd32d3749f..6215132e4b 100644 --- a/src/calibre/web/feeds/news.py +++ b/src/calibre/web/feeds/news.py @@ -839,7 +839,13 @@ class BasicNewsRecipe(Recipe): fetcher.image_url_processor = self.image_url_processor res, path, failures = fetcher.start_fetch(url), fetcher.downloaded_paths, fetcher.failed_links if not res or not os.path.exists(res): - raise Exception(_('Could not fetch article. Run with -vv to see the reason')) + msg = _('Could not fetch article.') + ' ' + if self.debug: + msg += _('The debug traceback is available earlier in this log') + else: + msg += _('Run with -vv to see the reason') + raise Exception(msg) + return res, path, failures def fetch_article(self, url, dir, f, a, num_of_feeds): @@ -901,7 +907,7 @@ class BasicNewsRecipe(Recipe): if self.test: feeds = feeds[:2] self.has_single_feed = len(feeds) == 1 - + index = os.path.join(self.output_dir, 'index.html') html = self.feeds2index(feeds)