#!/usr/pkg/bin/python3.13
# vim:fileencoding=utf-8
from __future__ import unicode_literals, division, absolute_import, print_function
from calibre.web.feeds.news import BasicNewsRecipe

__author__ = 'Ruben Scopacasa'
__license__ = 'GPL v3'
__copyright__ = '2019, Ruben Scopacasa <ruben.scopacasa at gmail.com>'
__version__ = 'v1.00'
__date__ = '22, April 2019'


class CorriereDellaSeraRecipe(BasicNewsRecipe):
    title = u'Il Corriere della sera'
    publisher = 'RCS Digital'
    category = 'News, politics, culture, economy, general interest'

    language = 'it'
    timefmt = '[%a, %d %b, %Y]'

    oldest_article = 3
    max_articles_per_feed = 100
    simultaneous_downloads = 5

    no_stylesheets = True
    remove_tags_before = dict(name='h1')
    remove_tags = [dict(id='gallery')]
    ignore_duplicate_articles = {'title', 'url'}

    feeds = [
        ('Homepage', 'http://xml2.corriereobjects.it/rss/homepage.xml'),
        ('Editoriali', 'http://xml2.corriereobjects.it/rss/editoriali.xml'),
        ('Cronache', 'http://xml2.corriereobjects.it/rss/cronache.xml'),
        ('Politica', 'http://xml2.corriereobjects.it/rss/politica.xml'),
        ('Esteri', 'http://xml2.corriereobjects.it/rss/esteri.xml'),
        ('Economia', 'http://xml2.corriereobjects.it/rss/economia.xml'),
        ('Cultura', 'http://xml2.corriereobjects.it/rss/cultura.xml'),
    ]

    def print_version(self, url):
        return url.replace('.shtml', '_print.html')

    def get_cover_url(self):
        return 'http://www.corriere.it/rss/images/logo_small.gif'
