from calibre.web.feeds.news import BasicNewsRecipe

class Ekot_SE(BasicNewsRecipe):
    title                 = 'Ekot'
    __author__            = 'Joakim Lindskog'
    description           = 'Nyheter fr\xc3\xa5n Ekot'
    publisher             = 'Ekot'
    category              = 'news, politics, Sweden'
    oldest_article        = 7
    delay                 = 1
    max_articles_per_feed = 100
    no_stylesheets        = True
    use_embedded_content  = False
    encoding              = 'utf-8'
    language              = 'sv'

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

    keep_only_tags = [dict(name='h1', attrs={'class':'newsH2'}),
                               dict(name='div', attrs={'class':'articleTop'}),
                               dict(name='div', attrs={'class':'newsIntro'}),
                               dict(name='div', attrs={'class':'newsText'})]
    remove_tags = [
                     dict(name=['object','link','base'])
                    ,dict(name='span',attrs={'class':'relLink'})
                  ]

    feeds          = [(u'Ekot', u'http://api.sr.se/api/rssfeed/rssfeed.aspx?rssfeed=83'),
                          (u'Utrikes', u'http://api.sr.se/api/rssfeed/rssfeed.aspx?rssfeed=3304'),
                          (u'Radiosporten', u'http://api.sr.se/api/rssfeed/rssfeed.aspx?rssfeed=179')]

    def print_version(self, url):
        return url.replace('http://sverigesradio.se/cgi-bin/ekot/artikel.asp',
                'http://sverigesradio.se/cgi-bin/isidorpub/PrinterFriendlyArticle.asp')+'&ProgramID=83'
