diff options
author | Andronaco Marco <marco.andronaco@olivetti.com> | 2023-07-13 11:10:38 +0200 |
---|---|---|
committer | Andronaco Marco <marco.andronaco@olivetti.com> | 2023-07-13 11:10:38 +0200 |
commit | 19ce085fa872db7f4f15e230524889ac5322f8a5 (patch) | |
tree | e5184f1116f118d64a7a2cd0e5d90497e214da49 /Overpost.py | |
parent | c4d85c371226380ae82f722938ca12eb5a528512 (diff) | |
download | sunstroke-19ce085fa872db7f4f15e230524889ac5322f8a5.tar.gz |
add custom resolver
Diffstat (limited to 'Overpost.py')
-rw-r--r-- | Overpost.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Overpost.py b/Overpost.py index cbea1ea..2448319 100644 --- a/Overpost.py +++ b/Overpost.py @@ -4,6 +4,7 @@ from re import compile import os import feedparser from dotenv import load_dotenv +from MyResolver import get load_dotenv() RSS_URL = os.getenv("RSS_URL") or os.path.join(".", "rss.xml") @@ -64,8 +65,14 @@ def parse_entry(entry): # entry = day dict_pop_first_n(links, int(N_LINKS_TO_REMOVE)) return (datetime.strptime(date, "%d.%m.%Y"), links) +def handle_url(url): + if url.startswith("http"): + return get(url) + else: + return url + def get_links(rss_url): - feed = feedparser.parse(rss_url) + feed = feedparser.parse(handle_url(rss_url)) return [ parse_entry(entry) for entry in feed.entries ] def get_newspaper(prefix="", index=0): |