__license__ = 'GPL v3'
__copyright__ = '2011, Seongkyoun Yoo <seongkyoun.yoo at gmail.com>'
'''
Profile to download The Hankyoreh
'''
from calibre.web.feeds.news import BasicNewsRecipe


class Hankyoreh21(BasicNewsRecipe):
    title = u'Hankyoreh21'
    language = 'ko'
    description = u'The Hankyoreh21 Magazine articles'
    __author__ = 'Seongkyoun Yoo'
    oldest_article = 30
    max_articles_per_feed = 10
    no_stylesheets = True
    remove_javascript = True
    keep_only_tags = [
        dict(name='header', attrs={'class': ['article_head']}),
        dict(name='div', attrs={'class': ['article_body']}),
    ]
    remove_tags = [
        dict(name='div', attrs={'class': ['article_tools']}),
    ]

    feeds = [
        # ('전체기사',  'http://h21.hani.co.kr/rss/'),
        ('표지이야기', 'http://h21.hani.co.kr/rss/cover/'),
        ('특집',      'http://h21.hani.co.kr/rss/special/'),
        ('정치',      'http://h21.hani.co.kr/rss/politics/'),
        ('경제',      'http://h21.hani.co.kr/rss/economy/'),
        ('사회',      'http://h21.hani.co.kr/rss/society/'),
        ('세계',      'http://h21.hani.co.kr/rss/world/'),
        ('문화',      'http://h21.hani.co.kr/rss/culture/'),
    ]

    def get_article_url(self, article):
        org_url = BasicNewsRecipe.get_article_url(self, article)
        return "http://h21.hani.co.kr" + org_url if org_url[0] == '/' else org_url
