Transform multiple rss/atom feed sources into one rss or atom feed. A node module.
JavaScript
Latest commit 986d6bb Jul 13, 2016 @AaronAcerboni Bump v number
Permalink
Failed to load latest commit information.
src Add missing files Jul 10, 2016
.gitignore Initial commit Jul 10, 2016
README.md Change typo Jul 12, 2016
example.config.json Add missing files Jul 10, 2016
feed-mixer.js Revise syntax error Jul 10, 2016
package.json Bump v number Jul 12, 2016

README.md

feed-mixer

feed-mixer is a module which transforms multiple rss/atom feeds into a single rss/atom feed.

It can be a single method use module or it can poll data every so often.

Here is an example of it being used in the context of a server.

npm install feed-mixer

usage

var FeedMixer = require('feed-mixer');

var mixer = new FeedMixer({
    "title": "My aggregate feed",
    "description": "This feed is made up of many.",
    "link": "http://example.com",
    "output": "rss-2.0",
    "feeds": [
        "https://www.youtube.com/feeds/videos.xml?user=vsauce",
        "https://twitrss.me/twitter_user_to_rss/?user=tweetsauce"
    ]
});

// Pattern A

mixer.refresh().then(function (feed) {
    require('fs').writeFileSync("output.rss", feed);
});

// OR Pattern B

mixer.on('refreshComplete', function (feed) {
    require('fs').writeFileSync("output.rss", feed);
});

mixer.refresh();

API

FeedMixer(config)

Returns a FeedMixer object

var mixer = new FeedMixer({
    "title": "My aggregate feed",
    "description": "This feed is made up of many.",
    "link": "http://example.com",
    "output": "rss-2.0",
    "update": "00:30:00",
    "feeds": [
        "https://www.youtube.com/feeds/videos.xml?user=vsauce",
        "https://twitrss.me/twitter_user_to_rss/?user=tweetsauce"
    ]
})

FeedMixer(configSource)

Returns a FeedMixer object with a config specified to JSON source.

var mixer = new FeedMixer('./config.json')

FeedMixer.refresh()

Returns a promise of which the callback argument is a string of the aggregate feed.

This function works by requesting all the feeds specified in the url and then aggregating them into one feed.

mixer.refresh().then(function (feed) {
    require('fs').writeFileSync('aggregate.rss', feed);
});

FeedMixer.aggregate

Returns a traversable object of the aggregate feed in the format of the feed module.

mixer.aggregate.length

FeedMixer.getFeed(feedFormatType)

Returns a string version of the aggregate feed.

feedFormatType is either "rss-2.0" or "atom-1.0". Defaults to the config output type.

var feedString = mixer.getFeed('atom-1.0');

FeedMixer.end()

FeedMixer.finish()

Stop the automatic polling/refreshing of the aggregate feed.

mixer.end();

config options

Config is either supplied in the constructor argument or as a resource string to a JSON file.

{
    name:        Your aggregate feed name
    description: Your aggregate feed description
    link:        Your aggregate feed url
    output:      Your aggregate feed in "rss-2.0" or "atom-1.0" format
    update:      (Optional) How often to refresh (hh:mm:ss format)
}

Events

FeedMixer.events.on('refreshStart')

Event called when the refresh() method is called. Argument passed is the Date of refresh.

mixer.events.on('refreshStart', function (when) {
    console.log('Started fetching/aggregating at ', when);
});

FeedMixer.events.on('refreshCompleted')

Event called when aggregate feed is ready and FeedMixer.aggregate property is updated.

Argument passed is the string of the aggregate feed in either the rss or atom format.

var latestFeedVersion;

mixer.events.on('refreshComplete', function (feed) {
    latestFeedVersion = feed;
});