Debian Codegraph @

recipes/variety.recipe

raw
1 __license__ = 'GPL v3'
2 __copyright__ = '2009-2012, Darko Miletic <darko.miletic at gmail.com>'
3 '''
4 www.variety.com
5 '''
6
7 from calibre.web.feeds.recipes import BasicNewsRecipe
8
9
10 class Variety(BasicNewsRecipe):
11 title = 'Variety'
12 __author__ = 'Darko Miletic'
13 description = 'Breaking entertainment movie news, movie reviews, entertainment industry events, news and reviews from Cannes, Oscars, and Hollywood awards. Featuring box office charts, archives and more.' # noqa: E501
14 oldest_article = 2
15 max_articles_per_feed = 100
16 no_stylesheets = True
17 use_embedded_content = False
18 encoding = 'utf8'
19 publisher = 'Red Business Information'
20 category = 'Entertainment Industry News, Daily Variety, Movie Reviews, TV, Awards, Oscars, Cannes, Box Office, Hollywood'
21 language = 'en'
22 masthead_url = 'http://images1.variety.com/graphics/variety/Variety_logo_green_tm.gif'
23 extra_css = '''
24 body{font-family: Arial,Helvetica,sans-serif; font-size: 1.275em}
25 .date{font-size: small; border: 1px dotted rgb(204, 204, 204); font-style: italic; color: rgb(102, 102, 102); margin: 5px 0px; padding: 0.5em;}
26 .author{margin: 5px 0px 5px 20px; padding: 0.5em; background: none repeat scroll 0% 0% rgb(247, 247, 247);}
27 .art h2{color: rgb(153, 0, 0); font-size: 1.275em; font-weight: bold;}
28 img{margin-bottom: 1em}
29 '''
30
31 conversion_options = {'comments': description, 'tags': category, 'language': language, 'publisher': publisher}
32
33 remove_tags = [dict(name=['object', 'link', 'map'])]
34 remove_attributes = ['lang', 'vspace', 'hspace', 'xmlns:ms', 'xmlns:dt']
35 keep_only_tags = [dict(name='div', attrs={'class': 'art control'})]
36
37 feeds = [('News & Articles', 'http://feeds.feedburner.com/variety/headlines')]
38
39 def print_version(self, url):
40 rpt = url.rpartition('.html')[0]
41 return rpt + '?printerfriendly=true'
42
43 def preprocess_raw_html(self, raw, url):
44 return '<html><head>' + raw[raw.find('</head>') :]
45
46 def get_article_url(self, article):
47 url = BasicNewsRecipe.get_article_url(self, article)
48 return url.rpartition('?')[0]
49
50 def preprocess_html(self, soup):
51 for item in soup.findAll('a'):
52 limg = item.find('img')
53 if item.string is not None:
54 str = item.string
55 item.replaceWith(str)
56 elif limg:
57 item.name = 'div'
58 item.attrs = []
59 else:
60 str = self.tag_to_string(item)
61 item.replaceWith(str)
62 for item in soup.findAll('img', alt=False):
63 item['alt'] = 'image'
64 return soup