feeds/update.py: fix sources which have null description

This commit is contained in:
2024-09-10 20:30:29 +00:00
parent e7f54cda6b
commit 1c3c7f599f

View File

@@ -36,7 +36,7 @@ def clean_item(item: dict) -> dict:
"url", # used by <hosts/common/feeds.nix> (and many others) "url", # used by <hosts/common/feeds.nix> (and many others)
"velocity", # used by <hosts/common/feeds.nix> "velocity", # used by <hosts/common/feeds.nix>
# "version", # "version",
] ] and item[k] is not None
} }
# clean up characters for better printability # clean up characters for better printability
for k in "title", "site_name", "description": for k in "title", "site_name", "description":
@@ -89,13 +89,13 @@ def main():
serialized = [item.serialize() for item in items] serialized = [item.serialize() for item in items]
serialized = [clean_item(s) for s in serialized] serialized = [clean_item(s) for s in serialized]
for item in serialized: for item in serialized:
print(json.dumps(item, sort_keys=True, indent=2)) print(json.dumps(item, sort_keys=True, indent=2))
# save the best feed to disk # save the best feed to disk
keep = select_feed(serialized, prefer_podcast=prefer_podcast) keep = select_feed(serialized, prefer_podcast=prefer_podcast)
results = json.dumps(keep, sort_keys=True, indent=2) results = json.dumps(keep, sort_keys=True, indent=2)
with open(json_path, "w") as out: with open(json_path, "w") as out:
out.write(results) out.write(results)
if __name__ == '__main__': if __name__ == '__main__':
main() main()