#!/usr/bin/env python
# vim:fileencoding=utf-8

__license__ = 'GPL v3'
__copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
'''
izvestia.ru
'''

from calibre.web.feeds.news import BasicNewsRecipe


class Izvestia(BasicNewsRecipe):
    title = 'Izvestia'
    __author__ = 'Darko Miletic (with fixes by bugmen00t)'
    description = 'News from Russia'
    publisher = 'Izvestia'
    category = 'news, politics, Russia'
    oldest_article = 5
    max_articles_per_feed = 100
    auto_cleanup = False
    no_stylesheets = True
    use_embedded_content = False
    language = 'ru'
    publication_type = 'newspaper'
    cover_url = u'https://cdn.iz.ru/profiles/portal/themes/purple/images/favicons/apple-icon-180x180.png'

    remove_tags_before = dict(name='div', attrs={'role': 'article'})

    remove_tags_after = dict(name='div', attrs={'role': 'article'})

    remove_tags = [
        dict(name='div', attrs={'class': 'article_page__left__top__views'}),
        dict(name='div', attrs={'class': 'hash_tags'}),
        dict(name='div', attrs={'class': 'get_yandex_subscription_links'}),
        dict(name='div', attrs={'class': 'article_buttons_block'}),
        dict(name='div', attrs={'class': 'rubrics_btn'}),
        dict(name='div', attrs={'class': 'hidden'}),
        dict(name='div', attrs={'class': 'share_bottom2'}),
        dict(name='div', attrs={'class': 'recommendation-block'}),
        dict(name='div', attrs={'class': 'plug-text'}),
        dict(name='div', attrs={'class': 'get_news_link'}),
        dict(name='div', attrs={'itemprop': 'address'})
    ]

    feeds = [(u'Новости', u'https://iz.ru/xml/rss/all.xml')]

    def preprocess_html(self, soup):
        for img in soup.findAll('img', attrs={'data-src': True}):
            img['src'] = img['data-src']
        return soup
