You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
889 B

# encoding: utf-8
"""
Simple script to display RSS/Atom feeds in tabulation separated values.
Values displayed are :
- last updated
- author(s) (comma separated)
- title
- link
"""
import argparse
import time
import feedparser
parser = argparse.ArgumentParser(description="Display RSS/Atom feeds in tabulation separated values.")
parser.add_argument("URL", type=str, help="URL to get feed from.")
parser.add_argument("-d", "--delay", type=int, help="Delay from when get last news (in minutes).", default=10)
args = parser.parse_args()
for entry in feedparser.parse(args.URL)["entries"]:
delay = (time.mktime(time.gmtime()) - time.mktime(entry["updated_parsed"])) / 60
if delay <= args.delay:
print("\t".join((
entry["updated"],
",".join([a["name"] for a in entry["authors"]]),
entry["title"],
entry["link"],
)))