mirror of
https://github.com/streamwall/streamwall.git
synced 2026-01-30 08:52:49 -05:00
Make data source refresh interval configurable
This commit is contained in:
@@ -27,6 +27,9 @@ username = "woke"
|
|||||||
password = "woke"
|
password = "woke"
|
||||||
|
|
||||||
[data]
|
[data]
|
||||||
|
# Interval to refresh polled datasources
|
||||||
|
#interval = 30
|
||||||
|
|
||||||
# By default, we use the woke.net streams data source.
|
# By default, we use the woke.net streams data source.
|
||||||
# You can add other URLs to fetch here:
|
# You can add other URLs to fetch here:
|
||||||
json-url = ["https://woke.net/api/streams.json"]
|
json-url = ["https://woke.net/api/streams.json"]
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ function filterLive(data) {
|
|||||||
return data.filter(({ status }) => status === 'Live' || status === 'Unknown')
|
return data.filter(({ status }) => status === 'Live' || status === 'Unknown')
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function* pollDataURL(url) {
|
export async function* pollDataURL(url, intervalSecs) {
|
||||||
const refreshInterval = 5 * 1000
|
const refreshInterval = intervalSecs * 1000
|
||||||
let lastData = []
|
let lastData = []
|
||||||
while (true) {
|
while (true) {
|
||||||
let data = []
|
let data = []
|
||||||
|
|||||||
@@ -62,7 +62,12 @@ function parseArgs() {
|
|||||||
describe: 'Background color of wall (useful for chroma-keying)',
|
describe: 'Background color of wall (useful for chroma-keying)',
|
||||||
default: '#000',
|
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', {
|
.option('data.json-url', {
|
||||||
describe: 'Fetch streams from the specified URL(s)',
|
describe: 'Fetch streams from the specified URL(s)',
|
||||||
array: true,
|
array: true,
|
||||||
@@ -353,7 +358,7 @@ async function main() {
|
|||||||
|
|
||||||
const dataSources = [
|
const dataSources = [
|
||||||
...argv.data['json-url'].map((url) =>
|
...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) =>
|
...argv.data['toml-file'].map((path) =>
|
||||||
markDataSource(watchDataFile(path), 'toml-file'),
|
markDataSource(watchDataFile(path), 'toml-file'),
|
||||||
|
|||||||
Reference in New Issue
Block a user