from calibre.web.feeds.news import BasicNewsRecipe


class MyAppleRecipe(BasicNewsRecipe):
    __license__ = 'GPL v3'
    __author__ = 'Artur Stachecki <artur.stachecki@gmail.com>'
    language = 'pl'

    title = 'MyApple.pl'
    category = 'News'
    description = ' Największy w Polsce serwis zajmujący się tematyką związaną z Apple i wszelkimi produktami tej firmy.'
    cover_url = ''
    remove_empty_feeds = True
    oldest_article = 7
    max_articles_per_feed = 100000
    recursions = 0

    no_stylesheets = True
    remove_javascript = True
    simultaneous_downloads = 3

    keep_only_tags = [dict(name='article')]

    remove_tags = [dict(name='a', attrs={'class': 'twitter-follow-button'}), dict(name='ul', attrs={'class': 'list-inline text-muted small mb-0 mt-1'})]

    extra_css = '''
                    body {font-family: verdana, arial, helvetica, geneva, sans-serif ;}
                    td.contentheading{font-size: large; font-weight: bold;}
                    '''

    feeds = [
        ('Wpisy', 'https://myapple.pl/posts.atom'),
    ]

    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
