Graphing Your Favorite Feeds with NetNewsWire and Ruby

January 6th, 2009  |  Published in ruby  |  2 Comments

After the election, my list of feeds in NetNewsWire became the source of some consternation. I’m still not completely recovered from the “must … know” paranoia that grips me, so I’m loath to unsubscribe to the political stuff: What if the world starts to end? How will I know?

The holidays are over, though, and it’s time to quit indulging in a lot of distractions. So how to figure out what I ought to get rid of in my feed reader? I don’t always pay a lot of attention to what I’m reading the most, so I could end up dropping something that’s more interesting to me than I realized. And there’s always the chance that there’s something I don’t really need to be following that I’m reading too much without realizing.

I thought about how much I like Google Reader’s attention tracking, which would help solve this sort of question pretty quickly. NetNewsWire also tracks attention information, providing a way to sort feeds if you go to View -> Sort Subscriptions By ... and selecting “Attention.”

At some point NetNewsWire started including the calculated attention score in its AppleScript dictionary. The definition for it is:

“The calculated attention score for this subscription, based on clicks and actions (such as posting to weblog, posting to del.icio.us, etc.). For groups it is the average of the subscription inside the group.”

It was pretty easy to get a list of attention scores out of NNW using ruby and rb-appscript:

#!/usr/bin/ruby 

require 'rubygems'
require 'appscript'
include Appscript

nnw = app("NetNewsWire")
subs = nnw.subscriptions.get
subs.reject!{|s| s.is_group.get != false} # get rid of folders
subs.sort!{ |a,b| b.calculated_attention_score.get <=> a.calculated_attention_score.get}
top = subs[0,25] #get the top n subscriptions

subs.each do |s| 
  puts "#{s.display_name.get} - #{s.calculated_attention_score.get}"
end

So there’s my list, sorted by how much attention I’m giving each feed.

For the database project I’m working on over in Rails, it would be helpful to do some graphing so I used this little excursion as an excuse to test a few gems for that sort of thing. Ultimately, I landed on scruffy, which does all sorts of pretty things, but also just squirts out pie charts like some sort of Swanson’s pot-pie factory.

Here’s the scruffy-fied version of that script, limiting the results to the top 10 feeds in NNW:

    #!/usr/bin/ruby 

    require 'rubygems'
    require 'appscript'
    require 'scruffy'
    include Appscript

    # Set up the graph
    graph = Scruffy::Graph.new
    graph.title = "NNW Attention Scores"
    graph.renderer = Scruffy::Renderers::Pie.new


    nnw = app("NetNewsWire")
    subs = nnw.subscriptions.get
    subs.reject!{|s| s.is_group.get != false} # get rid of folders
    subs.sort!{ |a,b| b.calculated_attention_score.get <=> a.calculated_attention_score.get}
    top = subs[0,9] #get the top n subscriptions

    scores = {}

    top.each do |s| 
      name = s.display_name.get
      score = s.calculated_attention_score.get
      title = name + " (#{score})" # get the attention score into the graph legend
      scores[title] = score
    end



    graph.add :pie, '', scores
    graph.render  :to => "nnw_attention.png",
                  :as => 'png',
                

    

And here’s the pretty pie chart it produces:

NetNewsWire attention chart

Infolicious!

For the record, I think I’m going to mix deletions up with changing the update intervals. I can’t believe the time I’ve wasted on MacWorld, and I think I can get more fiber from Talking Points Memo than I can Andrew Sullivan. I’m torn about MacUpdate. I rationalize keeping it around so I can stay current on security and bug fixes, but I have very few apps that don’t utilize Sparkle or their own update framework, which means MacUpdate is more of a distracting parade of new crap I can futz with.

Responses

  1. Dumping Your Safari History With Ruby (Apple’s Curious Epoch) :: dot unplanned says:

    January 7th, 2009 at 11:29 am (#)

    [...] So all that’s the nub of a further exploration of what’s getting my attentional resources. [...]

  2. blog.mignault.net » Blog Archive » Applescript made sane says:

    January 7th, 2009 at 2:24 pm (#)

    [...] Graphing Your Favorite Feeds with NetNewsWire and Ruby :: dot unplanned: After the election, my list of feeds in NetNewsWire became the source of some consternation. I’m still not completely recovered from the “must … know” paranoia that grips me, so I’m loath to unsubscribe to the political stuff: What if the world starts to end? How will I know? [...]

Leave a Response

This work by Michael Hall is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States license.