#!/usr/bin/env python

__license__ = 'GPL v3'
__copyright__ = 'teepel'

from calibre.web.feeds.news import BasicNewsRecipe


class media2_pl(BasicNewsRecipe):
    title = 'Media2'
    __author__ = 'teepel <teepel44@gmail.com>'
    language = 'pl'
    description = 'Media2.pl to jeden z najczęściej odwiedzanych serwisów dla profesjonalistów z branży medialnej, telekomunikacyjnej, public relations oraz nowych technologii.'  # noqa: E501
    masthead_url = 'http://media2.pl/res/logo/www.png'
    cover_url = 'http://media2.pl/res/logo/www.png'
    INDEX = 'http://media2.pl'
    remove_empty_feeds = True
    oldest_article = 7
    max_articles_per_feed = 100
    remove_javascript = True
    no_stylesheets = True
    remove_attributes = ['style']
    ignore_duplicate_articles = {'title', 'url'}
    extra_css = '''.news-lead{font-weight: bold; }'''

    keep_only_tags = [dict(name='div', attrs={'class': 'news-item tpl-big'})]
    remove_tags = [
        dict(name='span', attrs={'class': 'news-comments'}),
        dict(name='div', attrs={'class': ['item-sidebar', 'news-inline-promo nobbtext']}),
        dict(name='div', attrs={'class': 'news-tags'}),
    ]

    feeds = [
        ('Media2', 'http://feeds.feedburner.com/media2'),
        ('Internet', 'http://feeds.feedburner.com/media2/internet'),
        ('Media', 'http://feeds.feedburner.com/media2/media'),
        ('Telekomunikacja', 'http://feeds.feedburner.com/media2/telekomunikacja'),
        ('Reklama/PR', 'http://feeds.feedburner.com/media2/reklama-pr'),
        ('Technologie', 'http://feeds.feedburner.com/media2/technologie'),
        ('Badania', 'http://feeds.feedburner.com/media2/badania'),
    ]

    def image_url_processor(self, baseurl, url):
        if url[0] == '/':
            url = self.INDEX + url
        return url
