mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-15 03:10:59 +00:00
Catch http error response
This commit is contained in:
@@ -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()');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user