Catch http error response

This commit is contained in:
kodjomoustapha
2023-10-25 19:02:57 +01:00
parent 6eac32b58c
commit c07bcd6032
16 changed files with 511 additions and 361 deletions

View File

@@ -3,10 +3,11 @@ import 'package:bridge_lib/bridge_lib.dart';
getPopularAnime(MManga anime) async {
final data = {"url": "https://www.okanime.xyz"};
final res = await MBridge.http('GET', json.encode(data));
if (res.isEmpty) {
return anime;
final response = await MBridge.http('GET', json.encode(data));
if (response.hasError) {
return response;
}
String res = response.body;
anime.urls = MBridge.xpath(res,
'//div[@class="section" and contains(text(),"افضل انميات")]/div[@class="section-content"]/div/div/div[contains(@class,"anime-card")]/div[@class="anime-title")]/h4/a/@href');
@@ -24,10 +25,11 @@ getAnimeDetail(MManga anime) async {
{"يعرض الان": 0, "مكتمل": 1}
];
final data = {"url": anime.link};
final res = await MBridge.http('GET', json.encode(data));
if (res.isEmpty) {
return anime;
final response = await MBridge.http('GET', json.encode(data));
if (response.hasError) {
return response;
}
String res = response.body;
final status = MBridge.xpath(res,
'//*[@class="full-list-info" and contains(text(),"حالة الأنمي")]/small/a/text()');
@@ -56,10 +58,11 @@ getLatestUpdatesAnime(MManga anime) async {
final data = {
"url": "https://www.okanime.xyz/espisode-list?page=${anime.page}"
};
final res = await MBridge.http('GET', json.encode(data));
if (res.isEmpty) {
return anime;
final response = await MBridge.http('GET', json.encode(data));
if (response.hasError) {
return response;
}
String res = response.body;
anime.urls = MBridge.xpath(res,
'//*[contains(@class,"anime-card")]/div[@class="anime-title")]/h4/a/@href');
@@ -84,10 +87,11 @@ searchAnime(MManga anime) async {
url += "&page=${anime.page}";
}
final data = {"url": url};
final res = await MBridge.http('GET', json.encode(data));
if (res.isEmpty) {
return anime;
final response = await MBridge.http('GET', json.encode(data));
if (response.hasError) {
return response;
}
String res = response.body;
anime.urls = MBridge.xpath(res,
'//*[contains(@class,"anime-card")]/div[@class="anime-title")]/h4/a/@href');
@@ -108,11 +112,12 @@ searchAnime(MManga anime) async {
getVideoList(MManga anime) async {
final datas = {"url": anime.link};
final res = await MBridge.http('GET', json.encode(datas));
final response = await MBridge.http('GET', json.encode(datas));
if (res.isEmpty) {
return [];
if (response.hasError) {
return response;
}
String res = response.body;
final urls = MBridge.xpath(res, '//*[@id="streamlinks"]/a/@data-src');
final qualities = MBridge.xpath(res, '//*[@id="streamlinks"]/a/span/text()');