3 import generic_news_rss_renderer
5 from typing import Dict, List, Optional
9 class cnn_rss_renderer(generic_news_rss_renderer.generic_news_rss_renderer):
12 name_to_timeout_dict: Dict[str, int],
17 super(cnn_rss_renderer, self).__init__(
18 name_to_timeout_dict, feed_site, feed_uris, page_title
22 def debug_prefix(self) -> str:
23 return f"cnn({self.page_title})"
25 def get_headlines_page_prefix(self) -> str:
26 return f"cnn-{self.page_title}"
28 def get_details_page_prefix(self) -> str:
29 return f"cnn-details-{self.page_title}"
31 def munge_description(self, description: str) -> str:
32 description = re.sub("[Rr]ead full story for latest details.", "", description)
33 description = re.sub("<[^>]+>", "", description)
36 def find_image(self, item: xml.etree.ElementTree.Element) -> Optional[str]:
37 image = item.findtext("media:thumbnail")
39 image_url = image.get("url")
43 def should_use_https(self) -> bool:
46 def item_is_interesting_for_headlines(
47 self, title: str, description: str, item: xml.etree.ElementTree.Element
49 if self.is_item_older_than_n_days(item, 14):
51 return re.search(r"[Cc][Nn][Nn][A-Za-z]*\.com", title) is None
53 def item_is_interesting_for_article(
54 self, title, description, item: xml.etree.ElementTree.Element
56 if self.is_item_older_than_n_days(item, 7):
59 re.search(r"[Cc][Nn][Nn][A-Za-z]*\.com", title) is None
60 and len(description) >= 65
65 # x = cnn_rss_renderer(
67 # "Shuffle News" : 1},
69 # [ "/rss/cnn_topstories.rss",
70 # "/rss/money_latest.rss",
71 # "/rss/cnn_tech.rss",
74 # if x.fetch_news() == 0:
75 # print("Error fetching news, no items fetched.")