43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
/**
|
|
* Shared media API functions — identical across all MPR UI apps.
|
|
*/
|
|
|
|
import type { MediaAsset } from "../types/generated";
|
|
import { gql } from "./graphql";
|
|
|
|
/** Fetch all media assets. */
|
|
export async function getAssets(): Promise<MediaAsset[]> {
|
|
const data = await gql<{ assets: MediaAsset[] }>(`
|
|
query {
|
|
assets {
|
|
id filename file_path status error_message file_size duration
|
|
video_codec audio_codec width height framerate bitrate
|
|
properties comments tags created_at updated_at
|
|
}
|
|
}
|
|
`);
|
|
return data.assets;
|
|
}
|
|
|
|
/** Scan media/in/ folder for new files. */
|
|
export async function scanMediaFolder(): Promise<{
|
|
found: number;
|
|
registered: number;
|
|
skipped: number;
|
|
files: string[];
|
|
}> {
|
|
const data = await gql<{
|
|
scan_media_folder: {
|
|
found: number;
|
|
registered: number;
|
|
skipped: number;
|
|
files: string[];
|
|
};
|
|
}>(`
|
|
mutation {
|
|
scan_media_folder { found registered skipped files }
|
|
}
|
|
`);
|
|
return data.scan_media_folder;
|
|
}
|