From df1966826065f87b17da90f7cf6ec788a84999a2 Mon Sep 17 00:00:00 2001 From: knoflook Date: Fri, 28 Jan 2022 12:18:19 +0100 Subject: [PATCH 1/2] feat: remove local data for nonexisting feeds --- lumbunglib/feed.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lumbunglib/feed.py b/lumbunglib/feed.py index a68c550..32bbe90 100644 --- a/lumbunglib/feed.py +++ b/lumbunglib/feed.py @@ -194,13 +194,25 @@ def main(): if not os.path.exists(output_dir): os.makedirs(output_dir) + feed_dict = dict() + for url in feed_urls: + feed_name = urlparse(url).netloc + feed_dict[url] = feed_name + + feed_names = feed_dict.values() + content_dirs = os.listdir(output_dir) + for i in content_dirs: + if i not in feed_names: + shutil.rmtree(os.path.join(output_dir, i)) + print("%s not in feeds_list.txt, removing local data" %(i)) + # add iframe to the allowlist of feedparser's sanitizer, # this is now handled in parse_post() feedparser.sanitizer._HTMLSanitizer.acceptable_elements |= {"iframe"} for feed_url in feed_urls: - feed_name = urlparse(feed_url).netloc + feed_name = feed_dict[feed_url] feed_dir = os.path.join(output_dir, feed_name) From 2c5e94c26568cb3f5be5733fce8e47b2e336b243 Mon Sep 17 00:00:00 2001 From: knoflook Date: Fri, 28 Jan 2022 12:29:44 +0100 Subject: [PATCH 2/2] fix: don't expect title field for feeds --- lumbunglib/feed.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lumbunglib/feed.py b/lumbunglib/feed.py index 32bbe90..93ae387 100644 --- a/lumbunglib/feed.py +++ b/lumbunglib/feed.py @@ -60,6 +60,11 @@ def create_frontmatter(entry): else: author = "" + if "title" in entry: + title = entry.title + else: + title = "" + tags = [] if "tags" in entry: # TODO finish categories @@ -67,7 +72,7 @@ def create_frontmatter(entry): tags.append(t["term"]) frontmatter = { - "title": entry.title, + "title": title, "date": published.format(), "summary": "", "author": author,