diff --git a/lib/http/danmaku.dart b/lib/http/danmaku.dart index 2ed2a415..7b4283ae 100644 --- a/lib/http/danmaku.dart +++ b/lib/http/danmaku.dart @@ -17,7 +17,9 @@ class DanmakaHttp { var response = await Request().get( Api.webDanmaku, data: params, - extra: {'resType': ResponseType.bytes}, + options: Options( + responseType: ResponseType.bytes, + ), ); return DmSegMobileReply.fromBuffer(response.data); } diff --git a/lib/http/init.dart b/lib/http/init.dart index e820102a..0868570f 100644 --- a/lib/http/init.dart +++ b/lib/http/init.dart @@ -209,24 +209,12 @@ class Request { */ get(url, {data, Options? options, cancelToken, extra}) async { Response response; - options ??= Options(); // 如果 options 为 null,则初始化一个新的 Options 对象 - ResponseType resType = ResponseType.json; - if (extra != null) { - resType = extra['resType'] ?? ResponseType.json; if (extra['ua'] != null) { - options.headers = {'user-agent': headerUa(type: extra['ua'])}; - } - if (extra['opus-goback'] != null) { - if (extra['opus-goback'] != null) { - String cookieHeader = dio.options.headers['cookie']; - options.headers!['cookie'] = - '$cookieHeader; opus-goback = ${extra['opus-goback']}'; - } + options ??= Options(); + options.headers!['user-agent'] = headerUa(type: extra['ua']); } } - options.responseType = resType; - try { response = await dio.get( url, diff --git a/lib/http/read.dart b/lib/http/read.dart index 5ea33519..f2542936 100644 --- a/lib/http/read.dart +++ b/lib/http/read.dart @@ -65,7 +65,12 @@ class ReadHttp { static Future parseArticleCv({required String id}) async { var res = await Request().get( 'https://www.bilibili.com/read/cv$id', - extra: {'ua': 'pc', 'opus-goback': '1'}, + extra: {'ua': 'pc'}, + options: Options( + headers: { + 'cookie': 'opus-goback=1', + }, + ), ); String scriptContent = extractScriptContents(parse(res.data).body!.outerHtml)[0];