#!/usr/bin/env  python

__license__   = 'GPL v3'
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
'''
www.thestar.com
'''

from calibre.web.feeds.news import BasicNewsRecipe

class TheTorontoStar(BasicNewsRecipe):
    title                 = 'The Toronto Star'
    __author__            = 'Darko Miletic'
    description           = "Canada's largest daily newspaper"
    oldest_article        = 2
    language              = 'en_CA'
    max_articles_per_feed = 100
    no_stylesheets        = True
    use_embedded_content  = False
    delay                 = 2
    publisher             = 'The Toronto Star'
    category              = "Toronto Star,Canada's largest daily newspaper,breaking news,classifieds,careers,GTA,Toronto Maple Leafs,sports,Toronto,news,editorial,The Star,Ontario,information,columnists,business,entertainment,births,deaths,automotive,rentals,weather,archives,Torstar,technology,Joseph Atkinson"
    encoding              = 'utf-8'

    conversion_options = {
                             'comments'    : description
                            ,'tags'        : category
                            ,'publisher'   : publisher
                         }

    keep_only_tags = [dict(name='div', attrs={'class':'ts-article'})]
    remove_tags_before = dict(name='div',attrs={'id':'ts-article_header'})

    feeds          = [
                        (u'News'         , u'http://www.thestar.com/rss/82672?'    )
                       ,(u'Opinion'     ,  u'http://www.thestar.com/rss/82863?'    )
                       ,(u'Business'     , u'http://www.thestar.com/rss/82796?'    )
                       ,(u'Sports'       , u'http://www.thestar.com/rss/82758?'    )
                       ,(u'Entertainment', u'http://www.thestar.com/rss/117741?'    )
                       ,(u'Living'       , u'http://www.thestar.com/rss/82839?'    )
                       ,(u'Travel'       , u'http://www.thestar.com/rss/82858?'              )
                       ,(u'Science'      , u'http://www.thestar.com/rss/82848?')
                     ]

    def print_version(self, url):
        artl = url.rpartition('--')[0]
        artid = artl.rpartition('/')[2]
        return 'http://www.thestar.com/printarticle/' + artid

