mirror of
https://github.com/streamwall/streamwall.git
synced 2025-12-06 01:45:37 -05:00
Make data source refresh interval configurable
This commit is contained in:
@@ -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"]
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user