<?xml version="1.0" encoding="UTF-8"?>
<plugin-url>
  <approved type="boolean">true</approved>
  <author>Highgroove Studios</author>
  <cached-tag-list>feedburner, blog, analytics, popularity</cached-tag-list>
  <canonical-name nil="true"></canonical-name>
  <code>require &quot;time&quot;

class Feedburner &lt; Scout::Plugin
  
  TEST_USAGE = &quot;#{File.basename($0)} feed FEED&quot;
  
  def require_libs
    require 'open-uri'
    require 'hpricot'
  end
  
  def run
    begin
      require_libs
    rescue LoadError
      begin
        require &quot;rubygems&quot;       
        require_libs
      rescue LoadError
        return { :error =&gt; { :subject =&gt; &quot;Couldn't load required libraries.&quot;,
                             :body    =&gt; &quot;Please see the required libaries in the README file&quot; } }
      end
    end
    
    # The following attributes are required:
    # - feed
    if [@options[&quot;feed&quot;]].map { |opt| opt.strip.length}.find { |v| v.zero? }
      return { :error =&gt; { :subject =&gt; &quot;The feed must be provided.&quot; } }
    end
    
    # grabs data from the current day
    data = get_data(@options[&quot;feed&quot;])
    { :report =&gt; data.merge({:scout_time =&gt; Time.parse(data['date'])}) }
  rescue
    { :error =&gt; {:subject =&gt; &quot;FeedBurner data could not be collected&quot;,
                 :body    =&gt; &quot;#{$!.message}\n\n#{$!.backtrace}&quot;}
    }
  end # run
  
  private
  
  # Returns a 2-element hash with the circulation and feed hits
  def get_data(feed)
    res = open(&quot;https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=#{feed}&quot;).read
    hp = Hpricot(res)
    if hp.at(&quot;rsp&quot;).attributes['stat'] == &quot;ok&quot;
      parse_feedburner(res)
    else
      err = hp.at(&quot;err&quot;).attributes[&quot;msg&quot;]
      raise &quot;Unable to get data: #{err}&quot;
    end
  end
  
  def parse_feedburner(data)
   doc = Hpricot.parse(data)
   result = {}

   entry = (doc/&quot;rsp/feed/entry&quot;).first

   result['date'] = entry.attributes['date']
   result['circulation'] = entry.attributes['circulation']
   result['hits'] = entry.attributes['hits']

   result
  end
    
end # Feedburner
</code>
  <created-at type="datetime">2007-12-29T11:37:40-08:00</created-at>
  <default-triggers type="yaml" nil="true"></default-triggers>
  <description>Returns the feed circulation and hits from yesterday for the given feed.
&lt;br/&gt;
*Requirements*

FeedBurner Account w/awareness turned on (http://feedburner.com)
&lt;br/&gt;
*Dependencies*

Requires the following libraries:

require 'open-uri'
require 'hpricot'
&lt;br/&gt;
Code (and inspiration) taken and updated from Burnalytics:
http://www.eribium.org/blog/?p=51</description>
  <featured type="boolean">false</featured>
  <id type="integer">7</id>
  <metadata type="yaml">--- |+
options:
  feed:
    name: Feed Name
    notes: The name of the feed. Awareness must be activated.

</metadata>
  <name>FeedBurner Stats</name>
  <plugins-count type="integer">1</plugins-count>
  <rating-avg type="decimal" nil="true"></rating-avg>
  <rating-count type="integer" nil="true"></rating-count>
  <rating-total type="integer" nil="true"></rating-total>
  <readme>Feedburner Plugin
======================
Created by [Highgroove Studios LLC](http://www.highgroove.com)

Returns the feed circulation and hits from yesterday for the given feed.

Dependencies
------------
Requires the [hpricot library](http://code.whytheluckystiff.net/hpricot/):

	sudo gem install hpricot

Compatibility 
-------------
Works fully on Linux and OSX. 

Requirements
------------
FeedBurner Account w/awareness turned on (http://feedburner.com)


Compatibility 
-------------
Works fully on Linux and OSX.

Thanks
------
Code (and inspiration) taken and updated from [Burnalytics](http://www.eribium.org/blog/?p=51)
</readme>
  <schema type="yaml" nil="true"></schema>
  <scout-version type="integer">1</scout-version>
  <short-description>Returns the feed circulation and hits from yesterday for the given feed. </short-description>
  <tested-platforms>linux macox</tested-platforms>
  <total-usage-count type="integer">0</total-usage-count>
  <updated-at type="datetime">2009-09-23T23:03:09-07:00</updated-at>
  <url>http://github.com/highgroove/scout-plugins/raw/7d13f07023d2d284fefceca078a86718e928f4d0/feedburner/feedburner.rb</url>
</plugin-url>
