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

from calibre.web.feeds.news import BasicNewsRecipe


class FE_India(BasicNewsRecipe):
    title = 'The Financial Express'
    __author__ = 'Darko Miletic'
    description = 'Financial news from India'
    publisher = 'The Indian Express Limited'
    category = 'news, politics, finances, India'
    oldest_article = 30
    max_articles_per_feed = 200
    no_stylesheets = True
    encoding = 'cp1252'
    use_embedded_content = False
    language = 'en_IN'
    remove_empty_feeds = True
    masthead_url = 'http://static.expressindia.com/frontend/fe/images/fe_logo.jpg'
    publication_type = 'magazine'
    extra_css = ' body{font-family: Arial,Helvetica,sans-serif } '

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

    keep_only_tags = [dict(attrs={'class': 'txt'})]
    remove_attributes = ['width', 'height']

    feeds = [(u'Articles', u'http://www.expressindia.com/syndications/fe.xml')]

    def print_version(self, url):
        article_raw = url.rpartition('/')[0]
        article_id = article_raw.rpartition('/')[2]
        return 'http://www.financialexpress.com/printer/news/' + article_id + '/'

    def preprocess_html(self, soup):
        for item in soup.findAll(style=True):
            del item['style']
        return soup
