Last week I published the Hacker Top program and promised to explain how it was made. Before I do that, let me publish another similar program for Reddit. It’s the Reddit Top program.
As I mentioned in the Hacker Top post, Reddit is my favorite source for news because of the great programmer community it has. I actually unsubscribed from all the default subreddits (politics, pics, etc.) and subscribed to some 20 - 30 programming subreddits (like python, erlang, compsci and many others).
Reddit Top was actually derived from Hacker Top. Hacker Top was made in such a manner that it required me just to write a new parser for Reddit to create the new program. The program is written in Python programming language and uses ncurses interface for displaying the stories.
Download
Download link: reddit top program
Downloaded: 717 times
I’ll describe the process of creating the program in one of the next posts.
If you want to read about that, I suggest you subscribe to my rss feed.
Note - this program is released under GNU GPL.
How to run the program?
1) Make sure you are running a Unix type operating system.
2) Make sure you have Python installed. Any recent version will do.
3) Download and unpack the hacker top program archive.
$ wget 'http://www.catonmat.net/download/reddit-top.tgz' $ tar -xvzf reddit-top.tgz
4) Change to 'reddit-top' directory which was created by unpacking the archive.
$ cd reddit-top
5) Give the ‘reddit_top.py’ program execute permissions.
$ chmod u+x reddit_top.py
6) Run the reddit_top.py program.
$ ./reddit_top.py
(If that does not work out, try running 'python ./reddit_top.py')
Make sure that your terminal is at least 80 columns wide, otherwise the program won’t be able to display the results nicely.
Command Line Options
If you run the program with '--help' argument, it will display the possible command line options:
Usage: ./reddit_top.py [-h|--help] - displays this
Usage: ./reddit_top.py [-s|--subreddit subreddit]
[-i|--interval interval] [-n|--new]
[-u|--utf8 ]
As the help message suggests, the four main options are:
-
-s or –subreddit, which specifies the subreddit to monitor.
The default is reddit’s front page (http://www.reddit.com).
At the moment it is not possible to specify multiple subreddits. I’ll add the feature in the future. Here are a few examples of valid subreddits - ‘programming’, ‘wtf’, ‘python’, ‘politics’, and others. -
-i or –interval, which specifies refresh interval.
The default refresh interval is 1 minutes. Here are a few examples: 10s (10 seconds), 12m (12 minutes), 2h (2 hours). -
-u or –utf8, turns on utf8 output mode.
Default: off. Use this if you know for sure that your terminal supports it, otherwise you might get gibberish. -
-n or –new, which follows only the newest reddit stories on a given subreddit or front page.
Default: follow front page stories.
Keyboard Shortcuts
There are several keyboard shortcuts which you should know about when using the Reddit Top program:
- q - quits the program.
- u - forces an update of the news.
- up arrow/down arrow (or alternatively j/k keys) - scrolls the news list up or down.
- m - changes the display mode. There are 5 different display modes for your taste.
Enjoy the program! I’ll write some details how I created it in one of the next posts. Stay tuned - subscribe to my rss feed!
Download link: reddit top program
Downloaded: 717 times
The program is released under GNU General Public License.
Discuss it on catonmat forums!

(2 votes, average: 4.5 out of 5)
|
|
|


July 15th, 2008 at 12:18 am
This looks interesting.
At the moment, I view reddit using Gnus under Emacs. Gnus has the nnrss
backend for reading RSS feeds.
July 15th, 2008 at 2:36 am
How about enabling a method to pass the links to an external application.
July 15th, 2008 at 5:33 am
Works like gold on Debian Stable.
But yeah, adding a way to click on news-item would be great! 
July 15th, 2008 at 3:48 pm
Maybe have it open in links or lynx?
July 15th, 2008 at 5:48 pm
This is really cool!
Now we just need the equivalent for Twitter…
July 18th, 2008 at 4:22 pm
Geeky
July 18th, 2008 at 11:45 pm
How about if reddit produced a popup java console version for viewing their site in a more work-friendly way?
July 24th, 2008 at 7:41 am
[…] the last fortnight I have released two top-like applications to follow Reddit and Hacker News from the console. I received a few emails and comments asking me to explain how the […]
July 29th, 2008 at 4:11 am
Hey, nice script! I have one concern, though. When looking at “pyredditstories.py”, I noticed that you set the user-agent as this:
request.add_header(’User-Agent’, ‘Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)’)
First, I don’t really see the use in this, why would it matter to reddit what your user-agent is? Second, I find that it’s much more honest to use a useful user-agent. It lets a website/server owner contact you if they are having huge problems with your app, and there might be a design flaw.
Just thought I’d give a heads up!