from calibre.web.feeds.news import BasicNewsRecipe


class HindustanTimes(BasicNewsRecipe):
    title = u'Huffington Post UK'
    language = 'en_GB'
    __author__ = 'Krittika Goyal'
    oldest_article = 2  # days
    max_articles_per_feed = 25
    use_embedded_content = False

    no_stylesheets = True
    auto_cleanup = True
    auto_cleanup_keep = '//div[@class="articleBody"]'

    feeds = [
        ('UK Politics',
         'http://www.huffingtonpost.com/feeds/verticals/uk-politics/news.xml'),
        ('UK Entertainment',
         'http://www.huffingtonpost.com/feeds/verticals/uk-entertainment/news.xml'),
        ('UK Style',
         'http://www.huffingtonpost.com/feeds/verticals/uk-style/news.xml'),
        ('UK Fashion:',
         'http://www.huffingtonpost.com/feeds/verticals/uk-fashion/news.xml'),
        ('UK Universities:',
         'http://www.huffingtonpost.com/feeds/verticals/uk-universities-education/news.xml'),
        ('UK World',
         'http://www.huffingtonpost.com/feeds/verticals/uk-world/news.xml'),
        ('UK Lifestyle',
         'http://www.huffingtonpost.com/feeds/verticals/uk-lifestyle/news.xml'),
        ('UK Comedy',
         'http://www.huffingtonpost.com/feeds/verticals/uk-comedy/news.xml'),
        ('UK Celebrity',
         'http://www.huffingtonpost.com/feeds/verticals/uk-celebrity/news.xml'),
        ('UK Culture',
         'http://www.huffingtonpost.com/feeds/verticals/uk-culture/news.xml'),
        ('UK News',
         'http://www.huffingtonpost.com/feeds/verticals/uk/news.xml'),
        ('UK Tech',
         'http://www.huffingtonpost.com/feeds/verticals/uk-tech/news.xml'),
        ('UK Sport',
         'http://www.huffingtonpost.com/feeds/verticals/uk-sport/news.xml'),
    ]

    def get_article_url(self, entry):
        if entry.links:
            return entry.links[0]['href']
        return BasicNewsRecipe.get_article_url(self, entry)
