mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
fix: failed to view article
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -17,7 +17,7 @@ class DanmakaHttp {
|
|||||||
var response = await Request().get(
|
var response = await Request().get(
|
||||||
Api.webDanmaku,
|
Api.webDanmaku,
|
||||||
data: params,
|
data: params,
|
||||||
extra: {'resType': ResponseType.bytes},
|
options: Options(responseType: ResponseType.bytes),
|
||||||
);
|
);
|
||||||
if (response.statusCode != 200 || response.data == null) {
|
if (response.statusCode != 200 || response.data == null) {
|
||||||
return DmSegMobileReply();
|
return DmSegMobileReply();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:PiliPalaX/models/dynamics/article_content_model.dart';
|
import 'package:PiliPalaX/models/dynamics/article_content_model.dart';
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:html/dom.dart' as dom;
|
import 'package:html/dom.dart' as dom;
|
||||||
import 'package:html/parser.dart' as parser;
|
import 'package:html/parser.dart' as parser;
|
||||||
@@ -76,6 +77,11 @@ class HtmlHttp {
|
|||||||
var response = await Request().get(
|
var response = await Request().get(
|
||||||
"https://www.bilibili.com/$dynamicType/$id/",
|
"https://www.bilibili.com/$dynamicType/$id/",
|
||||||
extra: {'ua': 'pc'},
|
extra: {'ua': 'pc'},
|
||||||
|
options: Options(
|
||||||
|
headers: {
|
||||||
|
'cookie': 'opus-goback=1',
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
if (response.data is! String && response.data is! List<int>) {
|
if (response.data is! String && response.data is! List<int>) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -191,15 +191,13 @@ class Request {
|
|||||||
*/
|
*/
|
||||||
Future get(url, {data, options, cancelToken, extra}) async {
|
Future get(url, {data, options, cancelToken, extra}) async {
|
||||||
Response response;
|
Response response;
|
||||||
options ??= Options();
|
|
||||||
ResponseType resType = ResponseType.json;
|
|
||||||
if (extra != null) {
|
if (extra != null) {
|
||||||
resType = extra!['resType'] ?? ResponseType.json;
|
|
||||||
if (extra['ua'] != null) {
|
if (extra['ua'] != null) {
|
||||||
options.headers = {'user-agent': headerUa(type: extra['ua'])};
|
options ??= Options();
|
||||||
|
options.headers ??= <String, dynamic>{};
|
||||||
|
options.headers!['user-agent'] = headerUa(type: extra['ua']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
options.responseType = resType;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
response = await dio.get(
|
response = await dio.get(
|
||||||
|
|||||||
Reference in New Issue
Block a user