from calibre.web.feeds.recipes import BasicNewsRecipe

'''Calibre recipe to convert the RSS feeds of the Buchreport to an ebook.'''


class Buchreport(BasicNewsRecipe):
    __author__ = 'a.peter'
    __copyright__ = 'a.peter'
    __license__ = 'GPL v3'
    description = 'Buchreport'
    version = 4
    title = u'Buchreport'
    timefmt = ' [%d.%m.%Y]'
    encoding = 'cp1252'
    language = 'de'

    extra_css = 'body  { margin-left: 0.00em; margin-right: 0.00em; } \
                     article, articledate, articledescription { text-align: left; } \
                     h1 { text-align: left; font-size: 140%; font-weight: bold; } \
                     h2 { text-align: left; font-size: 100%; font-weight: bold; font-style: italic; } \
                     h3 { text-align: left; font-size: 100%; font-weight: regular; font-style: italic; } \
                     h4, h5, h6 { text-align: left; font-size: 100%; font-weight: bold; }'

    oldest_article = 7.0
    no_stylesheets = True
    remove_javascript = True
    use_embedded_content = False
    publication_type = 'newspaper'

    remove_tags_before = dict(name='h2')
    remove_tags_after = [
        dict(name='div', attrs={'style': ["padding-top:10px;clear:both"]})
    ]
    remove_tags = [
        dict(name='div', attrs={'style': ["padding-top:10px;clear:both"]}),
        dict(name='iframe'),
        dict(name='img')
    ]

    feeds = [
        (u'Buchreport', u'http://www.buchreport.de/index.php?id=5&type=100')
    ]

    def get_masthead_url(self):
        return 'http://www.buchreport.de/fileadmin/template/img/buchreport_logo.jpg'
