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

'''
24sata.rs
'''

import re
from calibre.web.feeds.recipes import BasicNewsRecipe

class Ser24Sata(BasicNewsRecipe):
    title                 = '24 Sata - Sr'
    __author__            = 'Darko Miletic'
    description           = '24 sata portal vesti iz Srbije'
    publisher             = 'Ringier d.o.o.'
    category              = 'news, politics, entertainment, Serbia'
    oldest_article        = 2
    max_articles_per_feed = 100
    no_stylesheets        = True
    encoding              = 'utf-8'
    use_embedded_content  = False
    language              = 'sr'
    publication_type      = 'newspaper'    
    extra_css             = '@font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)} body{font-family: serif1, serif} .article_description{font-family: serif1, serif}'

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

    preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')]

    feeds = [(u'Vesti Dana', u'http://www.24sata.rs/rss.php')]

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

    def print_version(self, url):
        article    = url.partition('#')[0]
        article_id = article.partition('id=')[2]
        return 'http://www.24sata.rs/_print.php?id=' + article_id

