Cleanup
[kiosk.git] / bellevue_reporter_rss_renderer.py
1 import generic_news_rss_renderer as gnrss
2 import re
3
4
5 class bellevue_reporter_rss_renderer(gnrss.generic_news_rss_renderer):
6     def __init__(self, name_to_timeout_dict, feed_site, feed_uris, page_title):
7         super(bellevue_reporter_rss_renderer, self).__init__(
8             name_to_timeout_dict, feed_site, feed_uris, page_title
9         )
10         self.debug = 1
11
12     def debug_prefix(self):
13         return "bellevue_reporter(%s)" % (self.page_title)
14
15     def get_headlines_page_prefix(self):
16         return "bellevue-reporter"
17
18     def get_details_page_prefix(self):
19         return "bellevue-reporter-details"
20
21     def should_use_https(self):
22         return True
23
24     def munge_description(self, description):
25         description = re.sub("<[^>]+>", "", description)
26         description = re.sub(
27             "Bellevue\s+Reporter\s+Bellevue\s+Reporter", "", description
28         )
29         description = re.sub("\s*\-\s*Your local homepage\.\s*", "", description)
30         return description
31
32     def item_is_interesting_for_headlines(self, title, description, item):
33         if self.is_item_older_than_n_days(item, 10):
34             self.debug_print("%s: is too old!" % title)
35             return False
36         if (
37             title.find("NFL") != -1
38             or re.search("[Ll]ive [Ss]tream", title) != None
39             or re.search("[Ll]ive[Ss]tream", title) != None
40             or re.search("[Ll]ive [Ss]tream", description) != None
41         ):
42             self.debug_print("%s: looks like it's about football." % title)
43             return False
44         return True
45
46     def item_is_interesting_for_article(self, title, description, item):
47         if self.is_item_older_than_n_days(item, 10):
48             self.debug_print("%s: is too old!" % title)
49             return False
50         if (
51             title.find(" NFL") != -1
52             or re.search("[Ll]ive [Ss]tream", title) != None
53             or re.search("[Ll]ive[Ss]tream", title) != None
54             or re.search("[Ll]ive [Ss]tream", description) != None
55         ):
56             self.debug_print("%s: looks like it's about football." % title)
57             return False
58         return True
59
60
61 # Test
62 # x = bellevue_reporter_rss_renderer(
63 #    {"Fetch News" : 1,
64 #     "Shuffle News" : 1},
65 #    "www.bellevuereporter.com",
66 #    [ "/feed/" ],
67 #    "Test" )
68 # d = """
69 # <DIV style="padding:8px;
70 #     font-size:44pt;
71 #     -webkit-column-break-inside:avoid;"><P>
72 # <B>Task force will tackle issues of racial justice, police reform</B>
73 # <BR>Bellevue Reporter
74 # Bellevue Reporter - Your local homepage.
75 # Inslee names civil rights activists, pastors, and cops to panel that may forge ideas f#or new laws Task force will tackle issues of racial justice, police reform
76 # Wire Service
77 # </DIV>"""
78 # d = x.munge_description(d)
79 # print d
80 # if x.fetch_news() == 0:
81 #    print "Error fetching news, no items fetched."
82 # x.shuffle_news()