From 3cf7988c256c4547111e76cd2df9b02ce19f4010 Mon Sep 17 00:00:00 2001 From: sylvaindurand Date: Mon, 5 Aug 2013 16:04:04 +0200 Subject: [PATCH 1/2] Typography, error message and description - french typography (apostrophes, guillemets); - error message if using a free account (which can't download the newspaper); - description. --- recipes/le_monde_sub.recipe | 55 +++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/recipes/le_monde_sub.recipe b/recipes/le_monde_sub.recipe index dc9fa9d36f..e55d71e0a7 100644 --- a/recipes/le_monde_sub.recipe +++ b/recipes/le_monde_sub.recipe @@ -13,7 +13,7 @@ class LeMonde(BasicNewsRecipe): title = u'Le Monde: Édition abonnés' __author__ = 'Sylvain Durand' - description = u'Disponible du lundi au samedi à partir de 14 heures environ, avec tous ses cahiers.' + description = u'La version papier du quotidien Le Monde, disponible du lundi au samedi à partir de 14 heures environ, avec tous ses cahiers.' language = 'fr' encoding = 'utf8' @@ -65,28 +65,41 @@ class LeMonde(BasicNewsRecipe): url = time.strftime(self.journal_url,self.date) soup = self.index_to_soup(url).sommaire sections = [] - for sec in soup.findAll("section"): - articles = [] - if sec['cahier'] != "Le Monde": - for col in sec.findAll("fnts"): - col.extract() - if sec['cahier']=="Le Monde Magazine": - continue - for art in sec.findAll("art"): - if art.txt.string and art.ttr.string: - if art.find(['url']): - art.insert(6,'
') - if art.find(['lgd']) and art.find(['lgd']).string: - art.insert(7,'
'+art.find(['lgd']).string+'
') - article = ""+unicode(art)+"" - article = article.replace('','').replace(' oC ','°C ') - article = article.replace('srttr>','h3>').replace('ssttr>','h2>').replace('ttr>','h1>') - f = PersistentTemporaryFile() - f.write(article) - articles.append({'title':art.ttr.string,'url':"file:///"+f.name}) - sections.append((sec['nom'], articles)) + try: + for sec in soup.findAll("section"): + articles = [] + if sec['cahier'] != "Le Monde": + for col in sec.findAll("fnts"): + col.extract() + if sec['cahier']=="Le Monde Magazine": + continue + for art in sec.findAll("art"): + if art.txt.string and art.ttr.string: + if art.find(['url']): + art.insert(6,'
') + if art.find(['lgd']) and art.find(['lgd']).string: + art.insert(7,'
'+art.find(['lgd']).string+'
') + + def guillemets(match): + if match.group(1) == u"=": + return match.group(0) + return u'%s« %s »' % (match.group(1), match.group(2)) + + article = ""+unicode(art)+"" + article = article.replace('','').replace(' oC ','°C ') + article = article.replace('srttr>','h3>').replace('ssttr>','h2>').replace('ttr>','h1>') + article = article.replace("'" , u'\u2019') + article = re.sub('(.|^)"([^"]+)"', guillemets, article) + + f = PersistentTemporaryFile() + f.write(article) + articles.append({'title':art.ttr.string,'url':"file:///"+f.name}) + sections.append((sec['nom'], articles)) + except AttributeError: + self.log("Vos identifiants sont incorrects, ou votre abonnement LeMonde.fr ne vous permet pas de télécharger le journal.") return sections + def preprocess_html(self, soup): for lgd in soup.findAll(id="lgd"): lgd.contents[-1].extract() From 71c7489cc1b618edce7058820464fd9cab0ec9d9 Mon Sep 17 00:00:00 2001 From: Sylvain Durand Date: Mon, 5 Aug 2013 17:09:22 +0200 Subject: [PATCH 2/2] =?UTF-8?q?New=20icon=20for=20Le=20Monde:=20Edition=20?= =?UTF-8?q?abonn=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- recipes/icons/le_monde_sub.png | Bin 0 -> 510 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 recipes/icons/le_monde_sub.png diff --git a/recipes/icons/le_monde_sub.png b/recipes/icons/le_monde_sub.png new file mode 100644 index 0000000000000000000000000000000000000000..a9b1717f77efa5e7346e8a9211e077f1896d6fae GIT binary patch literal 510 zcmVn>j(e<0gFjQ zK~y-)#go6zVNn#tf9IZyjzr@L6cRMzU*Qq(8WNFEQi(*N(@=Q>jn*58R-xb>{0WVF zuQkQQoe^JVCi#k4&Dl9Sd!4=4UdI698*un0LV`#n5}vVG3}Xz|TCBAIxUP%qx?dAm zYw3lxxh4p%^`~5CS zIv$Ve_xm!&=%t?kWwTiU>h*e(q*kk?*=#0B>UO&-l}g%fx0+6;uR;L|HQ4X>03;F# zf*>H7Ome+m34(xlJWf8Jr&ugb%707*qoM6N<$f&}W< AJOBUy literal 0 HcmV?d00001