From: khamidou Date: Sat, 31 Jan 2009 10:12:43 +0000 (+0100) Subject: changed a few things X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=e394c4da26d25cf626807f56301b9c7fcf72be8d;p=fh.git changed a few things --- diff --git a/fh-fetch.py b/fh-fetch.py index 4e89860..31552be 100644 --- a/fh-fetch.py +++ b/fh-fetch.py @@ -9,14 +9,22 @@ import sys import glob import feedparser -fetch_params = { "show-subtitle": 1, "show-titles": 1, "show-subtitles": 1, "show-content": 1, } +fetch_params = { "feed-title": 1, "feed-summary": 1, "feed-link": 1, "entry-title": 1, "entry-subtitle": 1, "entry-link": 1, "entry-content": 1, } + +sep = "" # the separator used to ...separate each entry of the feed +i = 0 # Parses a string of the form arg1,arg2,arg3 # If an element is present, put its value to one in fetch_params. def parse_arg_list(str): + fetch_params = {} for item in sys.argv[i].strip(","): fetch_params[item] = 1 +def print_field(field): + print field.encode("utf8").rstrip("\n") + print sep + def main(): for i in range(len(sys.argv[1:])): if (sys.argv[i] == "from"): @@ -31,20 +39,32 @@ def main(): for file in dir: feed = feedparser.parse(file) - if fetch_params["show-subtitle"]: - print feed.feed.subtitle + + if fetch_params["feed-title"]: + if feed.feed.has_key("title"): + print_field(feed.feed.subtitle) + + if fetch_params["feed-summary"]: + if feed.feed.has_key("sumary"): + print_field(feed.summary) + for e in feed.entries: - if fetch_params["show-subtitles"]: - print e.title - print "\t" - if fetch_params["show-content"]: + if fetch_params["entry-subtitle"]: + print_field(e.title) + + if fetch_params["entry-link"]: + if feed.feed.has_key("links"): + print_field(e.links[0]["href"]) + + if fetch_params["entry-subtitle"]: if feed.feed.has_key("description"): - print e.description - elif feed.feed.has_key("content"): - print e.content - print "\t" + print_field(e.description) + + if fetch_params["entry-content"]: + if feed.feed.has_key("content"): + print_field(e.content[0].value) print "\n" if __name__ == "__main__": diff --git a/fh-setup b/fh-setup index f2fb6b0..ead9a1b 100644 --- a/fh-setup +++ b/fh-setup @@ -1,5 +1,5 @@ #!/bin/sh -# Create the directories needed by fh. +# Create the directories needed by fh. It's there only for convenience purposes. mkdir ~/.fh touch ~/.fh/feedlist