__license__ = 'GPL v3'
__copyright__ = '2011, Darko Miletic <darko.miletic at gmail.com>'
'''
www.athensnews.gr
'''

from calibre.web.feeds.news import BasicNewsRecipe


class AthensNews(BasicNewsRecipe):
    title = 'Athens News'
    __author__ = 'Darko Miletic'
    description = 'Greece in English since 1952'
    publisher = 'NEP Publishing Company SA'
    category = 'news, politics, Greece, Athens'
    oldest_article = 1
    max_articles_per_feed = 200
    no_stylesheets = True
    encoding = 'utf8'
    use_embedded_content = False
    language = 'en_GR'
    remove_empty_feeds = True
    publication_type = 'newspaper'
    masthead_url = 'http://www.athensnews.gr/sites/athensnews/themes/athensnewsv3/images/logo.jpg'
    extra_css             = """
                               body{font-family: Arial,Helvetica,sans-serif }
                               img{margin-bottom: 0.4em; display:block}
                               .big{font-size: xx-large; font-family: Georgia,serif}
                               .articlepubdate{font-size: small; color: gray; font-family: Georgia,serif}
                               .lezanta{font-size: x-small; font-weight: bold; text-align: left; margin-bottom: 1em; display: block}
                            """

    conversion_options = {
        'comment': description, 'tags': category, 'publisher': publisher, 'language': language, 'linearize_tables': True
    }

    remove_tags = [
        dict(name=['meta', 'link'])
    ]
    keep_only_tags = [
        dict(name='span', attrs={'class': 'big'}), dict(
            name='td', attrs={'class': ['articlepubdate', 'text']})
    ]
    remove_attributes = ['lang']

    feeds = [

    (u'News', u'http://www.athensnews.gr/category/1/feed'),
    (u'Politics', u'http://www.athensnews.gr/category/8/feed'),
    (u'Business', u'http://www.athensnews.gr/category/2/feed'),
    (u'Economy', u'http://www.athensnews.gr/category/11/feed'),
    (u'Community', u'http://www.athensnews.gr/category/5/feed'),
    (u'Arts', u'http://www.athensnews.gr/category/3/feed'),
    (u'Living in Athens', u'http://www.athensnews.gr/category/7/feed'),
    (u'Sports', u'http://www.athensnews.gr/category/4/feed'),
    (u'Travel', u'http://www.athensnews.gr/category/6/feed'),
    (u'Letters', u'http://www.athensnews.gr/category/44/feed'),
    (u'Media', u'http://www.athensnews.gr/multimedia/feed')
    ]

    def print_version(self, url):
        return url + '?action=print'

    def preprocess_html(self, soup):
        for item in soup.findAll(style=True):
            del item['style']
        return soup
