import EventEmitter from "node:events"; import { BaseRequest } from "../base/index.js"; import Auth from "../base/Auth.js"; import type { MediaOptions, MediaPartOptions, DescV2 } from "../types/index.js"; import { MediaDetailReturnType, getArchivesReturnType, UploaderType, SubmitType, getSeasonListReturnType, Season, Section, ArchivePreReturnType } from "../types/platform.js"; export default class Platform extends BaseRequest { constructor(auth?: Auth); /** * 获取投稿列表 * 该接口需要登录 * @param params.keyword 关键词 * @param params.status 投稿状态,不传是全部,"is_pubing"是进行中,"pubed"是已通过,"not_pubed"是未通过 * @param params.pn 页码 * @param params.ps 每页数量 * @param params.coop 未知,传1 * @param params.interactive 未知,传1 * @param params.tid 分区id,不传是全部 * @param params.order 不传是投稿时间排序,"click"是播放量排序,"stow"是收藏量排序,"dm_count"是弹幕数排序,"scores"是评论排序 * @returns * */ getArchives(params?: { keyword?: string; status?: "is_pubing" | "pubed" | "not_pubed" | "is_pubing,pubed,not_pubed"; pn: number; ps: number; coop?: number; interactive?: number; tid?: number; order?: "click" | "stow" | "dm_count" | "scores"; }): Promise; /** * 检查tag是否可用 * @param tag 需要检查的tag * @returns */ checkTag(tag: string): Promise<{ code: number; message: string; data: { code: number; content: string; }; }>; /** * 上传 */ private _upload; /** * 投稿视频,推荐submit使用web参数 * on("completed", data => {})可以监听上传完成 * @param filePaths 文件路径 * @param options * @param api * @returns */ addMedia(filePaths: string[] | MediaPartOptions[], options: MediaOptions, api?: { uploader: UploaderType; submit: SubmitType; }, retryOptions?: { times?: number; delay?: number; }): Promise<{ emitter: EventEmitter; pause: () => void; start: () => void; cancel: () => void; }>; /** * 投稿视频,推荐submit使用web参数 * @param filePaths 文件路径 * @param options * @param api * @returns */ onAddMedia(filePaths: string[] | MediaPartOptions[], options: MediaOptions, api?: { uploader: UploaderType; submit: SubmitType; }): Promise<{ aid: number; bvid: string; }>; /** * 投稿视频详情,bvid和aid必须传一个 * @param bvid 视频bvid * @param aid 视频aid */ getArchive(params: { bvid: string; } | { aid: number; }): Promise; /** * 编辑视频,推荐使用web api * @param aid 视频id * @param filePaths 文件路径 * @param options * @param mode 编辑模式,append是追加,replace是替换 * @param api */ editMedia(aid: number, filePaths?: string[] | MediaPartOptions[], options?: Partial, mode?: "append" | "replace", api?: { uploader: UploaderType; submit: "web"; }, retryOptions?: { times?: number; delay?: number; }): Promise<{ emitter: EventEmitter; pause: () => void; start: () => void; cancel: () => void; }>; /** * 编辑视频,推荐使用client api * @param aid 视频id * @param mode 编辑模式,append是追加,replace是替换 * @param filePaths 文件路径 * @param options * @param api */ onEditMedia(aid: number, filePaths?: string[] | MediaPartOptions[], options?: Partial, mode?: "append" | "replace", api?: { uploader: UploaderType; submit: "web"; }): Promise<{ aid: number; bvid: string; }>; /** * 通过必剪 api投稿视频 */ addMediaBCutApi(videos: { cid: number; filename: string; title: string; desc?: string; }[], options: MediaOptions): Promise<{ aid: number; bvid: string; }>; /** * 通过web api投稿视频 */ addMediaWebApi(videos: { cid: number; filename: string; title: string; desc?: string; }[], options: MediaOptions): Promise<{ aid: number; bvid: string; }>; /** * 通过web api v3投稿视频 */ addMediaWebApiV3(videos: { cid: number; filename: string; title: string; desc?: string; }[], options: MediaOptions): Promise<{ aid: number; bvid: string; }>; convertDescV2ToDesc(descV2: DescV2[]): string; /** * 通过web api接口编辑视频 */ editMediaWebApi(videos: { cid: number; filename: string; title: string; desc?: string; }[], options: Partial & { aid: number; sortByCid?: number[]; }, mode: "append" | "replace"): Promise<{ aid: number; bvid: string; }>; /** * 上传封面 * @param filePath 文件路径 */ uploadCover(filePath: string): Promise<{ url: string; }>; /** * 获取上传模板 */ getUploadTemplateList(): Promise<{ tid: number; name: string; typeid: number; title: string; tags: string; description: string; copyright: 1 | 2; attribute: 0 | number; is_default: 0 | 1; }>; /** * 编辑上传模板 */ editUploadTemplate( /** 主键,列表接口获取 */ tid: number, options?: Partial<{ /** 模板名称 */ name: string; /** 标题 */ title: string; /** 标签 */ keywords: string; /** 描述 */ description: string; /** 分区id */ typeid: number; /** Original: 自制,Copy: 转载 */ arctype: "Original" | "Copy"; /** 0: 不设为默认,1: 设置默认 */ is_default: 0 | 1; }>): Promise<{}>; checkOptions(options: Partial): boolean; private sortVideosByCid; /** * 获取推荐标签 * subtype,title,description三个参数对结果影响较大 */ getRecommendTags(params?: { /** 不知道是啥 */ upload_id?: string; /** 分区id */ subtype?: number; /** 视频标题 */ title?: string; /** 分p的filename */ filenmae?: string; /** 视频描述 */ description?: string; /** 封面地址 */ cover_url?: string; }): Promise<{ tag: string; checked: number; request_id: string; }[]>; /** * 查询话题 */ getTopic(params?: { /** 分区id */ type_id?: number; /** 页码,从0开始 */ pn: number; /** 每页个数 */ ps: number; /** 视频标题 */ title?: string; }): Promise<{ topics: { topic_id: number; topic_name: string; description: string; mission_id: number; activity_text: string; activity_description: string; }[]; tags: null; maxpage: number; request_id: string; }>; /** * 话题搜索 */ searchTopic(params?: { /** 每页个数 */ page_size?: number; /** 个数偏移,并非页数 */ offset?: number; /** 关键字 */ keywords?: string; /** 当前时间 */ t?: number; }): Promise<{ result: { has_create_jurisdiction: boolean; is_new_topic: boolean; tips: string; page_info: { has_more: boolean; offset: number; page_number: number; }; topics: { act_protocol: string; activity_sign: string; description: string; id: number; mission_id: number; name: string; state: number; uname: string; }[]; }[]; }>; /** * 合集列表 */ getSeasonList(params?: { /** 页码,从1开始 */ pn: number; /** 个数 */ ps: number; /** 排序字段,ctime:创建时间,mtime:修改时间 */ order?: "ctime" | "mtime"; sort?: "desc" | "asc"; }): Promise; /** * 合集内添加内容 */ addMedia2Season(params: { /** 合集下的section_id */ sectionId: number; /** aid: 视频id, cid:分p id */ episodes: { aid: number; cid: number; title: string; }[]; }): Promise<{}>; /** * 编辑投稿视频合集 */ editMediaSeason(params: { /** 视频id */ aid: number; /** 合集id,null就是从合集中移除 */ season_id: number | null; /** 合集下section_id,null就是从合集中移除 */ section_id: number | null; /** 视频标题 */ title: string; }): Promise<{ season_id?: number | null; section_id?: number | null; title: string; aid: number; csrf: string; }>; /** * aid反查合集id */ getSessionId(aid: number): Promise; /** * 获取合集详情 * @param id 合集id */ getSeasonDetail(id: number): Promise<{ checkin: null; course: null; part_episodes: null; season: Season; seasonStat: null; sections: { sections: Section[]; total: number; }; }>; /** * 获取合集小节详情 * @param id 小节id */ getSectionDetail(id: number): Promise<{ section: Section; }>; /** * 获取投稿的相关活动及分区信息 */ getArchivePre(): Promise; /** * 获取分区的简介相关信息 * @param typeid 分区id * @param copyright 版权类型,可选 1,2 * @returns typeid: 分区id, id: 未知, lang: 未知, copyright:版权类型 * components: 简介输入框提示文字,一个json字符串,例:'[{"name":"相关游戏","index":1,"type":"text","required":"1","box":"请输入本视频所涉及的游戏名称,以顿号分隔,例:英雄联盟、塞尔达传说、刺客信条"},{"name":"简介补充","index":2,"type":"textarea","required":"1","box":""}]' */ getTypeDesc(typeid: number, copyright?: 1 | 2): Promise; /** * 获取新分区列表 */ getHumanType2List(): Promise<{ type_list: { id: number; name: string; }[]; }>; /** * 校验定时发布时间,返回 true 则为合法。 */ verifyScheduledPublishTime(scheduledPublishTime?: number): boolean; }