# -*- coding: utf-8 -*-

from calibre.web.feeds.news import BasicNewsRecipe

class Haber7TS (BasicNewsRecipe):

    title               = u'H7 TÜMSPOR'
    __author__            = u'thomass'
    description            =  ' Haber 7 TÜMSPOR sitesinden tüm branşlarda spor haberleri '
    oldest_article         =2
    max_articles_per_feed  =100
    no_stylesheets         = True
    #delay                  = 1
    #use_embedded_content   = False
    encoding               = 'ISO 8859-9'
    publisher              = 'thomass'
    category               = 'güncel, haber, türkçe,spor,futbol'
    language               = 'tr'
    publication_type = 'newspaper'

    conversion_options = {
                            'tags'            : category
                            ,'language'        : language
                            ,'publisher'       : publisher
                            ,'linearize_tables': True
                         }
    extra_css              = '  #newsheadcon h1{font-weight: bold; font-size: 18px;color:#0000FF} '
    keep_only_tags    = [dict(name='div', attrs={'class':['intNews','leftmidmerge']})]
    remove_tags  = [dict(name='div', attrs={'id':['blocktitle','banner46860body']}),dict(name='div', attrs={'class':[ 'Breadcrumb','shr','mobile/home.jpg','etiket','yorumYazNew','shr','y-list','banner','lftBannerShowcase','comments','interNews','lftBanner','midblock','rightblock','comnum','commentcon',]}) ,dict(name='a', attrs={'class':['saveto','sendto','comlink','newsshare',]}),dict(name='iframe', attrs={'name':['frm111','frm107']}) ,dict(name='ul', attrs={'class':['nocPagi','leftmidmerge']})]
    cover_img_url = 'http://image.tumspor.com/v2/images/tasarim/images/logo.jpg'
    masthead_url = 'http://image.tumspor.com/v2/images/tasarim/images/logo.jpg'
    remove_empty_feeds= True

    feeds          = [
                      ( u'Futbol', u'http://open.dapper.net/services/h7tsfutbol'),
                      ( u'Basketbol', u'http://open.dapper.net/services/h7tsbasket'),
                      ( u'Tenis', u'http://open.dapper.net/services/h7tstenis'),
                      ( u'NBA', u'http://open.dapper.net/services/h7tsnba'),
                      ( u'Diğer Sporlar', u'http://open.dapper.net/services/h7tsdiger'),
                      ( u'Yazarlar & Magazin', u'http://open.dapper.net/services/h7tsyazarmagazin'),
                        ]
    def preprocess_html(self, soup):
         for alink in soup.findAll('a'):
            if alink.string is not None:
               tstr = alink.string
               alink.replaceWith(tstr)
         return soup
   # def print_version(self, url):
    # return url.replace('http://www.aksiyon.com.tr/aksiyon/newsDetail_getNewsById.action?load=detay&', 'http://www.aksiyon.com.tr/aksiyon/mobile_detailn.action?')

