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


class SlovoRecipe(BasicNewsRecipe):
    __license__ = 'GPL v3'
    __author__ = 'Abelturd'
    language = 'sk'
    version = 1

    title = u'SLOVO'
    publisher = u''
    category = u'News, Newspaper'
    description = u'Politicko-spolo\u010densk\xfd t\xfd\u017edenn\xedk'
    encoding = 'Windows-1250'

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

    no_stylesheets = True
    remove_javascript = True

    feeds = []
    feeds.append((u'V\u0161etky \u010dl\xe1nky',
                  u'http://www.noveslovo.sk/rss.asp'))

    keep_only_tags = []
    remove_tags = []

    preprocess_regexps = [
        (re.compile(r'<img src="gif/image1.gif">', re.DOTALL | re.IGNORECASE),
         lambda match: ''),
    ]

    def print_version(self, url):
        m = re.search('(?<=id=)[0-9]*', url)

        return u'http://www.noveslovo.sk/clanoktlac.asp?id=' + str(m.group(0))
