f9410186b5014fd000f692212de03dd2ee6afe37
[kiosk.git] / wsj_rss_renderer.py
1 import generic_news_rss_renderer
2
3
4 class wsj_rss_renderer(generic_news_rss_renderer.generic_news_rss_renderer):
5     def __init__(self, name_to_timeout_dict, feed_site, feed_uris, page_title):
6         super(wsj_rss_renderer, self).__init__(
7             name_to_timeout_dict, feed_site, feed_uris, page_title
8         )
9         self.debug = 1
10
11     def debug_prefix(self):
12         return "wsj(%s)" % (self.page_title)
13
14     def get_headlines_page_prefix(self):
15         return "wsj-%s" % (self.page_title)
16
17     def get_details_page_prefix(self):
18         return "wsj-details-%s" % (self.page_title)
19
20     def find_image(self, item):
21         image = item.findtext("image")
22         if image is not None:
23             url = image.get("url")
24             return url
25         return None
26
27     def should_use_https(self):
28         return True
29
30     def item_is_interesting_for_headlines(self, title, description, item):
31         if self.is_item_older_than_n_days(item, 7):
32             self.debug_print("%s: is too old!" % title)
33             return False
34         return "WSJ.com" not in title and "WSJ.com" not in description
35
36     def item_is_interesting_for_article(self, title, description, item):
37         if self.is_item_older_than_n_days(item, 7):
38             self.debug_print("%s: is too old!" % title)
39             return False
40         return "WSJ.com" not in title and "WSJ.com" not in description
41
42
43 # Test
44 # x = wsj_rss_renderer(
45 #    {"Fetch News" : 1,
46 #     "Shuffle News" : 1},
47 #    "feeds.a.dj.com",
48 #    [ "/rss/RSSWorldNews.xml" ],
49 #    "Test" )
50 # if x.fetch_news() == 0:
51 #    print "Error fetching news, no items fetched."
52 # x.shuffle_news()