mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
519cd869ac
@ -9,13 +9,14 @@ __docformat__ = 'restructuredtext en'
|
|||||||
elpais.es
|
elpais.es
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
from time import strftime
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
class ElPais(BasicNewsRecipe):
|
class ElPais(BasicNewsRecipe):
|
||||||
__author__ = 'Kovid Goyal & Lorenzo Vigentini & Jordi Balcells'
|
__author__ = 'Kovid Goyal & Lorenzo Vigentini & Jordi Balcells'
|
||||||
description = 'Main daily newspaper from Spain'
|
description = 'Main daily newspaper from Spain'
|
||||||
|
|
||||||
cover_url = 'http://www.elpais.com/im/tit_logo_global.gif'
|
|
||||||
title = u'El Pais'
|
title = u'El Pais'
|
||||||
publisher = u'Ediciones El Pa\xeds SL'
|
publisher = u'Ediciones El Pa\xeds SL'
|
||||||
category = 'News, politics, culture, economy, general interest'
|
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')
|
(u'Vi\xf1etas', u'http://www.elpais.com/rss/feed.html?feedId=17058')
|
||||||
]
|
]
|
||||||
|
|
||||||
def print_version(self, url):
|
def get_cover_url(self):
|
||||||
url = url+'?print=1'
|
return 'http://img5.kiosko.net/' + strftime("%Y/%m/%d") + '/es/elpais.750.jpg'
|
||||||
return url
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
@ -23,6 +24,10 @@ class NYTimes(BasicNewsRecipe):
|
|||||||
webEdition = False
|
webEdition = False
|
||||||
oldest_article = 7
|
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.
|
# includeSections: List of sections to include. If empty, all sections found will be included.
|
||||||
# Otherwise, only the sections named will be included. For example,
|
# Otherwise, only the sections named will be included. For example,
|
||||||
#
|
#
|
||||||
@ -94,6 +99,10 @@ class NYTimes(BasicNewsRecipe):
|
|||||||
title='New York Times (Web)'
|
title='New York Times (Web)'
|
||||||
description = 'New York Times on the Web'
|
description = 'New York Times on the Web'
|
||||||
needs_subscription = True
|
needs_subscription = True
|
||||||
|
elif replaceKindleVersion:
|
||||||
|
title='The New York Times'
|
||||||
|
description = 'Today\'s New York Times'
|
||||||
|
needs_subscription = True
|
||||||
else:
|
else:
|
||||||
title='New York Times'
|
title='New York Times'
|
||||||
description = 'Today\'s New York Times'
|
description = 'Today\'s New York Times'
|
||||||
@ -623,7 +632,7 @@ class NYTimes(BasicNewsRecipe):
|
|||||||
self.log(">>> No class:'columnGroup first' found <<<")
|
self.log(">>> No class:'columnGroup first' found <<<")
|
||||||
except:
|
except:
|
||||||
self.log("ERROR: One picture per article in postprocess_html")
|
self.log("ERROR: One picture per article in postprocess_html")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Change captions to italic
|
# Change captions to italic
|
||||||
for caption in soup.findAll(True, {'class':'caption'}) :
|
for caption in soup.findAll(True, {'class':'caption'}) :
|
||||||
@ -637,7 +646,7 @@ class NYTimes(BasicNewsRecipe):
|
|||||||
caption.replaceWith(cTag)
|
caption.replaceWith(cTag)
|
||||||
except:
|
except:
|
||||||
self.log("ERROR: Problem in change captions to italic")
|
self.log("ERROR: Problem in change captions to italic")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Change <nyt_headline> to <h2>
|
# Change <nyt_headline> to <h2>
|
||||||
h1 = soup.find('h1')
|
h1 = soup.find('h1')
|
||||||
@ -675,7 +684,7 @@ class NYTimes(BasicNewsRecipe):
|
|||||||
except:
|
except:
|
||||||
self.log("ERROR: Problem in Change <h1> to <h3> - used in editorial blogs")
|
self.log("ERROR: Problem in Change <h1> to <h3> - used in editorial blogs")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Change <span class="bold"> to <b>
|
# Change <span class="bold"> to <b>
|
||||||
for subhead in soup.findAll(True, {'class':'bold'}) :
|
for subhead in soup.findAll(True, {'class':'bold'}) :
|
||||||
if subhead.contents:
|
if subhead.contents:
|
||||||
@ -684,15 +693,15 @@ class NYTimes(BasicNewsRecipe):
|
|||||||
subhead.replaceWith(bTag)
|
subhead.replaceWith(bTag)
|
||||||
except:
|
except:
|
||||||
self.log("ERROR: Problem in Change <h1> to <h3> - used in editorial blogs")
|
self.log("ERROR: Problem in Change <h1> to <h3> - used in editorial blogs")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
divTag = soup.find('div',attrs={'id':'articleBody'})
|
divTag = soup.find('div',attrs={'id':'articleBody'})
|
||||||
if divTag:
|
if divTag:
|
||||||
divTag['class'] = divTag['id']
|
divTag['class'] = divTag['id']
|
||||||
except:
|
except:
|
||||||
self.log("ERROR: Problem in soup.find(div,attrs={id:articleBody})")
|
self.log("ERROR: Problem in soup.find(div,attrs={id:articleBody})")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Add class="authorId" to <div> so we can format with CSS
|
# Add class="authorId" to <div> so we can format with CSS
|
||||||
divTag = soup.find('div',attrs={'id':'authorId'})
|
divTag = soup.find('div',attrs={'id':'authorId'})
|
||||||
if divTag and divTag.contents[0]:
|
if divTag and divTag.contents[0]:
|
||||||
@ -700,10 +709,10 @@ class NYTimes(BasicNewsRecipe):
|
|||||||
tag['class'] = "authorId"
|
tag['class'] = "authorId"
|
||||||
tag.insert(0, self.fixChars(self.tag_to_string(divTag.contents[0],
|
tag.insert(0, self.fixChars(self.tag_to_string(divTag.contents[0],
|
||||||
use_alt=False)))
|
use_alt=False)))
|
||||||
divTag.replaceWith(tag)
|
divTag.replaceWith(tag)
|
||||||
except:
|
except:
|
||||||
self.log("ERROR: Problem in Add class=authorId to <div> so we can format with CSS")
|
self.log("ERROR: Problem in Add class=authorId to <div> so we can format with CSS")
|
||||||
|
|
||||||
return soup
|
return soup
|
||||||
def populate_article_metadata(self, article, soup, first):
|
def populate_article_metadata(self, article, soup, first):
|
||||||
shortparagraph = ""
|
shortparagraph = ""
|
||||||
|
@ -85,6 +85,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QCheckBox" name="opt_use_subdirs">
|
<widget class="QCheckBox" name="opt_use_subdirs">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>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.</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Use sub directories</string>
|
<string>Use sub directories</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -18,7 +18,7 @@ from calibre.ebooks.chardet import substitute_entites
|
|||||||
from calibre.ebooks.oeb.base import XHTML_NS
|
from calibre.ebooks.oeb.base import XHTML_NS
|
||||||
from calibre.ptempfile import PersistentTemporaryDirectory
|
from calibre.ptempfile import PersistentTemporaryDirectory
|
||||||
from calibre.utils.config import config_dir
|
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, is_date_undefined, now as nowf
|
||||||
from calibre.utils.icu import capitalize
|
from calibre.utils.icu import capitalize
|
||||||
from calibre.utils.logging import default_log as log
|
from calibre.utils.logging import default_log as log
|
||||||
from calibre.utils.zipfile import ZipFile, ZipInfo
|
from calibre.utils.zipfile import ZipFile, ZipInfo
|
||||||
@ -1559,7 +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
|
this_title['rating'] = record['rating'] if record['rating'] else 0
|
||||||
|
|
||||||
if re.match('0101-01-01',str(record['pubdate'].date())):
|
if is_date_undefined(record['pubdate']):
|
||||||
this_title['date'] = None
|
this_title['date'] = None
|
||||||
else:
|
else:
|
||||||
this_title['date'] = strftime(u'%B %Y', record['pubdate'].timetuple())
|
this_title['date'] = strftime(u'%B %Y', record['pubdate'].timetuple())
|
||||||
@ -2675,8 +2675,7 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
|
|||||||
# Use series, series index if avail else just title
|
# Use series, series index if avail else just title
|
||||||
#aTag.insert(0,'%d. %s · %s' % (book['series_index'],escape(book['title']), ' & '.join(book['authors'])))
|
#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 is_date_undefined(book['pubdate']):
|
||||||
if re.match('0101-01-01',str(book['pubdate'].date())):
|
|
||||||
book['date'] = None
|
book['date'] = None
|
||||||
else:
|
else:
|
||||||
book['date'] = strftime(u'%B %Y', book['pubdate'].timetuple())
|
book['date'] = strftime(u'%B %Y', book['pubdate'].timetuple())
|
||||||
|
@ -46,6 +46,16 @@ local_tz = _local_tz = SafeLocalTimeZone()
|
|||||||
|
|
||||||
UNDEFINED_DATE = datetime(101,1,1, tzinfo=utc_tz)
|
UNDEFINED_DATE = datetime(101,1,1, tzinfo=utc_tz)
|
||||||
|
|
||||||
|
def is_date_undefined(qt_or_dt):
|
||||||
|
d = qt_or_dt
|
||||||
|
if d is None:
|
||||||
|
return True
|
||||||
|
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):
|
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
|
Parse a date/time string into a timezone aware datetime object. The timezone
|
||||||
|
Loading…
x
Reference in New Issue
Block a user