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],
18 name_to_timeout_dict, feed_site, feed_uris, page_title
21 def get_headlines_page_prefix(self) -> str:
22 return f"cnn-{self.page_title}"
24 def get_details_page_prefix(self) -> str:
25 return f"cnn-details-{self.page_title}"
27 def munge_description(self, description: str, item: xml.etree.ElementTree.Element) -> str:
28 description = re.sub("[Rr]ead full story for latest details.", "", description)
29 description = re.sub("<[^>]+>", "", description)
32 def find_image(self, item: xml.etree.ElementTree.Element) -> Optional[str]:
33 image = item.findtext("media:thumbnail")
35 image_url = image.get("url")
39 def should_use_https(self) -> bool:
42 def item_is_interesting_for_headlines(
43 self, title: str, description: str, item: xml.etree.ElementTree.Element
45 if self.is_item_older_than_n_days(item, 14):
47 return re.search(r"[Cc][Nn][Nn][A-Za-z]*\.com", title) is None
49 def item_is_interesting_for_article(
50 self, title, description, item: xml.etree.ElementTree.Element
52 if self.is_item_older_than_n_days(item, 7):
55 re.search(r"[Cc][Nn][Nn][A-Za-z]*\.com", title) is None
56 and len(description) >= 65
61 # x = cnn_rss_renderer(
63 # "Shuffle News" : 1},
65 # [ "/rss/cnn_topstories.rss",
66 # "/rss/money_latest.rss",
67 # "/rss/cnn_tech.rss",
70 # if x.fetch_news() == 0:
71 # print("Error fetching news, no items fetched.")