mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-29 03:26:37 +08:00
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
import { api, BATCH_REQUEST_TIMEOUT } from './client'
|
|
|
|
export type GenerateSTRMInput = {
|
|
library_id: string
|
|
output_dir?: string
|
|
base_url?: string
|
|
enabled?: boolean
|
|
overwrite?: boolean
|
|
include_local?: boolean
|
|
preserve_tree?: boolean
|
|
}
|
|
|
|
export type GenerateSTRMResult = {
|
|
library_id: string
|
|
output_dir: string
|
|
generated: number
|
|
updated: number
|
|
skipped: number
|
|
cleaned: number
|
|
errors?: string[]
|
|
items?: Array<{
|
|
media_id: string
|
|
title: string
|
|
file_path: string
|
|
url?: string
|
|
action: string
|
|
reason?: string
|
|
}>
|
|
}
|
|
|
|
export type GenerateSTRMTreeInput = {
|
|
provider: string
|
|
tree_text?: string
|
|
paths?: string[]
|
|
source_root?: string
|
|
output_prefix?: string
|
|
output_dir: string
|
|
base_url?: string
|
|
overwrite?: boolean
|
|
cleanup?: boolean
|
|
}
|
|
|
|
export const strmAPI = {
|
|
set: (mediaID: string, url: string) =>
|
|
api.put(`/media/${mediaID}/strm`, { url }).then((r) => r.data),
|
|
clear: (mediaID: string) => api.delete(`/media/${mediaID}/strm`).then((r) => r.data),
|
|
importURL: (libraryID: string, title: string, url: string) =>
|
|
api.post('/strm/import', { library_id: libraryID, title, url }).then((r) => r.data),
|
|
generate: (input: GenerateSTRMInput) =>
|
|
api
|
|
.post<GenerateSTRMResult>('/strm/generate', input, { timeout: BATCH_REQUEST_TIMEOUT })
|
|
.then((r) => r.data),
|
|
generateFromTree: (input: GenerateSTRMTreeInput) =>
|
|
api
|
|
.post<GenerateSTRMResult>('/strm/generate-from-tree', input, { timeout: BATCH_REQUEST_TIMEOUT })
|
|
.then((r) => r.data),
|
|
}
|