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

import re

from calibre.web.feeds.news import BasicNewsRecipe


class Information_dk(BasicNewsRecipe):
    title = 'Information - Denmark'
    __author__ = 'Darko Miletic'
    description = 'News from Denmark'
    publisher = 'information.dk'
    category = 'news, politics, Denmark'
    oldest_article = 2
    max_articles_per_feed = 100
    no_stylesheets = True
    remove_empty_feeds = True
    use_embedded_content = False
    encoding = 'utf8'
    language = 'da'

    conversion_options = {'comment': description, 'tags': category, 'publisher': publisher, 'language': language}

    feeds = [
        ('Nyheder', 'https://www.information.dk/feed'),
        ('Politik', 'https://www.information.dk/emne/politik/feed'),
        ('Indland', 'https://www.information.dk/indland/feed'),
        ('Udland', 'https://www.information.dk/udland/feed'),
        ('Debat', 'https://www.information.dk/debat/feed'),
        ('Kunst og kultur', 'https://www.information.dk/kultur/feed'),
        ('Literatur', 'https://www.information.dk/litteratur/feed'),
        ('Film', 'https://www.information.dk/emne/film/feed'),
        ('Kunst', 'https://www.information.dk/emne/kunst/feed'),
    ]

    keep_only_tags = [dict(name='article', attrs={}), dict(name='div', attrs={'class': 'field-name-body'})]
    remove_tags_before = dict(name='h1', attrs={'class': 'print-title'})
    remove_tags_after = dict(name='div', attrs={'class': 'print-footer'})

    field_name_best_from_inf = '^.*?field-name-best-from-inf.*?$'
    related_stuff = '^.*?related-stuff.*?$'
    view_iv_seneste = '^.*?view-iv-seneste.*?$'
    view_iv_news_queue = '^.*?view-iv-news-queue.*?$'
    view_footer = '^.*?view-footer.*?$'
    field_name_recommendations = '^.*?field-name-recommendations.*?$'
    field_name_comments_label = '^.*?field-name-comments-label.*?$'
    field_name_no_comments = '^.?field-name-no-comments.*?$'
    comment = '^.*?comment.*?$'

    remove_tags = [
        dict(name=['object', 'link']),
        dict(name='div', attrs={'id': 'node-article-full-group-date'}),
        dict(name='div', attrs={'id': 'node-article-full-group-right'}),
        dict(name='div', attrs={'id': 'node-article-non-subscriber-full-group-date'}),
        dict(name='div', attrs={'id': 'node-article-non-subscriber-full-group-right'}),
        dict(name='div', attrs={'class': re.compile(field_name_best_from_inf, re.IGNORECASE)}),
        dict(name='div', attrs={'class': re.compile(related_stuff, re.IGNORECASE)}),
        dict(name='div', attrs={'class': re.compile(view_iv_seneste, re.IGNORECASE)}),
        dict(name='div', attrs={'class': re.compile(view_iv_news_queue, re.IGNORECASE)}),
        dict(name='div', attrs={'class': re.compile(view_footer, re.IGNORECASE)}),
        dict(name='div', attrs={'class': re.compile(field_name_recommendations, re.IGNORECASE)}),
        dict(name='div', attrs={'class': re.compile(field_name_comments_label, re.IGNORECASE)}),
        dict(name='div', attrs={'class': re.compile(field_name_no_comments, re.IGNORECASE)}),
        dict(name='article', attrs={'class': re.compile(comment, re.IGNORECASE)}),
        dict(name='h2', attrs={'class': 'pane-title'}),
        dict(name='div', attrs={'id': 'comments'}),
    ]
