mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-30 03:36:37 +08:00
25 lines
622 B
TypeScript
25 lines
622 B
TypeScript
import { api } from './client'
|
|
import { useAuthStore } from '../stores/auth'
|
|
|
|
export interface SubtitleTrack {
|
|
lang: string
|
|
label: string
|
|
path: string
|
|
url: string
|
|
codec: string
|
|
}
|
|
|
|
export const subtitlesAPI = {
|
|
list: (mediaId: string) =>
|
|
api
|
|
.get<{ tracks: SubtitleTrack[] | null }>(`/media/${mediaId}/subtitles`)
|
|
.then((r) => r.data.tracks ?? []),
|
|
|
|
url: (mediaId: string, path: string) => {
|
|
const token = useAuthStore.getState().token ?? ''
|
|
return `/api/subtitles/${encodeURIComponent(mediaId)}?path=${encodeURIComponent(
|
|
path,
|
|
)}&token=${encodeURIComponent(token)}`
|
|
},
|
|
}
|