__license__ = 'GPL v3'
__copyright__ = '2010, Hans Donner <hans.donner at pobox.com>'
'''
www.standardmedia.co.ke
'''

from calibre.web.feeds.news import BasicNewsRecipe


class StandardMediaKeRecipe(BasicNewsRecipe):
    __author__ = 'Hans Donner'

    title = 'The Standard'
    description = 'News from Kenia'
    language = 'en'
    country = 'KE'
    publication_type = 'newspaper'
    publisher = 'standardmedia.co.ke'
    category = 'news, politics, Kenia'

    masthead_url = 'http://www.standardmedia.co.ke/images/easLogoOther.gif'

    max_articles_per_feed = 200
    oldest_article = 3

    use_embedded_content = False
    remove_empty_feeds = True

    no_stylesheets = False

    feeds = [
        ('Headlines', 'http://www.standardmedia.co.ke/rss/headlines.php'),
        ('Business', 'http://www.standardmedia.co.ke/rss/business.php'),
        ('Politics', 'http://www.standardmedia.co.ke/rss/politics.php'),
        ('Editorial', 'http://www.standardmedia.co.ke/rss/editorial.php'),
        ('Columnists', 'http://www.standardmedia.co.ke/rss/columnists.php'),
        ('Sports', 'http://www.standardmedia.co.ke/rss/sports.php'),
        ('Entertainment', 'http://www.standardmedia.co.ke/rss/entertain.php'),
    ]

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

    def print_version(self, url):
        import re

        p = re.compile(r'http://www.standardmedia.co.ke/.*InsidePage.php')
        return p.sub(r'http://www.standardmedia.co.ke/print.php', url)

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