fix(video-info): BangumiInfo supports sections

fix #5398
This commit is contained in:
WakelessSloth56 2025-10-19 19:06:24 +08:00
parent 5bf1ef1450
commit d94b85eceb
No known key found for this signature in database
GPG Key ID: A0564954AFEF3E8C

View File

@ -102,9 +102,18 @@ export interface EpisodeInfo {
skip: {
[x in 'ed' | 'op']: { start: number; end: number }
}
section: string
info?: VideoInfo
}
/**
* @author WakelessSloth56
*/
export interface SectionInfo {
title: string
episodes: EpisodeInfo[]
}
/**
* @author WakelessSloth56, LainIO24
*/
@ -127,8 +136,12 @@ export class BangumiInfo {
isFinish: boolean
isStarted: boolean
styles: string[]
/** 通过 {@link BangumiInfo.byEpisodeId()} 指定的 `epid` 对应的集,若通过 {@link BangumiInfo.bySeasonId()} 则不存在 */
episode?: EpisodeInfo
/** 包含正片及花絮、PV、番外等非正片内容 */
episodes: EpisodeInfo[]
/** 花絮、PV、番外等非正片内容 */
sections?: SectionInfo[]
/** @deprecated use {@link BangumiInfo.episodes} instead */
videos: {
title: string
@ -171,7 +184,23 @@ export class BangumiInfo {
this.isStarted = data.publish.is_started === 1
this.styles = data.styles
this.areas = data.areas
this.episodes = data.episodes.map(x => {
this.sections = data.section
const episodes = [
...data.episodes.map((ep: EpisodeInfo) => {
ep.section = data.positive.title
return ep
}),
...(data.section ?? [])
.flatMap((x: SectionInfo) => {
return x.episodes.map((ep: EpisodeInfo) => {
ep.section = x.title
return ep
})
})
// 有些内容例如次元发电机专访是链接cid、aid等为0
.filter(x => x.cid > 0),
]
this.episodes = episodes.map(x => {
const r: EpisodeInfo = {
aid: x.aid,
bvid: x.bvid,
@ -181,6 +210,7 @@ export class BangumiInfo {
cover: x.cover,
duration: x.duration / 1000,
skip: x.skip,
section: x.section,
}
if (r.epid === this.epid) {
this.episode = r