* fix * 适配 biliup/biliup-rs#186 extra_fields * dev 边录边上传功能初版 * 修复下载器错误 * 实现同步编辑投稿功能 * 上传模板标题格式化 * fix * 默认分p大小2G * 重写了对列 * 修改输出队列机制 * 多线程上传有bug * 修复异常阻塞和多线程上传bug * reset * fix * 修复线程池异常 * 添加额外字段支持;增加同步下载器选项;去除无用日志;修复B站FLV流小概率无法获取;去掉B站弹幕重复登录态验证。 * 删除补0测戳 * 调整 ffmpeg header 参数位置 * 添加同步保存到本地的配置项 和 运行分段后自定义命令 * 添加缺失的投稿参数 * 添加边录边传保存目录项 * 格式化 * 修正 webup_sync 上传线路选择 * 修复 webup_sync 的 submit_web * 修正参数错误 * 删除多余代码 * 删除多余代码 --------- Co-authored-by: xxxxuanran <xxxxuanran@gmail.com>
132 lines
2.9 KiB
TypeScript
132 lines
2.9 KiB
TypeScript
// Fetcher implementation.
|
|
// The extra argument will be passed via the `arg` property of the 2nd parameter.
|
|
// In the example below, `arg` will be `'my_token'`
|
|
export async function sendRequest<T>(url: string, { arg }: {arg: T}) {
|
|
const res = await fetch((process.env.NEXT_PUBLIC_API_SERVER ?? '') + url, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify(arg)
|
|
});
|
|
if(!(res.status >=200 && res.status < 300)) {
|
|
throw new Error(await res.text());
|
|
}
|
|
const data = await res.json();
|
|
if (!res.ok) {
|
|
throw new Error(data.message);
|
|
}
|
|
return data;
|
|
}
|
|
|
|
export const fetcher = async (...args: any[]) => {
|
|
const res = await fetch((process.env.NEXT_PUBLIC_API_SERVER ?? '') + args[0], args[1])
|
|
if (!res.ok) {
|
|
throw new Error(await res.text());
|
|
}
|
|
return res.json();
|
|
}
|
|
|
|
export const proxy = async (input: RequestInfo | URL, init?: RequestInit | undefined) => {
|
|
const res = await fetch((process.env.NEXT_PUBLIC_API_SERVER ?? '') + input, init)
|
|
if (!res.ok) {
|
|
throw new Error(await res.text());
|
|
}
|
|
return res;
|
|
}
|
|
|
|
export async function requestDelete<T>(url: string, { arg }: {arg: T}) {
|
|
const res = await fetch(`${process.env.NEXT_PUBLIC_API_SERVER ?? ''}${url}/${arg}`, {
|
|
method: 'DELETE',
|
|
})
|
|
if (!res.ok) {
|
|
throw new Error(await res.text());
|
|
}
|
|
return res;
|
|
}
|
|
|
|
export async function put<T>(url: string, { arg }: {arg: T}) {
|
|
const res = await fetch(`${process.env.NEXT_PUBLIC_API_SERVER ?? ''}${url}`, {
|
|
method: 'PUT',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify(arg)
|
|
})
|
|
if (!res.ok) {
|
|
throw new Error(await res.text());
|
|
}
|
|
return res;
|
|
}
|
|
|
|
type Credit = {
|
|
username: string;
|
|
uid: number;
|
|
};
|
|
|
|
export interface StudioEntity {
|
|
id: number;
|
|
template_name: string;
|
|
user_cookie: string;
|
|
copyright: number;
|
|
copyright_source: string;
|
|
tid: number;
|
|
cover_path: string;
|
|
title: string;
|
|
description: string;
|
|
dynamic: string;
|
|
tags: string[];
|
|
dtime: number;
|
|
// interactive: number;
|
|
mission_id?: number;
|
|
dolby: number;
|
|
hires: number;
|
|
no_reprint: number;
|
|
up_selection_reply: number;
|
|
up_close_reply: number;
|
|
up_close_danmu: number;
|
|
open_elec: number;
|
|
credits: Credit[];
|
|
uploader: string;
|
|
extra_fields?: string;
|
|
}
|
|
|
|
export interface LiveStreamerEntity {
|
|
id: number;
|
|
url: string;
|
|
remark: string;
|
|
filename: string;
|
|
split_time?: number;
|
|
split_size?: number;
|
|
upload_id?: number;
|
|
status?: string | React.ReactNode;
|
|
format?: string;
|
|
time_range?: string;
|
|
preprocessor?: Record<'run', string>[];
|
|
segment_processor?: Record<'run', string>[];
|
|
downloaded_processor?: Record<'run', string>[];
|
|
postprocessor?: (Record<'run' | 'mv', string> | 'rm')[];
|
|
opt_args?: string[];
|
|
}
|
|
|
|
export interface BiliType {
|
|
id: number;
|
|
children: BiliType[];
|
|
name: string;
|
|
desc: string;
|
|
}
|
|
|
|
export interface User {
|
|
id: number;
|
|
name: string;
|
|
value: string;
|
|
platform: string;
|
|
}
|
|
|
|
export interface FileList {
|
|
key: number;
|
|
name: string;
|
|
updateTime: number;
|
|
size: number;
|
|
}
|