Cancel superseded Enigma2 startup and select programs throughout playback
This commit is contained in:
@ -1,5 +1,9 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const zapDelayValue = value => {
|
||||
const delay = Number(value ?? 1500);
|
||||
return Number.isFinite(delay) ? Math.max(0, Math.min(10000, Math.trunc(delay))) : 1500;
|
||||
};
|
||||
const { sources } = require('../db');
|
||||
const { getDb } = require('../db/sqlite');
|
||||
const xtreamApi = require('../services/xtreamApi');
|
||||
@ -73,7 +77,7 @@ router.post('/', async (req, res) => {
|
||||
return res.status(400).json({ error: 'Invalid source type' });
|
||||
}
|
||||
|
||||
const source = await sources.create({ type, name, url, username, password, zapBeforeStreaming: zapBeforeStreaming === true, zapDelay: parseInt(zapDelay) || 1500 });
|
||||
const source = await sources.create({ type, name, url, username, password, zapBeforeStreaming: zapBeforeStreaming === true, zapDelay: zapDelayValue(zapDelay) });
|
||||
// Trigger Sync
|
||||
syncService.syncSource(source.id).catch(console.error);
|
||||
res.status(201).json(source);
|
||||
@ -100,7 +104,7 @@ router.put('/:id', async (req, res) => {
|
||||
if (username !== undefined) updates.username = username;
|
||||
if (password !== undefined) updates.password = password;
|
||||
if (zapBeforeStreaming !== undefined) updates.zapBeforeStreaming = zapBeforeStreaming === true;
|
||||
if (zapDelay !== undefined) updates.zapDelay = parseInt(zapDelay) || 1500;
|
||||
if (zapDelay !== undefined) updates.zapDelay = zapDelayValue(zapDelay);
|
||||
const updated = await sources.update(req.params.id, updates);
|
||||
if (!updated) return res.status(404).json({ error: 'Source not found' });
|
||||
// Trigger Sync (if critical fields changed? safely just trigger it)
|
||||
|
||||
Reference in New Issue
Block a user