Improved recipes for Corriere Della Serra and Leggo

This commit is contained in:
Kovid Goyal 2010-05-28 00:57:17 -06:00
parent 141003eb42
commit 59007222ab
2 changed files with 45 additions and 20 deletions

View File

@ -9,22 +9,25 @@ __description__ = 'Italian daily newspaper'
''' '''
http://www.corriere.it/ http://www.corriere.it/
''' '''
import time
from calibre.web.feeds.news import BasicNewsRecipe from calibre.web.feeds.news import BasicNewsRecipe
class ilCorriere(BasicNewsRecipe): class ilCorriere(BasicNewsRecipe):
__author__ = 'Lorenzo Vigentini, based on Darko Miletic' __author__ = 'Lorenzo Vigentini, based on Darko Miletic, Gabriele Marini'
description = 'Italian daily newspaper' description = 'Italian daily newspaper'
cover_url = 'http://images.corriereobjects.it/images/static/common/logo_home.gif?v=200709121520' # cover_url = 'http://images.corriereobjects.it/images/static/common/logo_home.gif?v=200709121520
title = u'Il Corriere della sera' title = u'Il Corriere della sera'
publisher = 'RCS Digital' publisher = 'RCS Digital'
category = 'News, politics, culture, economy, general interest' category = 'News, politics, culture, economy, general interest'
encoding = 'cp1252'
language = 'it' language = 'it'
timefmt = '[%a, %d %b, %Y]' timefmt = '[%a, %d %b, %Y]'
oldest_article = 1 oldest_article = 10
max_articles_per_feed = 100 max_articles_per_feed = 100
use_embedded_content = False use_embedded_content = False
recursion = 10 recursion = 10
@ -51,6 +54,22 @@ class ilCorriere(BasicNewsRecipe):
remove_tags_after = dict(name='p', attrs={'class':'footnotes'}) remove_tags_after = dict(name='p', attrs={'class':'footnotes'})
def get_cover_url(self):
cover = None
st = time.localtime()
year = str(st.tm_year)
month = "%.2d" % st.tm_mon
day = "%.2d" % st.tm_mday
#http://images.corriere.it/primapagina/storico/2010_05_17/images/prima_pagina_grande.png
cover='http://images.corriere.it/primapagina/storico/'+ year + '_' + month +'_' + day +'/images/prima_pagina_grande.png'
br = BasicNewsRecipe.get_browser()
try:
br.open(cover)
except:
self.log("\nCover unavailable")
cover ='http://images.corriereobjects.it/images/static/common/logo_home.gif?v=200709121520'
return cover
feeds = [ feeds = [
(u'Ultimora' , u'http://www.corriere.it/rss/ultimora.xml' ), (u'Ultimora' , u'http://www.corriere.it/rss/ultimora.xml' ),
(u'Editoriali' , u'http://www.corriere.it/rss/editoriali.xml'), (u'Editoriali' , u'http://www.corriere.it/rss/editoriali.xml'),
@ -63,5 +82,7 @@ class ilCorriere(BasicNewsRecipe):
(u'Salute' , u'http://www.corriere.it/rss/salute.xml' ), (u'Salute' , u'http://www.corriere.it/rss/salute.xml' ),
(u'Spettacolo' , u'http://www.corriere.it/rss/spettacoli.xml'), (u'Spettacolo' , u'http://www.corriere.it/rss/spettacoli.xml'),
(u'Cinema e TV', u'http://www.corriere.it/rss/cinema.xml' ), (u'Cinema e TV', u'http://www.corriere.it/rss/cinema.xml' ),
(u'Sport' , u'http://www.corriere.it/rss/sport.xml' ) (u'Sport' , u'http://www.corriere.it/rss/sport.xml' ),
(u'Roma' , u'http://www.corriere.it/rss/homepage_roma.xml'),
(u'Milano' , u'http://www.corriere.it/rss/homepage_milano.xml')
] ]

View File

@ -54,12 +54,16 @@ class LeggoIT(BasicNewsRecipe):
day = "%.2d" % st.tm_mday day = "%.2d" % st.tm_mday
cover='http://www.leggo.it/'+ year + month + day + '/jpeg/LEGGO_ROMA_1.jpg' cover='http://www.leggo.it/'+ year + month + day + '/jpeg/LEGGO_ROMA_1.jpg'
br = BasicNewsRecipe.get_browser() br = BasicNewsRecipe.get_browser()
try:
br.open(cover)
except:
cover='http://www.leggo.it/'+ year + month + day + '/jpeg/LEGGO_ROMA_3.jpg'
br = BasicNewsRecipe.get_browser()
try: try:
br.open(cover) br.open(cover)
except: except:
self.log("\nCover unavailable") self.log("\nCover unavailable")
cover = 'http://www.leggo.it/img/logo-leggo2.gif' cover = 'http://www.leggo.it/img/logo-leggo2.gif'
return cover return cover