mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: session secondary
Closes #837 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,37 +1,9 @@
|
||||
import 'package:PiliPlus/grpc/bilibili/community/service/dm/v1.pb.dart';
|
||||
import 'package:PiliPlus/grpc/grpc_repo.dart';
|
||||
import 'package:PiliPlus/http/api.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class DanmakuHttp {
|
||||
// 获取视频弹幕
|
||||
static Future<LoadingState<DmSegMobileReply>> queryDanmaku({
|
||||
required int cid,
|
||||
required int segmentIndex,
|
||||
int queryCount = 1,
|
||||
}) async {
|
||||
// 构建参数对象
|
||||
final response =
|
||||
await GrpcRepo.dmSegMobile(cid: cid, segmentIndex: segmentIndex);
|
||||
if (!response['status']) {
|
||||
if (queryCount >= 3) {
|
||||
return const Error('');
|
||||
} else {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
return await queryDanmaku(
|
||||
cid: cid,
|
||||
segmentIndex: segmentIndex,
|
||||
queryCount: ++queryCount,
|
||||
);
|
||||
}
|
||||
}
|
||||
DmSegMobileReply data = response['data'];
|
||||
return LoadingState.success(data);
|
||||
}
|
||||
|
||||
static Future shootDanmaku({
|
||||
int type = 1, //弹幕类选择(1:视频弹幕 2:漫画弹幕)
|
||||
required int oid, // 视频cid
|
||||
|
||||
@@ -2,9 +2,6 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/grpc/bilibili/app/dynamic/v2.pb.dart'
|
||||
show OpusSpaceFlowResp;
|
||||
import 'package:PiliPlus/grpc/grpc_repo.dart';
|
||||
import 'package:PiliPlus/http/api.dart';
|
||||
import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
@@ -52,18 +49,6 @@ class MemberHttp {
|
||||
};
|
||||
}
|
||||
|
||||
// static Future<LoadingState> spaceDynamic({
|
||||
// required int mid,
|
||||
// required int page,
|
||||
// }) async {
|
||||
// dynamic result = await GrpcRepo.dynSpace(uid: mid, page: page);
|
||||
// if (result['status']) {
|
||||
// return LoadingState.success(result['data']);
|
||||
// } else {
|
||||
// return LoadingState.error(result['msg']);
|
||||
// }
|
||||
// }
|
||||
|
||||
static Future<LoadingState<SpaceArticleData>> spaceArticle({
|
||||
required int mid,
|
||||
required int page,
|
||||
@@ -848,23 +833,6 @@ class MemberHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<OpusSpaceFlowResp>> opusSpaceFlow({
|
||||
required int hostMid,
|
||||
String? next,
|
||||
required String filterType,
|
||||
}) async {
|
||||
var res = await GrpcRepo.opusSpaceFlow(
|
||||
hostMid: hostMid,
|
||||
next: next,
|
||||
filterType: filterType,
|
||||
);
|
||||
if (res['status']) {
|
||||
return LoadingState.success(res['data']);
|
||||
} else {
|
||||
return LoadingState.error(res['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<SpaceOpusData>> spaceOpus({
|
||||
required int hostMid,
|
||||
required int page,
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/grpc/bilibili/app/im/v1.pb.dart';
|
||||
import 'package:PiliPlus/grpc/grpc_repo.dart';
|
||||
import 'package:PiliPlus/http/api.dart';
|
||||
import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
@@ -17,7 +15,6 @@ import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/wbi_sign.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:protobuf/protobuf.dart' show PbMap;
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class MsgHttp {
|
||||
@@ -433,16 +430,6 @@ class MsgHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<SessionMainReply>> sessionMain(
|
||||
{PbMap<int, Offset>? offset}) async {
|
||||
final res = await GrpcRepo.sessionMain(offset: offset);
|
||||
if (res['status']) {
|
||||
return LoadingState.success(res['data']);
|
||||
} else {
|
||||
return LoadingState.error(res['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future accountList(uids) async {
|
||||
var res = await Request().get(Api.sessionAccountList, queryParameters: {
|
||||
'uids': uids,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart';
|
||||
import 'package:PiliPlus/grpc/grpc_repo.dart';
|
||||
import 'package:PiliPlus/http/api.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
@@ -11,7 +9,6 @@ import 'package:PiliPlus/utils/accounts/account.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:fixnum/fixnum.dart';
|
||||
|
||||
class ReplyHttp {
|
||||
static Options get _options =>
|
||||
@@ -124,89 +121,6 @@ class ReplyHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<MainListReply>> mainList({
|
||||
int type = 1,
|
||||
required int oid,
|
||||
required Mode mode,
|
||||
required String? offset,
|
||||
required Int64? cursorNext,
|
||||
required bool antiGoodsReply,
|
||||
}) async {
|
||||
dynamic res = await GrpcRepo.mainList(
|
||||
type: type,
|
||||
oid: oid,
|
||||
mode: mode,
|
||||
offset: offset,
|
||||
cursorNext: cursorNext,
|
||||
);
|
||||
if (res['status']) {
|
||||
MainListReply mainListReply = res['data'];
|
||||
// keyword filter
|
||||
if (replyRegExp.pattern.isNotEmpty) {
|
||||
// upTop
|
||||
if (mainListReply.hasUpTop() &&
|
||||
replyRegExp.hasMatch(mainListReply.upTop.content.message)) {
|
||||
mainListReply.clearUpTop();
|
||||
}
|
||||
|
||||
// replies
|
||||
if (mainListReply.replies.isNotEmpty) {
|
||||
mainListReply.replies.removeWhere((item) {
|
||||
bool hasMatch = replyRegExp.hasMatch(item.content.message);
|
||||
// remove subreplies
|
||||
if (hasMatch.not) {
|
||||
if (item.replies.isNotEmpty) {
|
||||
item.replies.removeWhere(
|
||||
(item) => replyRegExp.hasMatch(item.content.message));
|
||||
}
|
||||
}
|
||||
return hasMatch;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// antiGoodsReply
|
||||
if (antiGoodsReply) {
|
||||
// upTop
|
||||
if (mainListReply.hasUpTop() && needRemoveGrpc(mainListReply.upTop)) {
|
||||
mainListReply.clearUpTop();
|
||||
}
|
||||
|
||||
// replies
|
||||
if (mainListReply.replies.isNotEmpty) {
|
||||
mainListReply.replies.removeWhere((item) {
|
||||
bool hasMatch = needRemoveGrpc(item);
|
||||
// remove subreplies
|
||||
if (hasMatch.not) {
|
||||
if (item.replies.isNotEmpty) {
|
||||
item.replies.removeWhere(needRemoveGrpc);
|
||||
}
|
||||
}
|
||||
return hasMatch;
|
||||
});
|
||||
}
|
||||
}
|
||||
return LoadingState.success(mainListReply);
|
||||
} else {
|
||||
return LoadingState.error(res['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
// ref BiliRoamingX
|
||||
static bool needRemoveGrpc(ReplyInfo reply) {
|
||||
if ((reply.content.urls.isNotEmpty &&
|
||||
reply.content.urls.values.any((url) {
|
||||
return url.hasExtra() &&
|
||||
(url.extra.goodsCmControl == 1 ||
|
||||
url.extra.goodsItemId != 0 ||
|
||||
url.extra.goodsPrefetchedCache.isNotEmpty);
|
||||
})) ||
|
||||
reply.content.message.contains(Constants.goodsUrlPrefix)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool needRemove(ReplyItemModel reply) {
|
||||
try {
|
||||
if ((reply.content?.jumpUrl?.isNotEmpty == true &&
|
||||
@@ -269,76 +183,6 @@ class ReplyHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> detailList({
|
||||
int type = 1,
|
||||
required int oid,
|
||||
required int root,
|
||||
required int rpid,
|
||||
required Mode mode,
|
||||
required String? offset,
|
||||
required bool antiGoodsReply,
|
||||
}) async {
|
||||
dynamic res = await GrpcRepo.detailList(
|
||||
type: type,
|
||||
oid: oid,
|
||||
root: root,
|
||||
rpid: rpid,
|
||||
mode: mode,
|
||||
offset: offset,
|
||||
);
|
||||
if (res['status']) {
|
||||
DetailListReply detailListReply = res['data'];
|
||||
if (replyRegExp.pattern.isNotEmpty) {
|
||||
if (detailListReply.root.replies.isNotEmpty) {
|
||||
detailListReply.root.replies.removeWhere(
|
||||
(item) => replyRegExp.hasMatch(item.content.message));
|
||||
}
|
||||
}
|
||||
if (antiGoodsReply) {
|
||||
if (detailListReply.root.replies.isNotEmpty) {
|
||||
detailListReply.root.replies.removeWhere(needRemoveGrpc);
|
||||
}
|
||||
}
|
||||
return LoadingState.success(detailListReply);
|
||||
} else {
|
||||
return LoadingState.error(res['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> dialogList({
|
||||
int type = 1,
|
||||
required int oid,
|
||||
required int root,
|
||||
required int dialog,
|
||||
required String? offset,
|
||||
required bool antiGoodsReply,
|
||||
}) async {
|
||||
dynamic res = await GrpcRepo.dialogList(
|
||||
type: type,
|
||||
oid: oid,
|
||||
root: root,
|
||||
dialog: dialog,
|
||||
offset: offset,
|
||||
);
|
||||
if (res['status']) {
|
||||
DialogListReply dialogListReply = res['data'];
|
||||
if (replyRegExp.pattern.isNotEmpty) {
|
||||
if (dialogListReply.replies.isNotEmpty) {
|
||||
dialogListReply.replies.removeWhere(
|
||||
(item) => replyRegExp.hasMatch(item.content.message));
|
||||
}
|
||||
}
|
||||
if (antiGoodsReply) {
|
||||
if (dialogListReply.replies.isNotEmpty) {
|
||||
dialogListReply.replies.removeWhere(needRemoveGrpc);
|
||||
}
|
||||
}
|
||||
return LoadingState.success(dialogListReply);
|
||||
} else {
|
||||
return LoadingState.error(res['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future hateReply({
|
||||
required int type,
|
||||
required int action,
|
||||
|
||||
@@ -172,22 +172,6 @@ class VideoHttp {
|
||||
}
|
||||
}
|
||||
|
||||
// static Future<LoadingState> hotVideoListGrpc({required int idx}) async {
|
||||
// dynamic res = await GrpcRepo.popular(idx);
|
||||
// if (res['status']) {
|
||||
// List<card.Card> list = <card.Card>[];
|
||||
// Set<int> blackMids = GStorage.blackMids;
|
||||
// for (card.Card item in res['data']) {
|
||||
// if (!blackMids.contains(item.smallCoverV5.up.id.toInt())) {
|
||||
// list.add(item);
|
||||
// }
|
||||
// }
|
||||
// return LoadingState.success(list);
|
||||
// } else {
|
||||
// return LoadingState.error(res['msg']);
|
||||
// }
|
||||
// }
|
||||
|
||||
// 视频流
|
||||
static Future videoUrl({
|
||||
int? avid,
|
||||
|
||||
Reference in New Issue
Block a user