From 5e9fbd8f66fdecd3b7d41dbfe5af3df6d172ac46 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 18 Jan 2011 10:26:35 -0700 Subject: [PATCH 1/6] ... --- src/calibre/gui2/device_drivers/configwidget.ui | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/calibre/gui2/device_drivers/configwidget.ui b/src/calibre/gui2/device_drivers/configwidget.ui index f4902a7387..619d7052e8 100644 --- a/src/calibre/gui2/device_drivers/configwidget.ui +++ b/src/calibre/gui2/device_drivers/configwidget.ui @@ -85,6 +85,9 @@ + + If checked, books are placed into sub directories based on their metadata on the device. If unchecked, books are all put into the top level directory. + Use sub directories From f8182c38043e663ba3c53d334529f8e55fe89608 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 18 Jan 2011 10:47:24 -0700 Subject: [PATCH 2/6] Add a is_undefined_date method to utils.date --- src/calibre/utils/date.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/calibre/utils/date.py b/src/calibre/utils/date.py index 2551b90788..d970ed228d 100644 --- a/src/calibre/utils/date.py +++ b/src/calibre/utils/date.py @@ -46,6 +46,14 @@ local_tz = _local_tz = SafeLocalTimeZone() UNDEFINED_DATE = datetime(101,1,1, tzinfo=utc_tz) +def is_date_undefined(qt_or_dt): + d = qt_or_dt + if hasattr(d, 'toString'): + d = datetime(d.year(), d.month(), d.day(), tzinfo=utc_tz) + return d.year == UNDEFINED_DATE.year and \ + d.month == UNDEFINED_DATE.month and \ + d.day == UNDEFINED_DATE.day + def parse_date(date_string, assume_utc=False, as_utc=True, default=None): ''' Parse a date/time string into a timezone aware datetime object. The timezone From 6c92177944f2a49e3d50d6b5d7ddcd84119016e9 Mon Sep 17 00:00:00 2001 From: GRiker Date: Tue, 18 Jan 2011 10:51:56 -0700 Subject: [PATCH 3/6] GwR revisions to catalog generator --- src/calibre/library/catalog.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index ea02c29fa7..16e90aaf0c 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -18,7 +18,7 @@ from calibre.ebooks.chardet import substitute_entites 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.date import format_date, isoformat, now as nowf, UNDEFINED_DATE, utc_tz from calibre.utils.icu import capitalize from calibre.utils.logging import default_log as log from calibre.utils.zipfile import ZipFile, ZipInfo @@ -1559,6 +1559,8 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1]) this_title['rating'] = record['rating'] if record['rating'] else 0 + #pubdate = record['pubdate'].astimezone(utc_tz) + #if pubdate == UNDEFINED_DATE: if re.match('0101-01-01',str(record['pubdate'].date())): this_title['date'] = None else: @@ -2676,6 +2678,7 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1]) #aTag.insert(0,'%d. %s · %s' % (book['series_index'],escape(book['title']), ' & '.join(book['authors']))) # Reassert 'date' since this is the result of a new search + #if book['pubdate'] == UNDEFINED_DATE: # tz doesn't match if re.match('0101-01-01',str(book['pubdate'].date())): book['date'] = None else: From 8c8583b7298dccb243a4c15aaa467ff87af08949 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 18 Jan 2011 10:58:29 -0700 Subject: [PATCH 4/6] Update El Pais --- resources/recipes/el_pais.recipe | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/resources/recipes/el_pais.recipe b/resources/recipes/el_pais.recipe index 2e358060b8..4da3384093 100644 --- a/resources/recipes/el_pais.recipe +++ b/resources/recipes/el_pais.recipe @@ -9,13 +9,14 @@ __docformat__ = 'restructuredtext en' elpais.es ''' +from time import strftime + from calibre.web.feeds.news import BasicNewsRecipe class ElPais(BasicNewsRecipe): __author__ = 'Kovid Goyal & Lorenzo Vigentini & Jordi Balcells' description = 'Main daily newspaper from Spain' - cover_url = 'http://www.elpais.com/im/tit_logo_global.gif' title = u'El Pais' publisher = u'Ediciones El Pa\xeds SL' category = 'News, politics, culture, economy, general interest' @@ -62,6 +63,6 @@ class ElPais(BasicNewsRecipe): (u'Vi\xf1etas', u'http://www.elpais.com/rss/feed.html?feedId=17058') ] -def print_version(self, url): - url = url+'?print=1' - return url + def get_cover_url(self): + return 'http://img5.kiosko.net/' + strftime("%Y/%m/%d") + '/es/elpais.750.jpg' + From f178ce16f19c0aa8f149447cf9d287691b66fa52 Mon Sep 17 00:00:00 2001 From: GRiker Date: Tue, 18 Jan 2011 10:58:57 -0700 Subject: [PATCH 5/6] GwR revisions to catalog generator --- src/calibre/library/catalog.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index 16e90aaf0c..ae600a29f9 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -18,7 +18,7 @@ from calibre.ebooks.chardet import substitute_entites 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, UNDEFINED_DATE, utc_tz +from calibre.utils.date import format_date, isoformat, is_date_undefined, 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 @@ -1559,9 +1559,7 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1]) this_title['rating'] = record['rating'] if record['rating'] else 0 - #pubdate = record['pubdate'].astimezone(utc_tz) - #if pubdate == UNDEFINED_DATE: - if re.match('0101-01-01',str(record['pubdate'].date())): + if is_date_undefined(record['pubdate']): this_title['date'] = None else: this_title['date'] = strftime(u'%B %Y', record['pubdate'].timetuple()) @@ -2677,9 +2675,7 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1]) # Use series, series index if avail else just title #aTag.insert(0,'%d. %s · %s' % (book['series_index'],escape(book['title']), ' & '.join(book['authors']))) - # Reassert 'date' since this is the result of a new search - #if book['pubdate'] == UNDEFINED_DATE: # tz doesn't match - if re.match('0101-01-01',str(book['pubdate'].date())): + if is_date_undefined(book['pubdate']): book['date'] = None else: book['date'] = strftime(u'%B %Y', book['pubdate'].timetuple()) From 54fb874621bb7c56c35f930633fb226e58f244fb Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 18 Jan 2011 13:00:20 -0700 Subject: [PATCH 6/6] ... --- resources/recipes/nytimes_sub.recipe | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/resources/recipes/nytimes_sub.recipe b/resources/recipes/nytimes_sub.recipe index 8f92852237..cdacc42d92 100644 --- a/resources/recipes/nytimes_sub.recipe +++ b/resources/recipes/nytimes_sub.recipe @@ -1,4 +1,5 @@ #!/usr/bin/env python +# -*- coding: utf-8 -*- __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal ' @@ -23,6 +24,10 @@ class NYTimes(BasicNewsRecipe): webEdition = False oldest_article = 7 + # replace paid Kindle Version: the name will be changed to "The New York Times" to cause + # previous paid versions of the new york times to best sent to the back issues folder on the kindle + replaceKindleVersion = False + # includeSections: List of sections to include. If empty, all sections found will be included. # Otherwise, only the sections named will be included. For example, # @@ -94,6 +99,10 @@ class NYTimes(BasicNewsRecipe): title='New York Times (Web)' description = 'New York Times on the Web' needs_subscription = True + elif replaceKindleVersion: + title='The New York Times' + description = 'Today\'s New York Times' + needs_subscription = True else: title='New York Times' description = 'Today\'s New York Times' @@ -623,7 +632,7 @@ class NYTimes(BasicNewsRecipe): 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'}) : @@ -637,7 +646,7 @@ class NYTimes(BasicNewsRecipe): caption.replaceWith(cTag) except: self.log("ERROR: Problem in change captions to italic") - + try: # Change to

h1 = soup.find('h1') @@ -675,7 +684,7 @@ class NYTimes(BasicNewsRecipe): except: self.log("ERROR: Problem in Change

to

- used in editorial blogs") - try: + try: # Change to for subhead in soup.findAll(True, {'class':'bold'}) : if subhead.contents: @@ -684,15 +693,15 @@ class NYTimes(BasicNewsRecipe): subhead.replaceWith(bTag) except: self.log("ERROR: Problem in Change

to

- used in editorial blogs") - - try: + + 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: + + try: # Add class="authorId" to
so we can format with CSS divTag = soup.find('div',attrs={'id':'authorId'}) if divTag and divTag.contents[0]: @@ -700,10 +709,10 @@ class NYTimes(BasicNewsRecipe): tag['class'] = "authorId" tag.insert(0, self.fixChars(self.tag_to_string(divTag.contents[0], use_alt=False))) - divTag.replaceWith(tag) + 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 = ""