diff --git a/recipes/el_diplo.recipe b/recipes/el_diplo.recipe
index d9fbe755a8..4b51ffc79f 100644
--- a/recipes/el_diplo.recipe
+++ b/recipes/el_diplo.recipe
@@ -1,123 +1,103 @@
-# Copyright 2013 Tomás Di Domenico
-#
-# This is a news fetching recipe for the Calibre ebook software, for
-# fetching the Cono Sur edition of Le Monde Diplomatique (www.eldiplo.org).
-#
-# This recipe is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This software is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this recipe. If not, see .
+# -*- mode: python; coding: utf-8; -*-
+# vim: set syntax=python fileencoding=utf-8
-import re
-from contextlib import closing
-from calibre.web.feeds.recipes import BasicNewsRecipe
+from __future__ import absolute_import, division, print_function, unicode_literals
+__license__ = 'GPL v3'
+__copyright__ = '2020, Darko Miletic '
+
+'''
+www.eldiplo.org
+'''
+
+from calibre.web.feeds.news import BasicNewsRecipe
from calibre.ptempfile import PersistentTemporaryFile
-from calibre.utils.magick import Image
-class ElDiplo_Recipe(BasicNewsRecipe):
- title = u'El Diplo'
- __author__ = 'Tomas Di Domenico'
- description = 'Publicacion mensual de Le Monde Diplomatique, edicion Argentina'
- language = 'es_AR'
- needs_subscription = True
- auto_cleanup = True
+class ElDiplo2020(BasicNewsRecipe):
+ title = 'Le Monde Diplomatique - cono sur'
+ __author__ = 'Darko Miletic'
+ description = 'Publicación de Le Monde Diplomatique para el cono sur.'
+ publisher = 'Le Monde Diplomatique'
+ category = 'news, politics, Argentina, Uruguay, Paraguay, South America, World'
+ oldest_article = 31
+ no_stylesheets = True
+ encoding = 'utf8'
+ use_embedded_content = False
+ language = 'es_AR'
+ remove_empty_feeds = True
+ publication_type = 'magazine'
+ auto_cleanup = True
+ delay = 1
+ simultaneous_downloads = 1
+ timeout = 8
+ needs_subscription = 'optional'
+ ignore_duplicate_articles = {'url'}
+ articles_are_obfuscated = True
+ temp_files = []
+ fetch_retries = 10
+ handle_gzip = True
+ compress_news_images = True
+ scale_news_images_to_device = True
+ masthead_url = 'https://www.eldiplo.org/wp-content/themes/eldiplo/img/logo.png'
+ INDEX = 'https://www.eldiplo.org/'
- def get_cover(self, url):
- tmp_cover = PersistentTemporaryFile(suffix=".jpg", prefix="eldiplo_")
- self.cover_url = tmp_cover.name
+ extra_css = """
+ body{font-family: Roboto, sans-serif}
+ .entry-title{font-family: Spectral, serif}
+ """
- with closing(self.browser.open(url)) as r:
- imgdata = r.read()
-
- img = Image()
- img.load(imgdata)
- img.crop(img.size[0], img.size[1] / 2, 0, 0)
-
- img.save(tmp_cover.name)
+ conversion_options = {
+ 'comment': description, 'tags': category, 'publisher': publisher, 'language': language
+ }
def get_browser(self):
br = BasicNewsRecipe.get_browser(self)
+ br.open(self.INDEX)
if self.username is not None and self.password is not None:
- br.open('http://www.eldiplo.org/index.php/login/-/do_login/index.html')
- br.select_form(nr=3)
- br['uName'] = self.username
- br['uPassword'] = self.password
+ br.select_form(id='loginform')
+ br['log'] = self.username
+ br['pwd'] = self.password
br.submit()
- self.browser = br
return br
def parse_index(self):
- default_sect = 'General'
- articles = {default_sect: []}
- ans = [default_sect]
- sectionsmarker = 'DOSSIER_TITLE: '
- sectionsre = re.compile('^' + sectionsmarker)
+ articles = []
+ soup = self.index_to_soup(self.INDEX)
+ mylink = soup.find('a', {'class':'edicion_cover'})
+ if mylink is None:
+ return None
+ self.cover_url = mylink.img['src']
+ indexurl = mylink['href']
+ self.log(indexurl)
+ parts = indexurl.split('www.eldiplo.org/', 1)
+ series = parts[1].split('-', 1)[0]
+ self.conversion_options.update({'series' : self.title})
+ self.conversion_options.update({'series_index' : series})
+ soupindex = self.index_to_soup(indexurl)
+ totalfeeds = []
+ articles = []
+ for article in soupindex.findAll('a', href=True, attrs={'class':'title'}):
+ url = article['href']
+ title = self.tag_to_string(article)
+ articles.append({'title': title, 'url': url, 'description': '', 'date': ''})
+ self.log('title: ', title, ' url: ', url)
+ totalfeeds.append(('Articles',articles))
+ return totalfeeds
- soup = self.index_to_soup('http://www.eldiplo.org/index.php')
-
- coverdivs = soup.findAll(True, attrs={'id': ['lmd-foto']})
- a = coverdivs[0].find('a', href=True)
- coverurl = a['href'].split("?imagen=")[1]
- self.get_cover(coverurl)
-
- thedivs = soup.findAll(True, attrs={'class': ['lmd-leermas']})
- for div in thedivs:
- a = div.find('a', href=True)
- if 'Sumario completo' in self.tag_to_string(a, use_alt=True):
- summaryurl = re.sub(r'\?.*', '', a['href'])
- summaryurl = 'http://www.eldiplo.org' + summaryurl
-
- for pagenum in range(1, 10):
- soup = self.index_to_soup(
- '{0}/?cms1_paging_p_b32={1}'.format(summaryurl, pagenum))
- thedivs = soup.findAll(True, attrs={'class': ['interna']})
-
- if len(thedivs) == 0:
- break
-
- for div in thedivs:
- section = div.find(True, text=sectionsre).replace(
- sectionsmarker, '')
- if section == '':
- section = default_sect
-
- if section not in articles.keys():
- articles[section] = []
- ans.append(section)
-
- nota = div.find(
- True, attrs={'class': ['lmd-pl-titulo-nota-dossier']})
- a = nota.find('a', href=True)
- if not a:
- continue
-
- url = re.sub(r'\?.*', '', a['href'])
- url = 'http://www.eldiplo.org' + url
- title = self.tag_to_string(a, use_alt=True).strip()
-
- summary = div.find(
- True, attrs={'class': 'lmd-sumario-descript'}).find('p')
- if summary:
- description = self.tag_to_string(summary, use_alt=False)
-
- aut = div.find(True, attrs={'class': 'lmd-autor-sumario'})
- if aut:
- auth = self.tag_to_string(aut, use_alt=False).strip()
-
- if section not in articles: # noqa
- articles[section] = []
-
- articles[section].append(dict(
- title=title, author=auth, url=url, date=None, description=description, content=''))
-
- ans = [(s, articles[s]) for s in ans if s in articles]
- return ans
+ def get_obfuscated_article(self, url):
+ result = None
+ count = 0
+ while (count < self.fetch_retries):
+ try:
+ response = self.browser.open(url, timeout=self.timeout)
+ html = response.read()
+ count = self.fetch_retries
+ tfile = PersistentTemporaryFile('_fa.html')
+ tfile.write(html)
+ tfile.close()
+ self.temp_files.append(tfile)
+ result = tfile.name
+ except:
+ self.info("Retrying download...")
+ count += 1
+ return result
diff --git a/recipes/icons/el_diplo.png b/recipes/icons/el_diplo.png
new file mode 100644
index 0000000000..0092c83a28
Binary files /dev/null and b/recipes/icons/el_diplo.png differ