diff --git a/lib/http/api.dart b/lib/http/api.dart index ccbb3bb3..c8edf863 100644 --- a/lib/http/api.dart +++ b/lib/http/api.dart @@ -11,7 +11,7 @@ class Api { // 视频流 // https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/video/videostream_url.md - static const String videoUrl = '/x/player/playurl'; + static const String videoUrl = '/x/player/wbi/playurl'; // 视频详情 // 竖屏 https://api.bilibili.com/x/web-interface/view?aid=527403921 diff --git a/lib/http/video.dart b/lib/http/video.dart index b4622f02..f97ac277 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -122,27 +122,33 @@ class VideoHttp { static Future videoUrl( {int? avid, String? bvid, required int cid, int? qn}) async { Map data = { - // 'avid': avid, - 'bvid': bvid, 'cid': cid, - // 'qn': qn ?? 80, + 'qn': qn ?? 80, // 获取所有格式的视频 'fnval': 4048, - // 'fnver': '', - 'fourk': 1, - // 'session': '', - // 'otype': '', - // 'type': '', - // 'platform': '', - // 'high_quality': '' }; + if (avid != null) { + data['avid'] = avid; + } + if (bvid != null) { + data['bvid'] = bvid; + } + + Map params = await WbiSign().makSign({ + ...data, + 'fourk': 1, + 'voice_balance': 1, + 'gaia_source': 'pre-load', + 'web_location': 1550101, + }); + // 免登录查看1080p if (userInfoCache.get('userInfoCache') == null && setting.get(SettingBoxKey.p1080, defaultValue: true)) { data['try_look'] = 1; } try { - var res = await Request().get(Api.videoUrl, data: data); + var res = await Request().get(Api.videoUrl, data: params); if (res.data['code'] == 0) { return { 'status': true,