mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-12 13:51:38 +08:00
@@ -31,23 +31,16 @@ import 'package:PiliPlus/models_new/video/video_shot/data.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
import 'package:PiliPlus/utils/app_sign.dart';
|
||||
import 'package:PiliPlus/utils/extension/string_ext.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
import 'package:PiliPlus/utils/recommend_filter.dart';
|
||||
import 'package:PiliPlus/utils/request_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:PiliPlus/utils/wbi_sign.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart' show compute;
|
||||
import 'package:protobuf/protobuf.dart';
|
||||
|
||||
/// view层根据 status 判断渲染逻辑
|
||||
abstract final class VideoHttp {
|
||||
static RegExp zoneRegExp = RegExp(Pref.banWordForZone, caseSensitive: false);
|
||||
static bool enableFilter = zoneRegExp.pattern.isNotEmpty;
|
||||
|
||||
// 首页推荐视频
|
||||
static Future<LoadingState<List<RcmdVideoItemModel>>> rcmdVideoList({
|
||||
required int ps,
|
||||
@@ -68,15 +61,7 @@ abstract final class VideoHttp {
|
||||
if (res.data['code'] == 0) {
|
||||
List<RcmdVideoItemModel> list = <RcmdVideoItemModel>[];
|
||||
for (final i in res.data['data']['item']) {
|
||||
//过滤掉live与ad,以及拉黑用户
|
||||
if (i['goto'] == 'av' &&
|
||||
(i['owner'] != null &&
|
||||
!GlobalData().blackMids.contains(i['owner']['mid']))) {
|
||||
RcmdVideoItemModel videoItem = RcmdVideoItemModel.fromJson(i);
|
||||
if (!RecommendFilter.filter(videoItem)) {
|
||||
list.add(videoItem);
|
||||
}
|
||||
}
|
||||
list.add(RcmdVideoItemModel.fromJson(i));
|
||||
}
|
||||
return Success(list);
|
||||
} else {
|
||||
@@ -142,20 +127,9 @@ abstract final class VideoHttp {
|
||||
List<RcmdVideoItemAppModel> list = <RcmdVideoItemAppModel>[];
|
||||
for (final i in res.data['data']['items']) {
|
||||
// 屏蔽推广和拉黑用户
|
||||
if (i['card_goto'] != 'ad_av' &&
|
||||
i['card_goto'] != 'ad_web_s' &&
|
||||
i['ad_info'] == null &&
|
||||
(i['args'] != null &&
|
||||
!GlobalData().blackMids.contains(i['args']['up_id']))) {
|
||||
if (enableFilter &&
|
||||
i['args']?['tname'] != null &&
|
||||
zoneRegExp.hasMatch(i['args']['tname'])) {
|
||||
continue;
|
||||
}
|
||||
RcmdVideoItemAppModel videoItem = RcmdVideoItemAppModel.fromJson(i);
|
||||
if (!RecommendFilter.filter(videoItem)) {
|
||||
list.add(videoItem);
|
||||
}
|
||||
final goto = i['card_goto'];
|
||||
if (goto != 'ad_av' && goto != 'ad_web_s' && i['ad_info'] == null) {
|
||||
list.add(RcmdVideoItemAppModel.fromJson(i));
|
||||
}
|
||||
}
|
||||
return Success(list);
|
||||
@@ -176,19 +150,7 @@ abstract final class VideoHttp {
|
||||
if (res.data['code'] == 0) {
|
||||
List<HotVideoItemModel> list = <HotVideoItemModel>[];
|
||||
for (final i in res.data['data']['list']) {
|
||||
if (!GlobalData().blackMids.contains(i['owner']['mid']) &&
|
||||
!RecommendFilter.filterTitle(i['title']) &&
|
||||
!RecommendFilter.filterLikeRatio(
|
||||
i['stat']['like'],
|
||||
i['stat']['view'],
|
||||
)) {
|
||||
if (enableFilter &&
|
||||
i['tname'] != null &&
|
||||
zoneRegExp.hasMatch(i['tname'])) {
|
||||
continue;
|
||||
}
|
||||
list.add(HotVideoItemModel.fromJson(i));
|
||||
}
|
||||
list.add(HotVideoItemModel.fromJson(i));
|
||||
}
|
||||
return Success(list);
|
||||
} else {
|
||||
@@ -208,7 +170,6 @@ abstract final class VideoHttp {
|
||||
required bool tryLook,
|
||||
required VideoType videoType,
|
||||
String? language,
|
||||
bool voiceBalance = false,
|
||||
}) async {
|
||||
final params = await WbiSign.makSign({
|
||||
'avid': ?avid,
|
||||
@@ -221,7 +182,7 @@ abstract final class VideoHttp {
|
||||
'fnval': 4048,
|
||||
'fourk': 1,
|
||||
'fnver': 0,
|
||||
'voice_balance': voiceBalance ? 1 : 0,
|
||||
'voice_balance': 0,
|
||||
'gaia_source': 'pre-load',
|
||||
'isGaiaAvoided': true,
|
||||
'web_location': 1315873,
|
||||
@@ -318,13 +279,11 @@ abstract final class VideoHttp {
|
||||
queryParameters: {'bvid': bvid},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
final items = (res.data['data'] as List?)?.map(
|
||||
(i) => HotVideoItemModel.fromJson(i),
|
||||
return Success(
|
||||
(res.data['data'] as List?)
|
||||
?.map((i) => HotVideoItemModel.fromJson(i))
|
||||
.toList(),
|
||||
);
|
||||
final list = RecommendFilter.applyFilterToRelatedVideos
|
||||
? items?.where((i) => !RecommendFilter.filterAll(i)).toList()
|
||||
: items?.toList();
|
||||
return Success(list);
|
||||
} else {
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
@@ -561,13 +520,6 @@ abstract final class VideoHttp {
|
||||
if (res.data['code'] == 0) {
|
||||
try {
|
||||
final replyInfo = RequestUtils.replyCast(res.data['data']['reply']);
|
||||
GStorage.reply?.put(
|
||||
replyInfo.id.toString(),
|
||||
(replyInfo.deepCopy()
|
||||
..unknownFields.clear()
|
||||
..clearTrackInfo())
|
||||
.writeToBuffer(),
|
||||
);
|
||||
return Success(replyInfo);
|
||||
} catch (e, s) {
|
||||
Utils.reportError(e, s);
|
||||
@@ -594,7 +546,6 @@ abstract final class VideoHttp {
|
||||
options: Options(contentType: Headers.formUrlEncodedContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
GStorage.reply?.delete(rpid.toString());
|
||||
return const Success(null);
|
||||
} else {
|
||||
return const Error('请退出账号后重新登录');
|
||||
@@ -860,23 +811,6 @@ abstract final class VideoHttp {
|
||||
return null;
|
||||
}
|
||||
|
||||
static bool _canAddRank(Map i) {
|
||||
if (!GlobalData().blackMids.contains(i['owner']['mid']) &&
|
||||
!RecommendFilter.filterTitle(i['title']) &&
|
||||
!RecommendFilter.filterLikeRatio(
|
||||
i['stat']['like'],
|
||||
i['stat']['view'],
|
||||
)) {
|
||||
if (enableFilter &&
|
||||
i['tname'] != null &&
|
||||
zoneRegExp.hasMatch(i['tname'])) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 视频排行
|
||||
static Future<LoadingState<List<HotVideoItemModel>>> getRankVideoList(
|
||||
int rid,
|
||||
@@ -888,17 +822,7 @@ abstract final class VideoHttp {
|
||||
if (res.data['code'] == 0) {
|
||||
List<HotVideoItemModel> list = <HotVideoItemModel>[];
|
||||
for (final i in res.data['data']['list']) {
|
||||
if (_canAddRank(i)) {
|
||||
list.add(HotVideoItemModel.fromJson(i));
|
||||
// final List? others = i['others'];
|
||||
// if (others != null && others.isNotEmpty) {
|
||||
// for (final j in others) {
|
||||
// if (_canAddRank(j)) {
|
||||
// list.add(HotVideoItemModel.fromJson(j));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
list.add(HotVideoItemModel.fromJson(i));
|
||||
}
|
||||
return Success(list);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user