
__license__   = 'GPL v3'
__copyright__ = '2008-2010, Darko Miletic <darko.miletic at gmail.com>'
'''
b92.net
'''
import re
from calibre.web.feeds.news import BasicNewsRecipe

class B92(BasicNewsRecipe):
    title                 = 'B92'
    __author__            = 'Darko Miletic'
    description           = 'B92 info, najnovije vesti iz Srbije, regiona i sveta'    
    publisher             = 'B92'
    category              = 'news, politics, Serbia'
    oldest_article        = 2
    max_articles_per_feed = 100
    no_stylesheets        = True
    use_embedded_content  = False
    encoding              = 'cp1250'
    language              = 'sr'
    publication_type      = 'newsportal'
    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')]
    
    keep_only_tags     = [dict(name='table', attrs={'class':'maindocument'})]

    remove_tags = [
                     dict(name='ul', attrs={'class':'comment-nav'})
                    ,dict(name=['embed','link','base']            )
                    ,dict(name='div', attrs={'class':'udokum'}    )
                  ]

    feeds          = [
                        (u'Vesti', u'http://www.b92.net/info/rss/vesti.xml')
                       ,(u'Biz'  , u'http://www.b92.net/info/rss/biz.xml'  )
                     ]

    def print_version(self, url):
        return url + '&version=print'

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

