Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/mrgnw/dlna-rs. Single-binary DLNA media server in Rust. Auto-discovered by VLC on Apple TV.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455export type Folder = { path: string; recursive: boolean; file_count: number };export type BrowseEntry = { name: string; is_dir: boolean };export type BrowseResp = { path: string; parent: string | null; entries: BrowseEntry[] };
export async function listFolders(): Promise<Folder[]> { const r = await fetch('/api/folders'); if (!r.ok) throw new Error(await r.text()); return r.json();}
export async function addFolder(path: string, recursive: boolean): Promise<Folder> { const r = await fetch('/api/folders', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ path, recursive }), }); if (!r.ok) throw new Error(await r.text()); return r.json();}
export async function removeFolder(path: string): Promise<void> { const r = await fetch('/api/folders', { method: 'DELETE', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ path }), }); if (!r.ok) throw new Error(await r.text());}
export async function refreshFolder(path: string): Promise<{ file_count: number }> { const r = await fetch('/api/folders/refresh', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ path }), }); if (!r.ok) throw new Error(await r.text()); return r.json();}
export async function browse(path?: string): Promise<BrowseResp> { const u = path ? `/api/browse?path=${encodeURIComponent(path)}` : '/api/browse'; const r = await fetch(u); if (!r.ok) throw new Error(await r.text()); return r.json();}
export type FileMeta = { rel: string; size: number };export type FilesResp = { folder: string; recursive: boolean; files: FileMeta[] };
export async function listFiles(folder: string): Promise<FilesResp> { const r = await fetch(`/api/files?path=${encodeURIComponent(folder)}`); if (!r.ok) throw new Error(await r.text()); return r.json();}