From ec208049c547d73be9ee3807af21f4d583c2e5cc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 19 May 2010 15:39:15 -0600 Subject: [PATCH] Improved Il Messagero and Leggo (it) --- resources/recipes/il_messaggero.recipe | 21 ++++++++++++++++++--- resources/recipes/leggo_it.recipe | 26 +++++++++++++++++++++----- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/resources/recipes/il_messaggero.recipe b/resources/recipes/il_messaggero.recipe index e2c90075d5..93c35f4695 100644 --- a/resources/recipes/il_messaggero.recipe +++ b/resources/recipes/il_messaggero.recipe @@ -7,14 +7,14 @@ description = 'Italian daily newspaper - v1.01 (04, January 2010)' ''' http://www.messaggero.it/ ''' - +import time from calibre.web.feeds.news import BasicNewsRecipe class IlMessaggero(BasicNewsRecipe): __author__ = 'Gabriele Marini' description = 'Italian News' - cover_url = 'http://www.ilmessaggero.it/img_tst/logomsgr.gif' +# cover_url = 'http://www.ilmessaggero.it/img_tst/logomsgr.gif' title = u'Il Messaggero' publisher = 'Caltagirone Editore' category = 'News, politics, culture, economy, general interest' @@ -34,6 +34,21 @@ class IlMessaggero(BasicNewsRecipe): dict(name='h2', attrs={'class':'sottotitLettura'}), dict(name='span', attrs={'class':'testoArticoloG'}) ] + 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 + cover='http://carta.ilmessaggero.it/' + year + month + day + '/jpeg/MSGR_20_CITTA_1.jpg' + br = BasicNewsRecipe.get_browser() + try: + br.open(cover) + except: + self.log("\nCover unavailable") + cover = 'http://www.ilmessaggero.it/img_tst/logomsgr.gif' + + return cover @@ -53,4 +68,4 @@ class IlMessaggero(BasicNewsRecipe): (u'Calcio', u'http://www.ilmessaggero.it/rss/sport_calcio.xml'), (u'Motori', u'http://www.ilmessaggero.it/rss/sport_motori.xml') ] - + diff --git a/resources/recipes/leggo_it.recipe b/resources/recipes/leggo_it.recipe index 1e2b5aca5b..5be21e7dfc 100644 --- a/resources/recipes/leggo_it.recipe +++ b/resources/recipes/leggo_it.recipe @@ -7,14 +7,14 @@ description = 'Italian daily newspaper - v1.00 05-05-2010' ''' http://www.leggo.it ''' - +import time from calibre.web.feeds.news import BasicNewsRecipe class LeggoIT(BasicNewsRecipe): __author__ = 'Gabriele Marini' description = 'Italian Free daily newspaper' - cover_url = 'http://www.leggo.it/img/logo-leggo2.gif' +# cover_url = 'http://www.leggo.it/img/logo-leggo2.gif' title = u'Leggo.it' publisher = 'Ced Caltagirone Editore S.p.A.' category = 'News, politics, culture, economy, general interest' @@ -33,8 +33,8 @@ class LeggoIT(BasicNewsRecipe): keep_only_tags = [ dict(name='h1',attrs={'class':'nero22'}), - dict(name='div',attrs={'id':'testodim'}) - ] + dict(name='div',attrs={'id':'testodim'}) + ] feeds = [ (u'Home Page', u'http://www.leggo.it/rss/home.xml'), (u'Italia', u'http://www.leggo.it/rss/italia.xml'), @@ -45,5 +45,21 @@ class LeggoIT(BasicNewsRecipe): (u'Spettacoli', u'http://www.leggo.it/rss/spettacoli.xml'), (u'Salute', u'http://www.leggo.it/rss/salute.xml'), (u'Scienza', u'http://www.leggo.it/rss/scienza.xml') - ] + ] + 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 + cover='http://www.leggo.it/'+ year + month + day + '/jpeg/LEGGO_ROMA_1.jpg' + br = BasicNewsRecipe.get_browser() + try: + br.open(cover) + except: + self.log("\nCover unavailable") + cover = 'http://www.leggo.it/img/logo-leggo2.gif' + + return cover +