#!/usr/bin/env python

__license__ = 'GPL v3'
__copyright__ = '2010, Tomasz Dlugosz <tomek3d@gmail.com>'
'''
rmf24.pl
'''

import re

from calibre.web.feeds.news import BasicNewsRecipe


class RMF24_ESKN(BasicNewsRecipe):
    title = 'Rmf24.pl - Ekonomia Sport Kultura Nauka'
    description = 'Ekonomia, sport, kultura i nauka ze strony rmf24.pl'
    language = 'pl'
    oldest_article = 7
    max_articles_per_feed = 100
    __author__ = 'Tomasz D\u0142ugosz'
    no_stylesheets = True
    remove_javascript = True

    feeds = [
        ('Ekonomia', 'http://www.rmf24.pl/ekonomia/feed'),
        ('Sport', 'http://www.rmf24.pl/sport/feed'),
        ('Kultura', 'http://www.rmf24.pl/kultura/feed'),
        ('Nauka', 'http://www.rmf24.pl/nauka/feed'),
    ]

    keep_only_tags = [dict(name='header', attrs={'class': 'article-header'}), dict(name='div', attrs={'class': 'article-container'})]

    remove_tags = [dict(name='div', attrs={'id': 'ReklamaMobile'}), dict(name='img', attrs={'class': 'img-responsive hidden-lg hidden-md hidden-sm'})]

    extra_css = '''
        h1 { font-size: 1.2em; }
        '''

    preprocess_regexps = [
        (re.compile(i[0], re.IGNORECASE | re.DOTALL), i[1])
        for i in [
            (r'<h2>Zdj.cie</h2>', lambda match: ''),
            (r'<a href="http://www.facebook.com/pages/RMF24pl/.*?>RMF24.pl</a> on Facebook</div>', lambda match: '</div>'),
        ]
    ]
