a collection of programs that work
cooperatively.
-fh requires ruby and libfeedreader.
+fh requires ruby and python. (I'm porting
+it to python because of universal feed parser).
Quick usage guide
=================
# show feed-title,entry-title,entry-contents
import os
+import sys
import glob
import feedparser
-dir = glob.iglob(os.environ.get("HOME") + "/.fh/feeds/*")
+fetch_params = { "show-subtitle": 1, "show-titles": 1, "show-subtitles": 1, "show-content": 1, }
-for file in dir:
- feed = feedparser.parse(file)
- print feed.feed.subtitle
+# 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):
+ for item in sys.argv[i].strip(","):
+ fetch_params[item] = 1
- for e in feed.entries:
- print e.title
+def main():
+ for i in range(len(sys.argv[1:])):
+ if (sys.argv[i] == "from"):
+ pass
+
+ if (sys.argv[i] == "show"):
+ i += 1
+ parse_arg_list(sys.argv[i])
+
+
+ dir = glob.iglob(os.environ.get("HOME") + "/.fh/feeds/*")
+
+ for file in dir:
+ feed = feedparser.parse(file)
+ if fetch_params["show-subtitle"]:
+ print feed.feed.subtitle
+
+ for e in feed.entries:
+ if fetch_params["show-subtitles"]:
+ print e.title
+ print "\t"
+
+ if fetch_params["show-content"]:
+ if feed.feed.has_key("description"):
+ print e.description
+ elif feed.feed.has_key("content"):
+ print e.content
+ print "\t"
+
+ print "\n"
+if __name__ == "__main__":
+ main()
# fh-inc - get data from the feeds refered in ~/.fh/feedlist
require 'net/http'
-require 'feedparser'
require 'uri'
fd = File.new(ENV["HOME"] + "/.fh/feedlist")
fd.each_line do |line|
line = line.chomp
- s = Net::HTTP::get URI::parse(line)
-
- # Each file is named according to the url of the feed.
- fname = line.gsub("http://", "")
- fname.gsub!("/", "-")
+ if line != ""
+ s = Net::HTTP::get URI::parse(line)
+
+ # Each file is named according to the url of the feed.
+ fname = line.gsub("http://", "")
+ fname.gsub!("/", "-")
- File.open(ENV["HOME"] + "/.fh/feeds/" + fname, "w+") do |ff|
- ff.write(s)
- end
+ File.open(ENV["HOME"] + "/.fh/feeds/" + fname, "w+") do |ff|
+ ff.write(s)
+ end
- counter += 1
+ counter += 1
+ end
end
print "Fetched ", counter, " feeds\n"