from calibre.web.feeds.news import BasicNewsRecipe


class PravdaSlovakiaRecipe(BasicNewsRecipe):
    __license__ = 'GPL v3'
    __author__ = 'kwetal'
    language = 'sk'
    version = 1

    title = 'Pravda'
    publisher = ''
    category = 'News, Newspaper'
    description = 'News from Slovakia'

    oldest_article = 1
    max_articles_per_feed = 100
    use_embedded_content = False
    remove_empty_feeds = True

    no_stylesheets = True
    remove_javascript = True

    # Feeds from: http://spravy.pravda.sk/info.asp?y=sk_kskop/rssinfo.htm
    feeds = []
    feeds.append(('Spravodajstvo', 'http://servis.pravda.sk/rss.asp'))
    feeds.append(('N\u00e1zory', 'http://servis.pravda.sk/rss.asp?o=sk_nazory'))
    feeds.append(('\u0160port', 'http://servis.pravda.sk/rss.asp?o=sk_sport'))
    feeds.append(('Peniaze', 'http://servis.pravda.sk/rss.asp?o=sk_peniaze'))
    feeds.append(('Koktail', 'http://servis.pravda.sk/rss.asp?o=sk_koktail'))
    feeds.append(('Kult\u00fara', 'http://servis.pravda.sk/rss.asp?o=sk_kultura'))
    feeds.append(('B\u00fdvanie', 'http://servis.pravda.sk/rss.asp?o=sk_byvanie'))
    feeds.append(('Veda a Technika', 'http://servis.pravda.sk/rss.asp?o=sk_veda'))
    feeds.append(('Mozgov\u00f1a', 'http://servis.pravda.sk/rss.asp?o=sk_mozgovna'))
    feeds.append(('Auto', 'http://servis.pravda.sk/rss.asp?o=sk_autoweb'))
    feeds.append(('Cestovanie', 'http://servis.pravda.sk/rss.asp?o=sk_cestovanie'))
    feeds.append(('Regi\u00f3ny', 'http://servis.pravda.sk/rss.asp?r=sk_regiony'))
    feeds.append(('Profesia', 'http://servis.pravda.sk/rss.asp?o=sk_profesia'))
    feeds.append(('Zdravie', 'http://servis.pravda.sk/rss.asp?o=sk_zdravie'))
    feeds.append(('\u010c\u00edtajme de\u0165om', 'http://servis.pravda.sk/rss.asp?o=sk_citajme'))

    remove_tags = []
    remove_tags.append(dict(name='p', attrs={'class': 'spatNaClanok'}))
    remove_tags.append(dict(name='ul'))

    extra_css = '''
                @font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)}
                @font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/LiberationSans.ttf)}
                body {font-family: sans1, serif1;}
                .art-info {font-size: x-small; color: #696969; margin-bottom: 0.3em;}
                .img-info {font-size: x-small; color: #696969;}
                '''

    def print_version(self, url):
        ignore, sep, main = url.rpartition('/')
        app, sep, id = main.rpartition('?')

        app = app.replace('.asp', '')

        return 'http://sport.pravda.sk/tlac.asp?r=' + app + '&' + id
