lametric-rss-formatter
v2.0.0
Published
Reads RSS feed and formats it into LaMetric compatible JSON
Readme
lametric-rss-formatter
Converts RSS feed into format understood by LaMetric smart clock.
Installation
$ yarn add lametric-rss-formatterUsage
The library provides two functions, formatURL and formatString. First one
takes an URL, retrieves the feed from it and returns the RSS feed in LaMetric
compatible format. Other one takes an string as an argument from which the
contents of the RSS feed are read from and does the same thing.
On error situations (unable to parse the feed for example) an single LaMetric frame containing an error message is returned instead.
import express from "express";
import { formatURL } from "lametric-rss-formatter";
const app = express();
app.get("/", (req, res) =>
formatURL("https://feeds.yle.fi/uutiset/v1/recent.rss?publisherIds=YLE_NEWS")
.then((result) => res.send(result))
);Options
You can pass additional options to both format functions:
| Option | Default value | Description |
| ------ | ------------- | ------------------------------------------------------- |
| icon | nothing | Name of the LaMetric icon to display for each item. |
| max | 5 | Maximum number of entries to display from the RSS feed. |
For example:
import { formatString } from "lametric-rss-formatter";
const { frames } = await formatString("<?xml...", { max: 2 });