mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 03:06:59 +08:00
@@ -8,20 +8,18 @@ import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/login.dart';
|
||||
import 'package:PiliPlus/models/common/account_type.dart';
|
||||
import 'package:PiliPlus/models/home/rcmd/result.dart';
|
||||
import 'package:PiliPlus/models/member/article.dart';
|
||||
import 'package:PiliPlus/models/model_hot_video_item.dart';
|
||||
import 'package:PiliPlus/models/model_rec_video_item.dart';
|
||||
import 'package:PiliPlus/models/pgc/pgc_rank/pgc_rank_item_model.dart';
|
||||
import 'package:PiliPlus/models/pgc_lcf.dart';
|
||||
import 'package:PiliPlus/models/play_info/data.dart';
|
||||
import 'package:PiliPlus/models/triple/pgc_triple.dart';
|
||||
import 'package:PiliPlus/models/triple/ugc_triple.dart';
|
||||
import 'package:PiliPlus/models/user/fav_folder.dart';
|
||||
import 'package:PiliPlus/models/video/ai.dart';
|
||||
import 'package:PiliPlus/models/video/note_list/data.dart';
|
||||
import 'package:PiliPlus/models/video/play/url.dart';
|
||||
import 'package:PiliPlus/models/video_detail/video_detail_response.dart';
|
||||
import 'package:PiliPlus/models/video_relation/data.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_rank/pgc_rank_item_model.dart';
|
||||
import 'package:PiliPlus/models_new/triple/pgc_triple.dart';
|
||||
import 'package:PiliPlus/models_new/triple/ugc_triple.dart';
|
||||
import 'package:PiliPlus/models_new/video/video_ai_conclusion/data.dart';
|
||||
import 'package:PiliPlus/models_new/video/video_detail/video_detail_response.dart';
|
||||
import 'package:PiliPlus/models_new/video/video_note_list/data.dart';
|
||||
import 'package:PiliPlus/models_new/video/video_play_info/data.dart';
|
||||
import 'package:PiliPlus/models_new/video/video_relation/data.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
import 'package:PiliPlus/utils/recommend_filter.dart';
|
||||
@@ -213,7 +211,7 @@ class VideoHttp {
|
||||
|
||||
try {
|
||||
var res = await Request().get(
|
||||
epid != null && usePgcApi ? Api.bangumiVideoUrl : Api.videoUrl,
|
||||
epid != null && usePgcApi ? Api.pgcUrl : Api.ugcUrl,
|
||||
queryParameters: params,
|
||||
);
|
||||
|
||||
@@ -281,33 +279,6 @@ class VideoHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future seasonFav({
|
||||
required bool isFav,
|
||||
required dynamic seasonId,
|
||||
}) async {
|
||||
var res = await Request().post(
|
||||
Api.seasonFav + (isFav ? 'unfav' : 'fav'),
|
||||
data: {
|
||||
'platform': 'web',
|
||||
'season_id': seasonId,
|
||||
'csrf': Accounts.main.csrf,
|
||||
},
|
||||
options: Options(
|
||||
contentType: Headers.formUrlEncodedContentType,
|
||||
),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {
|
||||
'status': true,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
'status': false,
|
||||
'msg': res.data['message'],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
static Future videoRelation({required dynamic bvid}) async {
|
||||
var res = await Request().get(
|
||||
Api.videoRelation,
|
||||
@@ -346,10 +317,10 @@ class VideoHttp {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取点赞/投币/收藏状态 bangumi
|
||||
static Future bangumiLikeCoinFav({dynamic epId}) async {
|
||||
// 获取点赞/投币/收藏状态 pgc
|
||||
static Future pgcLikeCoinFav({dynamic epId}) async {
|
||||
var res = await Request().get(
|
||||
Api.bangumiLikeCoinFav,
|
||||
Api.pgcLikeCoinFav,
|
||||
queryParameters: {'ep_id': epId},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
@@ -383,7 +354,7 @@ class VideoHttp {
|
||||
}
|
||||
}
|
||||
|
||||
// 一键三连 bangumi
|
||||
// 一键三连 pgc
|
||||
static Future triple({dynamic epId, required dynamic seasonId}) async {
|
||||
var res = await Request().post(
|
||||
Api.triple,
|
||||
@@ -524,121 +495,6 @@ class VideoHttp {
|
||||
}
|
||||
}
|
||||
|
||||
// (取消)收藏
|
||||
static Future delFav({
|
||||
List? ids,
|
||||
String? delIds,
|
||||
}) async {
|
||||
var res = await Request().post(
|
||||
Api.delFav,
|
||||
data: {
|
||||
'resources': ids?.join(','),
|
||||
'media_id': delIds,
|
||||
'platform': 'web',
|
||||
'csrf': Accounts.main.csrf,
|
||||
},
|
||||
options: Options(contentType: Headers.formUrlEncodedContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true, 'data': res.data['data']};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
|
||||
// (取消)收藏
|
||||
static Future favVideo({
|
||||
int? aid,
|
||||
String? addIds,
|
||||
String? delIds,
|
||||
int? type,
|
||||
}) async {
|
||||
var res = await Request().post(
|
||||
Api.favVideo,
|
||||
data: {
|
||||
'rid': aid,
|
||||
'type': type ?? 2,
|
||||
'add_media_ids': addIds ?? '',
|
||||
'del_media_ids': delIds ?? '',
|
||||
'csrf': Accounts.main.csrf,
|
||||
},
|
||||
options: Options(contentType: Headers.formUrlEncodedContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true, 'data': res.data['data']};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
|
||||
static Future copyOrMoveFav({
|
||||
required bool isCopy,
|
||||
required bool isFav,
|
||||
required dynamic srcMediaId,
|
||||
required dynamic tarMediaId,
|
||||
dynamic mid,
|
||||
required List resources,
|
||||
}) async {
|
||||
var res = await Request().post(
|
||||
isFav
|
||||
? isCopy
|
||||
? Api.copyFav
|
||||
: Api.moveFav
|
||||
: isCopy
|
||||
? Api.copyToview
|
||||
: Api.moveToview,
|
||||
data: {
|
||||
if (srcMediaId != null) 'src_media_id': srcMediaId,
|
||||
'tar_media_id': tarMediaId,
|
||||
if (mid != null) 'mid': mid,
|
||||
'resources': resources.join(','),
|
||||
'platform': 'web',
|
||||
'csrf': Accounts.main.csrf,
|
||||
},
|
||||
options: Options(contentType: Headers.formUrlEncodedContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
|
||||
static Future allFavFolders(mid) async {
|
||||
var res = await Request().get(
|
||||
Api.favFolder,
|
||||
queryParameters: {'up_mid': mid},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
FavFolderData data = FavFolderData.fromJson(res.data['data']);
|
||||
return {'status': true, 'data': data};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
|
||||
// 查看视频被收藏在哪个文件夹
|
||||
static Future videoInFolder({
|
||||
dynamic mid,
|
||||
dynamic rid,
|
||||
dynamic type,
|
||||
}) async {
|
||||
var res = await Request().get(
|
||||
Api.favFolder,
|
||||
queryParameters: {
|
||||
'up_mid': mid,
|
||||
'rid': rid,
|
||||
if (type != null) 'type': type,
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
FavFolderData data = FavFolderData.fromJson(res.data['data']);
|
||||
return {'status': true, 'data': data};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
|
||||
// 发表评论 replyAdd
|
||||
|
||||
// type num 评论区类型代码 必要 类型代码见表
|
||||
@@ -800,8 +656,8 @@ class VideoHttp {
|
||||
}
|
||||
|
||||
// 添加追番
|
||||
static Future bangumiAdd({int? seasonId}) async {
|
||||
var res = await Request().post(Api.bangumiAdd, queryParameters: {
|
||||
static Future pgcAdd({int? seasonId}) async {
|
||||
var res = await Request().post(Api.pgcAdd, queryParameters: {
|
||||
'season_id': seasonId,
|
||||
'csrf': Accounts.main.csrf,
|
||||
});
|
||||
@@ -821,8 +677,8 @@ class VideoHttp {
|
||||
}
|
||||
|
||||
// 取消追番
|
||||
static Future bangumiDel({int? seasonId}) async {
|
||||
var res = await Request().post(Api.bangumiDel, queryParameters: {
|
||||
static Future pgcDel({int? seasonId}) async {
|
||||
var res = await Request().post(Api.pgcDel, queryParameters: {
|
||||
'season_id': seasonId,
|
||||
'csrf': Accounts.main.csrf,
|
||||
});
|
||||
@@ -841,12 +697,12 @@ class VideoHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future bangumiUpdate({
|
||||
static Future pgcUpdate({
|
||||
required List seasonId,
|
||||
required dynamic status,
|
||||
}) async {
|
||||
var res = await Request().post(
|
||||
Api.bangumiUpdate,
|
||||
Api.pgcUpdate,
|
||||
data: {
|
||||
'season_id': seasonId.join(','),
|
||||
'status': status,
|
||||
@@ -890,7 +746,7 @@ class VideoHttp {
|
||||
if (res.data['code'] == 0 && res.data['data']['code'] == 0) {
|
||||
return {
|
||||
'status': true,
|
||||
'data': AiConclusionModel.fromJson(res.data['data']),
|
||||
'data': AiConclusionData.fromJson(res.data['data']),
|
||||
};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
@@ -1016,7 +872,7 @@ class VideoHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<NoteListData>> getVideoNoteList({
|
||||
static Future<LoadingState<VideoNoteData>> getVideoNoteList({
|
||||
dynamic oid,
|
||||
dynamic uperMid,
|
||||
required int page,
|
||||
@@ -1033,120 +889,9 @@ class VideoHttp {
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return Success(NoteListData.fromJson(res.data['data']));
|
||||
return Success(VideoNoteData.fromJson(res.data['data']));
|
||||
} else {
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<List<FavNoteModel>?>> noteList({
|
||||
required int page,
|
||||
}) async {
|
||||
var res = await Request().get(
|
||||
Api.noteList,
|
||||
queryParameters: {
|
||||
'pn': page,
|
||||
'ps': 10,
|
||||
'csrf': Accounts.main.csrf,
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
List<FavNoteModel>? list = (res.data['data']?['list'] as List?)
|
||||
?.map((e) => FavNoteModel.fromJson(e))
|
||||
.toList();
|
||||
return Success(list);
|
||||
} else {
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<List<FavNoteModel>?>> userNoteList({
|
||||
required int page,
|
||||
}) async {
|
||||
var res = await Request().get(
|
||||
Api.userNoteList,
|
||||
queryParameters: {
|
||||
'pn': page,
|
||||
'ps': 10,
|
||||
'csrf': Accounts.main.csrf,
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
List<FavNoteModel>? list = (res.data['data']?['list'] as List?)
|
||||
?.map((e) => FavNoteModel.fromJson(e))
|
||||
.toList();
|
||||
return Success(list);
|
||||
} else {
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> addNote({
|
||||
required oid,
|
||||
required String title,
|
||||
required String summary,
|
||||
}) async {
|
||||
String noteId = '';
|
||||
try {
|
||||
final res = await Request().get(Api.archiveNote, queryParameters: {
|
||||
'oid': oid,
|
||||
'oid_type': 0,
|
||||
'csrf': Accounts.main.csrf,
|
||||
});
|
||||
if (res.data['code'] == 0) {
|
||||
if (res.data['data']?['noteIds'] != null) {
|
||||
noteId = res.data['data']['noteIds'].first;
|
||||
}
|
||||
}
|
||||
} catch (_) {}
|
||||
|
||||
final res = await Request().post(
|
||||
Api.addNote,
|
||||
data: {
|
||||
'cont_len': summary.length,
|
||||
'note_id': noteId,
|
||||
'oid': oid,
|
||||
'oid_type': 0,
|
||||
'platform': 'web',
|
||||
'title': title,
|
||||
'summary': summary,
|
||||
'content': jsonEncode([
|
||||
{"insert": summary},
|
||||
]),
|
||||
'from': 'close',
|
||||
'hash': DateTime.now().millisecondsSinceEpoch,
|
||||
'tags': '',
|
||||
'csrf': Accounts.main.csrf,
|
||||
},
|
||||
options: Options(
|
||||
contentType: Headers.formUrlEncodedContentType,
|
||||
),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return Success(res.data['data']?['list']);
|
||||
} else {
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future delNote({
|
||||
required bool isPublish,
|
||||
required List noteIds,
|
||||
}) async {
|
||||
final res = await Request().post(
|
||||
isPublish ? Api.delPublishNote : Api.delNote,
|
||||
data: {
|
||||
isPublish ? 'cvids' : 'note_ids': noteIds.join(','),
|
||||
'csrf': Accounts.main.csrf,
|
||||
},
|
||||
options: Options(
|
||||
contentType: Headers.formUrlEncodedContentType,
|
||||
),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user