mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 16:18:22 +08:00
feat: danmaku api (#1530)
This commit is contained in:
committed by
GitHub
parent
88d207cc24
commit
e5f0742bf6
@@ -1,9 +1,10 @@
|
||||
import 'package:PiliPlus/http/api.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class DanmakuHttp {
|
||||
abstract final class DanmakuHttp {
|
||||
static Future shootDanmaku({
|
||||
int type = 1, //弹幕类选择(1:视频弹幕 2:漫画弹幕)
|
||||
required int oid, // 视频cid
|
||||
@@ -27,23 +28,23 @@ class DanmakuHttp {
|
||||
// assert(aid != null || bvid != null);
|
||||
// assert(csrf != null || access_key != null);
|
||||
// 构建参数对象
|
||||
var data = <String, dynamic>{
|
||||
var data = <String, Object>{
|
||||
'type': type,
|
||||
'oid': oid,
|
||||
'msg': msg,
|
||||
'mode': mode,
|
||||
//'aid': aid,
|
||||
'bvid': bvid,
|
||||
'progress': progress,
|
||||
'color': colorful ? 16777215 : color,
|
||||
'fontsize': fontsize,
|
||||
'pool': pool,
|
||||
'progress': ?progress,
|
||||
'color': ?colorful ? 16777215 : color,
|
||||
'fontsize': ?fontsize,
|
||||
'pool': ?pool,
|
||||
'rnd': DateTime.now().microsecondsSinceEpoch,
|
||||
'colorful': colorful ? 60001 : null,
|
||||
'checkbox_type': checkboxType,
|
||||
'colorful': ?colorful ? 60001 : null,
|
||||
'checkbox_type': ?checkboxType,
|
||||
'csrf': Accounts.main.csrf,
|
||||
// 'access_key': access_key,
|
||||
}..removeWhere((key, value) => value == null);
|
||||
};
|
||||
|
||||
var response = await Request().post(
|
||||
Api.shootDanmaku,
|
||||
@@ -68,4 +69,132 @@ class DanmakuHttp {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<Null>> danmakuLike({
|
||||
required bool isLike,
|
||||
required int cid,
|
||||
required int id,
|
||||
}) async {
|
||||
final data = {
|
||||
'op': isLike ? 2 : 1,
|
||||
'dmid': id,
|
||||
'oid': cid,
|
||||
'platform': 'web_player',
|
||||
'polaris_app_id': 100,
|
||||
'polaris_platform': 5,
|
||||
'spmid': '333.788.0.0',
|
||||
'from_spmid': '333.788.0.0',
|
||||
'statistics': '{"appId":100,"platform":5,"abtest":"","version":""}',
|
||||
'csrf': Accounts.main.csrf,
|
||||
};
|
||||
final res = await Request().post(
|
||||
Api.danmakuLike,
|
||||
data: data,
|
||||
options: Options(contentType: Headers.formUrlEncodedContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return const Success(null);
|
||||
} else {
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> danmakuReport({
|
||||
required int reason,
|
||||
required int cid,
|
||||
required int id,
|
||||
bool block = false,
|
||||
String? content,
|
||||
}) async {
|
||||
final data = {
|
||||
'cid': cid,
|
||||
'dmid': id,
|
||||
'reason': reason,
|
||||
'block': block,
|
||||
'originCid': cid,
|
||||
'content': ?content,
|
||||
'polaris_app_id': 100,
|
||||
'polaris_platform': 5,
|
||||
'spmid': '333.788.0.0',
|
||||
'from_spmid': '333.788.0.0',
|
||||
'statistics': '{"appId":100,"platform":5,"abtest":"","version":""}',
|
||||
'csrf': Accounts.main.csrf,
|
||||
};
|
||||
final res = await Request().post(
|
||||
Api.danmakuReport,
|
||||
data: data,
|
||||
options: Options(contentType: Headers.formUrlEncodedContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {
|
||||
'status': true,
|
||||
'data': res.data['data']['block'],
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
'status': false,
|
||||
'msg': res.data['message'],
|
||||
};
|
||||
|
||||
/// {
|
||||
/// 0: "举报已提交",
|
||||
/// "-1": "举报失败,请先激活账号。",
|
||||
/// "-2": "举报失败,系统拒绝受理您的举报请求。",
|
||||
/// "-3": "举报失败,您已经被禁言。",
|
||||
/// "-4": "您的操作过于频繁,请稍后再试。",
|
||||
/// "-5": "您已经举报过这条弹幕了。",
|
||||
/// "-6": "举报失败,系统错误。"
|
||||
/// }
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<String?>> danmakuRecall({
|
||||
required int cid,
|
||||
required int id,
|
||||
}) async {
|
||||
final data = {
|
||||
'dmid': id,
|
||||
'cid': cid,
|
||||
'type': 1,
|
||||
'csrf': Accounts.main.csrf,
|
||||
};
|
||||
final res = await Request().post(
|
||||
Api.danmakuRecall,
|
||||
data: data,
|
||||
options: Options(contentType: Headers.formUrlEncodedContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return Success(res.data['message']);
|
||||
} else {
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<String?>> danmakuEditState({
|
||||
required int oid,
|
||||
required Iterable<int> ids,
|
||||
required int state,
|
||||
}) async {
|
||||
/// 0: 取消删除
|
||||
/// 1:删除弹幕
|
||||
/// 2:弹幕保护
|
||||
/// 3:取消保护
|
||||
final data = {
|
||||
'dmids': ids.join(','),
|
||||
'oid': oid,
|
||||
'state': state,
|
||||
'type': 1,
|
||||
'csrf': Accounts.main.csrf,
|
||||
};
|
||||
final res = await Request().post(
|
||||
Api.danmakuRecall,
|
||||
data: data,
|
||||
options: Options(contentType: Headers.formUrlEncodedContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return Success(res.data['message']);
|
||||
} else {
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user