__license__   = 'GPL v3'
__copyright__ = '2009-2010, Darko Miletic <darko.miletic at gmail.com>'

'''
www.esquire.com
'''

from calibre.web.feeds.news import BasicNewsRecipe

class Esquire(BasicNewsRecipe):
    title                 = 'Esquire'
    __author__            = 'Darko Miletic'
    description           = 'Esquire: Man at His Best'
    publisher             = 'Hearst Communications, Inc.'
    category              = 'magazine, men, women we love, style, the guide, sex, screen'
    oldest_article        = 30
    max_articles_per_feed = 100
    no_stylesheets        = True
    encoding              = 'cp1250'
    use_embedded_content  = False
    language              = 'en'
    publication_type      = 'magazine'
    masthead_url          = 'http://www.esquire.com/cm/shared/site_images/print_this/esquire_logo.gif'

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

    keep_only_tags    = [dict(name='div', attrs={'id':['article_header','article_content']})]
    remove_tags       = [dict(name=['object','link','embed','iframe','base'])]
    remove_attributes = ['width','height']

    feeds = [
               (u'Style'    , u'http://www.esquire.com/style/rss/'    )
              ,(u'Women'    , u'http://www.esquire.com/women/rss/'    )
              ,(u'Features' , u'http://www.esquire.com/features/rss/' )
              ,(u'Fiction'  , u'http://www.esquire.com/fiction/rss/'  )
              ,(u'Frontpage', u'http://www.esquire.com/rss/'          )
            ]

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