fix media workflows and download organization

This commit is contained in:
ShukeBta
2026-06-26 08:42:16 +08:00
parent 0da96f7e4e
commit 65adca04df
102 changed files with 4063 additions and 437 deletions
+28 -4
View File
@@ -17,6 +17,11 @@ export interface DiscoverItem extends Partial<Media> {
rating?: number
subscribe_keyword?: string
subscribe_aliases?: string[]
total_episodes?: number
downloaded_episodes?: number
local_media_count?: number
missing_episodes?: number[]
in_library?: boolean
}
export interface DiscoverSection {
@@ -25,6 +30,16 @@ export interface DiscoverSection {
provider?: string
}
export interface DiscoverFeedMeta {
page: number
has_next: boolean
}
export interface DiscoverFeedResult {
items: Record<string, DiscoverItem[]>
meta: Record<string, DiscoverFeedMeta>
}
// 后端在 TMDb 不可达 / API key 缺失时统一返回 { items: [], error: "..." }
// 200 状态码——前端必须能区分这两种情况,不能简单用 items.length === 0
// 推断"未配置 API key"。
@@ -46,10 +61,19 @@ export const discoverAPI = {
})),
sections: () =>
api.get<{ sections: DiscoverSection[] }>('/discover/sections').then((r) => r.data.sections),
feed: (sectionKeys: string[]) =>
feed: (sectionKeys: string[], page = 1): Promise<DiscoverFeedResult> =>
api
.get<Record<string, DiscoverItem[] | null>>('/discover/feed', {
params: { sections: sectionKeys.join(',') },
.get<Record<string, DiscoverItem[] | DiscoverFeedMeta | Record<string, DiscoverFeedMeta> | null>>('/discover/feed', {
params: { sections: sectionKeys.join(','), page },
})
.then((r) => r.data),
.then((r) => {
const raw = r.data
const meta = ((raw._meta as Record<string, DiscoverFeedMeta> | undefined) ?? {})
const items: Record<string, DiscoverItem[]> = {}
for (const key of sectionKeys) {
const row = raw[key]
items[key] = Array.isArray(row) ? row : []
}
return { items, meta }
}),
}