From d922fcbe586ab069eb93b6e3b2221beebcd74b48 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Tue, 8 Dec 2020 00:44:30 +0100 Subject: Add more entries in prss --- patternutils/commands/prss.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/patternutils/commands/prss.py b/patternutils/commands/prss.py index 95e6a3c..d23f67f 100644 --- a/patternutils/commands/prss.py +++ b/patternutils/commands/prss.py @@ -51,16 +51,19 @@ def prss( "feed_description": parsed_feed.feed.description, } - files = [f.name for f in walk(directory)] + direntries = [] + filenames = [] + + for f in walk(directory): + direntries.append(f) + filenames.append(f.name) matches = [] for entry in parsed_feed.entries: href = entry.enclosures[0]["href"] - splitted_href = href.split("/") - file_to_search = splitted_href[-1] try: @@ -69,14 +72,22 @@ def prss( click.secho(f"{file_to_search} not found!", fg="red", err=True) else: filename = files[file_index] + direntry = direntries[file_index] entry_values = { - "title": entry.title, - "link": entry.link, - "description": entry.description, - "id": entry.id, - "enclosure_href": entry.enclosures[0]["href"], + "title": entry.get("title", None), + "link": entry.get("link", None), + "description": entry.get("description", None), + "id": entry.get("id", None), + "enclosure_href": href, + "published": entry.get("published", None), + "subtitle": entry.get("subtitle", None), + "summary": entry.get("summary", None), + "author": entry.get("author", None), "_name": filename, - "_abspath": os.path.abspath(filename), + "_path": direntry.path, + "_abspath": os.path.abspath(direntry.path), + "_realpath": os.path.realpath(direntry.path), + "_relpath": os.path.relpath(direntry.path), } entry_values.update(default_values) matches.append(entry_values) -- cgit v1.3.1