from calibre.web.feeds.news import BasicNewsRecipe


class NTVMSNBC(BasicNewsRecipe):
    title = u'NTV'
    __author__ = 'A Erdogan'
    description = 'News from Turkey'
    publisher = 'NTV'
    category = 'news, politics, Turkey'
    oldest_article = 7
    max_articles_per_feed = 100
    no_stylesheets = True
    use_embedded_content = False
    masthead_url = 'http://www.ntvmsnbc.com/images/MSNBC/msnbc_ban.gif'
    language = 'tr'

    remove_tags_before = dict(name='h1')
    remove_tags_after = dict(attrs={'id': 'haberDetayYazi'})
    extra_css             = '''
                        body{font-family:Arial,Helvetica,sans-serif; font-size:small; align:left;  color:#000000}
                        h1{font-size:large; color:#000000}
        h2{font-size:small; color:#000000}
        p{font-size:small; color:#000000}
                     '''

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

    remove_tags = [dict(name=['embed', 'il', 'ul', 'iframe', 'object', 'link', 'base']), dict(name='div', attrs={'style': ['padding: 0pt 10px 10px;']}), dict(name='div', attrs={'style': ['padding: 0pt 10px 10px;']}),  dict(name='div', attrs={  # noqa
        'class': ['textSmallGrey w320']}), dict(name='div', attrs={'style': ['font-family:Arial; font-size:16px;font-weight:bold; font-color:#003366; margin-bottom:20px; margin-top:20px; border-bottom:solid 1px;border-color: #CCC; padding-bottom:2px;']})]  # noqa
    remove_tags_before = dict(name='h1')
    remove_tags_after = dict(name='div', attrs={'style': [
                             'font-family:Arial; font-size:16px;font-weight:bold; font-color:#003366; margin-bottom:20px; margin-top:20px; border-bottom:solid 1px;border-color: #CCC; padding-bottom:2px;']})  # noqa

    feeds = [(u'NTV', u'http://www.ntvmsnbc.com/id/3032091/device/rss/rss.xml')]

    def print_version(self, url):
        articleid = url.rpartition('/id/')[2]
        return 'http://www.ntvmsnbc.com/id/' + articleid + '/print/1/displaymode/1098/'

    def preprocess_html(self, soup):
        return self.adeify_images(soup)
