
__license__   = 'GPL v3'
__copyright__ = '2009-2010, Darko Miletic <darko.miletic at gmail.com>'
'''
azstarnet.com
'''
import urllib
from calibre.web.feeds.news import BasicNewsRecipe

class Azstarnet(BasicNewsRecipe):
    title                 = 'Arizona  Daily Star'
    __author__            = 'Darko Miletic'
    description           = 'news from Arizona'
    language              = 'en'
    publisher             = 'azstarnet.com'
    category              = 'news, politics, Arizona, USA'
    oldest_article        = 3
    max_articles_per_feed = 100
    no_stylesheets        = True
    use_embedded_content  = False
    encoding              = 'utf-8'
    masthead_url          = 'http://azstarnet.com/content/tncms/live/global/resources/images/logo.gif'
    needs_subscription    = True

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


    def get_browser(self):
        br = BasicNewsRecipe.get_browser(self)
        br.open('http://azstarnet.com/')
        if self.username is not None and self.password is not None:
            data = urllib.urlencode({ 'm':'login'
                                     ,'u':self.username
                                     ,'p':self.password
                                     ,'z':'http://azstarnet.com/'
                                   })
            br.open('http://azstarnet.com/app/registration/proxy.php',data)
        return br

    remove_tags = [dict(name=['object','link','iframe','base','img'])]


    feeds = [
               (u'Local News'    , u'http://azstarnet.com/search/?f=rss&t=article&c=news/local&l=25&s=start_time&sd=desc')
              ,(u'National News' , u'http://azstarnet.com/search/?f=rss&t=article&c=news/national&l=25&s=start_time&sd=desc')
              ,(u'World News'    , u'http://azstarnet.com/search/?f=rss&t=article&c=news/world&l=25&s=start_time&sd=desc')
              ,(u'Sports'        , u'http://azstarnet.com/search/?f=rss&t=article&c=sports&l=25&s=start_time&sd=desc')
              ,(u'Opinion'       , u'http://azstarnet.com/search/?f=rss&t=article&c=news/opinion&l=25&s=start_time&sd=desc')
              ,(u'Movies'        , u'http://azstarnet.com/search/?f=rss&t=article&c=entertainment/movies&l=25&s=start_time&sd=desc')
              ,(u'Food'          , u'http://azstarnet.com/search/?f=rss&t=article&c=lifestyles/food-and-cooking&l=25&s=start_time&sd=desc')
            ]

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

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

