mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-29 11:36:36 +08:00
97b3a7bd7f
Add account-level multi-line configuration for emby_remote mounts. Lines are stored in strm_accounts.config as a urls JSON array with backward compatibility for the legacy single url field. The backend automatically fails over to the next line on connection errors and persists the working active_line index. Frontend: multi-line editor on Emby mount page and STRM account dialog with add/remove/reorder, line names, and URL validation. Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: truewhile <truewhile@users.noreply.github.com>
32 lines
907 B
TypeScript
32 lines
907 B
TypeScript
export type EmbyRemoteLine = {
|
|
name: string
|
|
url: string
|
|
}
|
|
|
|
export function normalizeEmbyRemoteLines(lines: EmbyRemoteLine[]): EmbyRemoteLine[] {
|
|
return lines
|
|
.map((line) => ({
|
|
name: line.name.trim(),
|
|
url: line.url.trim().replace(/\/+$/, ''),
|
|
}))
|
|
.filter((line) => line.url.startsWith('http://') || line.url.startsWith('https://'))
|
|
}
|
|
|
|
export function encodeEmbyRemoteConfigLines(lines: EmbyRemoteLine[]): Record<string, string> {
|
|
const normalized = normalizeEmbyRemoteLines(lines)
|
|
if (normalized.length === 0) {
|
|
return {}
|
|
}
|
|
return {
|
|
urls: JSON.stringify(normalized),
|
|
url: normalized[0].url,
|
|
}
|
|
}
|
|
|
|
export function defaultEmbyRemoteLines(existing?: EmbyRemoteLine[]): EmbyRemoteLine[] {
|
|
if (existing && existing.length > 0) {
|
|
return existing.map((line) => ({ name: line.name ?? '', url: line.url ?? '' }))
|
|
}
|
|
return [{ name: '线路 1', url: '' }]
|
|
}
|