Created
August 14, 2008 21:04
-
-
Save jessehattabaugh/5493 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cron_refresh(){ | |
storage.feeds.sort(stale).limit(5).forEach(function(feed){ | |
var loadedFeed = loadFeed(feed.url) | |
// here would be a good place to update the rest of the feed's fields in case they've changed | |
var entries = loadedFeed.entries | |
var n=0 | |
for(var i=0; i<entries.length; i++){ | |
var someEntry = storage.entries.filter({feed:feed, title:entries[i].title}).first() | |
if(!someEntry) { | |
var published = parseDate(entries[i].publishedDate) | |
if(published > new Date()) published = new Date() | |
var data = { | |
feed:feed, | |
user:feed.user, | |
added: new Date(), | |
analyzed:false, | |
title:entries[i].title, | |
link:entries[i].link, | |
author:entries[i].author, | |
published:published, | |
content:entries[i].content, | |
summary:entries[i].contentSnippet | |
} | |
var entry = storage.entries.add(data) | |
n++ | |
} | |
} | |
feed.updated = new Date() | |
if(n) dlog.info("added "+n+" entries to "+feed.title) | |
//else dlog.info("no new entries found for "+feed.title) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment