diff --git a/frontends/web-simple/src/lib/api.mjs b/frontends/web-simple/src/lib/api.mjs index d3532d5..9c6f34b 100644 --- a/frontends/web-simple/src/lib/api.mjs +++ b/frontends/web-simple/src/lib/api.mjs @@ -1,10 +1,16 @@ async function json(/** @type {string} */ url, /** @type {RequestInit | undefined} */ init) { - return await (await fetch(url, init)).json(); + const response = await (await fetch(url, init)).json(); + + if (response.data) { + return response.data; + } else { + throw response.error; + } } -export function listMedia(server) { - return json(server + '/media'); +export async function listMedia(server) { + return (await json(server + '/media')).list; } export function getMediaById(server, { mediaId }) { diff --git a/frontends/web-simple/src/routes/+page.server.js b/frontends/web-simple/src/routes/+page.server.js index a1339cd..10de7af 100644 --- a/frontends/web-simple/src/routes/+page.server.js +++ b/frontends/web-simple/src/routes/+page.server.js @@ -18,6 +18,7 @@ export async function load({ cookies, request }) { try { mediaList.push(...await API.listMedia(server)); } catch (e) { + console.error(e); errors.push(e.toString()); } } diff --git a/frontends/web-simple/src/routes/media/[mediaId]/+page.svelte b/frontends/web-simple/src/routes/media/[mediaId]/+page.svelte index 273c361..b272b07 100644 --- a/frontends/web-simple/src/routes/media/[mediaId]/+page.svelte +++ b/frontends/web-simple/src/routes/media/[mediaId]/+page.svelte @@ -35,36 +35,31 @@
Directors: | -- {data.media.info.people.directors.join(', ')} - | -Studios: | - {data.media.info.studios.join(', ')} - | -|
Writers: | -- {data.media.info.people.writers.join(', ')} + {data.media.info.studios.map((s) => s.name).join(', ')} | -Video: | +Directors: | - {data.media.files.streams.video.map((s) => s.name || s.codec).join(', ')} + {data.media.info.directors.map((p) => p.name).join(', ')} |
Starring: | - {data.media.info.people.actors.join(', ')} + {data.media.info.actors.map((p) => p.name).join(', ')} | - -Audio: | +Codecs: |
- {data.media.files.streams.audio.map((s) => s.name || s.codec).join(', ')}
+ {data.media.files.streams.video
+ .map((s) => s.name || s.codec.toUpperCase())
+ .join(', ')}
+ + {data.media.files.streams.audio + .map((s) => s.name || s.codec.toUpperCase()) + .join(', ')} |