__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 = u'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 = [(u'Headlines', u'http://www.standardmedia.co.ke/rss/headlines.php'),
             (u'Business', u'http://www.standardmedia.co.ke/rss/business.php'),
             (u'Politics', u'http://www.standardmedia.co.ke/rss/politics.php'),
             (u'Editorial', u'http://www.standardmedia.co.ke/rss/editorial.php'),
             (u'Columnists', u'http://www.standardmedia.co.ke/rss/columnists.php'),
             (u'Sports', u'http://www.standardmedia.co.ke/rss/sports.php'),
             (u'Entertainment', u'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('http://www.standardmedia.co.ke/.*InsidePage.php')
        return p.sub('http://www.standardmedia.co.ke/print.php', url)

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