mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-30 19:46:38 +08:00
feat(emby): support multiple connection lines for remote mount (#9)
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>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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: '' }]
|
||||
}
|
||||
Reference in New Issue
Block a user