from calibre.web.feeds.news import BasicNewsRecipe

class Filmweb_pl(BasicNewsRecipe):
    title          = u'FilmWeb'
    __author__        = 'fenuks'
    description   = 'FilmWeb - biggest polish movie site'
    cover_url      = 'http://userlogos.org/files/logos/crudus/filmweb.png'
    category       = 'movies'
    language       = 'pl'
    oldest_article = 8
    max_articles_per_feed = 100
    no_stylesheets= True
    extra_css      = '.hdrBig {font-size:22px;}'
    remove_tags= [dict(name='div', attrs={'class':['recommendOthers']}), dict(name='ul', attrs={'class':'fontSizeSet'})]
    keep_only_tags= [dict(name='h1', attrs={'class':'hdrBig'}), dict(name='div', attrs={'class':['newsInfo', 'reviewContent fontSizeCont description']})]
    feeds          = [(u'Wszystkie newsy', u'http://www.filmweb.pl/feed/news/latest'),
                         (u'News / Filmy w produkcji', 'http://www.filmweb.pl/feed/news/category/filminproduction'),
                         (u'News / Festiwale, nagrody i przeglądy', u'http://www.filmweb.pl/feed/news/category/festival'),
                         (u'News / Seriale', u'http://www.filmweb.pl/feed/news/category/serials'),
                         (u'News / Box office', u'http://www.filmweb.pl/feed/news/category/boxoffice'),
                         (u'News / Multimedia', u'http://www.filmweb.pl/feed/news/category/multimedia'),
                         (u'News / Dystrybucja dvd / blu-ray', u'http://www.filmweb.pl/feed/news/category/video'),
                         (u'News / Dystrybucja kinowa', u'http://www.filmweb.pl/feed/news/category/cinema'),
                         (u'News / off', u'http://www.filmweb.pl/feed/news/category/off'),
                         (u'News / Gry wideo', u'http://www.filmweb.pl/feed/news/category/game'),
                         (u'News / Organizacje branżowe', u'http://www.filmweb.pl/feed/news/category/organizations'),
                         (u'News / Internet', u'http://www.filmweb.pl/feed/news/category/internet'),
                         (u'News / Różne', u'http://www.filmweb.pl/feed/news/category/other'),
                         (u'News / Kino polskie', u'http://www.filmweb.pl/feed/news/category/polish.cinema'),
                         (u'News / Telewizja', u'http://www.filmweb.pl/feed/news/category/tv'),
                         (u'Recenzje redakcji', u'http://www.filmweb.pl/feed/reviews/latest'),
                         (u'Recenzje użytkowników', u'http://www.filmweb.pl/feed/user-reviews/latest')]

    def skip_ad_pages(self, soup):   
        skip_tag = soup.find('a', attrs={'class':'welcomeScreenButton'})
        if skip_tag is not None:
            self.log.warn('skip_tag')
            self.log.warn(skip_tag)
            return self.index_to_soup(skip_tag['href'], raw=True)
        
