diff --git a/lib/http/api.dart b/lib/http/api.dart index d71a3c94d..5905ed637 100644 --- a/lib/http/api.dart +++ b/lib/http/api.dart @@ -972,4 +972,6 @@ class Api { static const String followedUp = '/x/relation/followings/followed_upper'; static const String sameFollowing = '/x/relation/same/followings'; + + static const String seasonStatus = '/pgc/view/web/season/user/status'; } diff --git a/lib/http/pgc.dart b/lib/http/pgc.dart index 61fbf6cda..5843d2939 100644 --- a/lib/http/pgc.dart +++ b/lib/http/pgc.dart @@ -242,4 +242,18 @@ class PgcHttp { return {'status': false, 'msg': res.data['message']}; } } + + static Future seasonStatus(dynamic seasonId) async { + var res = await Request().get( + Api.seasonStatus, + queryParameters: { + 'season_id': seasonId, + }, + ); + if (res.data['code'] == 0) { + return {'status': true, 'data': res.data['result']}; + } else { + return {'status': false, 'msg': res.data['message']}; + } + } } diff --git a/lib/pages/video/introduction/pgc/controller.dart b/lib/pages/video/introduction/pgc/controller.dart index 1a9a05122..c419f960d 100644 --- a/lib/pages/video/introduction/pgc/controller.dart +++ b/lib/pages/video/introduction/pgc/controller.dart @@ -1,11 +1,9 @@ import 'dart:async'; import 'dart:math' show max; -import 'package:PiliPlus/grpc/bilibili/app/viewunite/pgcanymodel.pb.dart' - show ViewPgcAny; -import 'package:PiliPlus/grpc/view.dart'; import 'package:PiliPlus/http/constants.dart'; import 'package:PiliPlus/http/fav.dart'; +import 'package:PiliPlus/http/pgc.dart'; import 'package:PiliPlus/http/search.dart'; import 'package:PiliPlus/http/video.dart'; import 'package:PiliPlus/models/common/video/source_type.dart'; @@ -448,7 +446,7 @@ class PgcIntroController extends CommonIntroController { } } - void queryIsFollowed() { + Future queryIsFollowed() async { // try { // var result = await Request().get( // 'https://www.bilibili.com/bangumi/play/ss$seasonId', @@ -464,14 +462,22 @@ class PgcIntroController extends CommonIntroController { // scriptContent['props']['pageProps']['followState']['followStatus']; // } // } catch (_) {} - ViewGrpc.view(bvid: bvid).then((res) { - if (res.isSuccess) { - ViewPgcAny view = ViewPgcAny.fromBuffer(res.data.supplement.value); - var userStatus = view.ogvData.userStatus; - isFollowed.value = userStatus.follow == 1; - followStatus.value = userStatus.followStatus; - } - }); + + // ViewGrpc.view(bvid: bvid).then((res) { + // if (res.isSuccess) { + // ViewPgcAny view = ViewPgcAny.fromBuffer(res.data.supplement.value); + // var userStatus = view.ogvData.userStatus; + // isFollowed.value = userStatus.follow == 1; + // followStatus.value = userStatus.followStatus; + // } + // }); + + final res = await PgcHttp.seasonStatus(seasonId); + if (res['status']) { + final data = res['data']; + isFollowed.value = data['follow'] == 1; + followStatus.value = data['follow_status']; + } } @override diff --git a/pubspec.lock b/pubspec.lock index a832f0715..ab874c52b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -785,7 +785,7 @@ packages: description: path: "." ref: "version_4.7.2" - resolved-ref: "92be28f3279717fc7f63969d144b97e16fff1e38" + resolved-ref: "579a8978a922e6c57cebd001320f78674e040418" url: "https://github.com/bggRGjQaUbCoE/getx.git" source: git version: "4.7.2"