diff --git a/example.config.toml b/example.config.toml index 9aacd12..a29cd3e 100644 --- a/example.config.toml +++ b/example.config.toml @@ -27,6 +27,9 @@ username = "woke" password = "woke" [data] +# Interval to refresh polled datasources +#interval = 30 + # By default, we use the woke.net streams data source. # You can add other URLs to fetch here: json-url = ["https://woke.net/api/streams.json"] diff --git a/src/node/data.js b/src/node/data.js index 28f97b8..4d90b54 100644 --- a/src/node/data.js +++ b/src/node/data.js @@ -12,8 +12,8 @@ function filterLive(data) { return data.filter(({ status }) => status === 'Live' || status === 'Unknown') } -export async function* pollDataURL(url) { - const refreshInterval = 5 * 1000 +export async function* pollDataURL(url, intervalSecs) { + const refreshInterval = intervalSecs * 1000 let lastData = [] while (true) { let data = [] diff --git a/src/node/index.js b/src/node/index.js index 34b781d..4f18e9b 100644 --- a/src/node/index.js +++ b/src/node/index.js @@ -62,7 +62,12 @@ function parseArgs() { describe: 'Background color of wall (useful for chroma-keying)', default: '#000', }) - .group(['data.json-url', 'data.toml-file'], 'Datasources') + .group(['data.interval', 'data.json-url', 'data.toml-file'], 'Datasources') + .option('data.interval', { + describe: 'Interval (in seconds) for refreshing polled data sources', + number: true, + default: 30, + }) .option('data.json-url', { describe: 'Fetch streams from the specified URL(s)', array: true, @@ -353,7 +358,7 @@ async function main() { const dataSources = [ ...argv.data['json-url'].map((url) => - markDataSource(pollDataURL(url), 'json-url'), + markDataSource(pollDataURL(url, argv.data.interval), 'json-url'), ), ...argv.data['toml-file'].map((path) => markDataSource(watchDataFile(path), 'toml-file'),