diff --git a/lib/http/api.dart b/lib/http/api.dart index d12b1f982..a2f6337a8 100644 --- a/lib/http/api.dart +++ b/lib/http/api.dart @@ -19,8 +19,8 @@ class Api { static const String videoUrl = '/x/player/wbi/playurl'; // 番剧视频流 - // https://api.bilibili.com/pgc/player/web/playurl?cid=104236640&bvid=BV13t411n7ex - static const String bangumiVideoUrl = '/pgc/player/web/playurl'; + // https://api.bilibili.com/pgc/player/web/v2/playurl?cid=104236640&bvid=BV13t411n7ex + static const String bangumiVideoUrl = '/pgc/player/web/v2/playurl'; // 字幕 // aid, cid diff --git a/lib/http/video.dart b/lib/http/video.dart index e56ce23c7..f1aeff8dd 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -195,20 +195,24 @@ class VideoHttp { } // 视频流 - static Future videoUrl( - {int? avid, String? bvid, required int cid, int? qn}) async { + static Future videoUrl({ + int? avid, + String? bvid, + required int cid, + int? qn, + dynamic epid, + dynamic seasonId, + }) async { Map data = { + if (avid != null) 'avid': avid, + if (bvid != null) 'bvid': bvid, + if (epid != null) 'ep_id': epid, + if (seasonId != null) 'season_id': seasonId, 'cid': cid, 'qn': qn ?? 80, // 获取所有格式的视频 'fnval': 4048, }; - if (avid != null) { - data['avid'] = avid; - } - if (bvid != null) { - data['bvid'] = bvid; - } // 免登录查看1080p if ((GStorage.userInfo.get('userInfoCache') == null || @@ -226,11 +230,21 @@ class VideoHttp { }); try { - var res = await Request().get(Api.videoUrl, queryParameters: params); + var res = epid != null + ? await Request().get(Api.bangumiVideoUrl, queryParameters: params) + : await Request().get(Api.videoUrl, queryParameters: params); if (res.data['code'] == 0) { + late PlayUrlModel data; + if (epid != null) { + data = PlayUrlModel.fromJson(res.data['result']['video_info']) + ..lastPlayTime = res.data['result']['play_view_business_info'] + ['user_status']['watch_progress']['last_time']; + } else { + data = PlayUrlModel.fromJson(res.data['data']); + } return { 'status': true, - 'data': PlayUrlModel.fromJson(res.data['data']) + 'data': data, }; } else { return { diff --git a/lib/pages/bangumi/introduction/controller.dart b/lib/pages/bangumi/introduction/controller.dart index cfefc5d08..4f843619f 100644 --- a/lib/pages/bangumi/introduction/controller.dart +++ b/lib/pages/bangumi/introduction/controller.dart @@ -551,6 +551,10 @@ class BangumiIntroController extends CommonController { scriptContent['props']['pageProps']['followState']['isFollowed']; followStatus.value = scriptContent['props']['pageProps']['followState']['followStatus']; + // int progress = scriptContent['props']['pageProps']['dehydratedState'] + // ['queries'][0]['state']['data']['result'] + // ['play_view_business_info']['user_status']['watch_progress'] + // ['current_watch_progress']; } } } diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index 9437178f6..fd333aae5 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -1078,7 +1078,12 @@ class VideoDetailController extends GetxController defaultValue: AudioQuality.k192.code); }); } - var result = await VideoHttp.videoUrl(cid: cid.value, bvid: bvid); + var result = await VideoHttp.videoUrl( + cid: cid.value, + bvid: bvid, + epid: epId, + seasonId: seasonId, + ); if (result['status']) { data = result['data']; if (enableSponsorBlock) { diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index fc2bae2d9..a43929c18 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -34,6 +34,14 @@ class Utils { static const channel = MethodChannel("pilipalax"); + static void showCopyTextDialog(text) { + Get.dialog( + AlertDialog( + content: SelectableText('$text'), + ), + ); + } + static Future getWwebid(mid) async { try { dynamic response =