Skip to content

Commit

Permalink
Add instagram
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Jan 24, 2016
1 parent dd597f1 commit c2c77cb
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions instagram.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package moul

import (
"github.com/SlyMarbo/rss"
"github.com/patrickmn/go-cache"
)

var instagramFeed *rss.Feed

func init() {
RegisterAction("instagram-activity", GetInstagramActivityAction)
}

func GetInstagramActivityAction(args []string) (interface{}, error) {
if activity, found := moulCache.Get("instagram-activity"); found {
return activity, nil
}
activity, err := GetInstagramActivity()
if err != nil {
return nil, err
}
moulCache.Set("instagram-activity", activity, cache.DefaultExpiration)
return activity, nil
}

func GetInstagramActivity() (*rss.Feed, error) {
var err error
if instagramFeed == nil {
instagramFeed, err = rss.Fetch("http://widget.websta.me/rss/n/m42am")
} else {
err = instagramFeed.Update()
}
return instagramFeed, err
}

0 comments on commit c2c77cb

Please sign in to comment.