mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 19:01:15 +00:00
Catch http error response
This commit is contained in:
@@ -4,15 +4,19 @@ import 'package:bridge_lib/bridge_lib.dart';
|
||||
getPopularAnime(MManga anime) async {
|
||||
final data = {"url": "${anime.baseUrl}/most-popular?page=${anime.page}"};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
|
||||
return animeElementM(res, anime);
|
||||
if (res.hasError) {
|
||||
return res;
|
||||
}
|
||||
return animeElementM(res.body, anime);
|
||||
}
|
||||
|
||||
getLatestUpdatesAnime(MManga anime) async {
|
||||
final data = {"url": "${anime.baseUrl}/top-airing?page=${anime.page}"};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
|
||||
return animeElementM(res, anime);
|
||||
if (res.hasError) {
|
||||
return res;
|
||||
}
|
||||
return animeElementM(res.body, anime);
|
||||
}
|
||||
|
||||
getAnimeDetail(MManga anime) async {
|
||||
@@ -24,11 +28,11 @@ getAnimeDetail(MManga anime) async {
|
||||
];
|
||||
final url = "${anime.baseUrl}${anime.link}";
|
||||
final data = {"url": url, "headers": null};
|
||||
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="anisc-info"]/div[contains(text(),"Status:")]/span[2]/text()')
|
||||
.first;
|
||||
@@ -70,7 +74,7 @@ getAnimeDetail(MManga anime) async {
|
||||
};
|
||||
final resEp = await MBridge.http('GET', json.encode(dataEp));
|
||||
|
||||
final html = json.decode(resEp)["html"];
|
||||
final html = json.decode(resEp.body)["html"];
|
||||
|
||||
final epUrls = MBridge.querySelectorAll(html,
|
||||
selector: "a.ep-item", typeElement: 3, attributes: "href", typeRegExp: 0);
|
||||
@@ -107,8 +111,10 @@ searchAnime(MManga anime) async {
|
||||
"url": "${anime.baseUrl}/search?keyword=${anime.query}&page=${anime.page}"
|
||||
};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
|
||||
return animeElementM(res, anime);
|
||||
if (res.hasError) {
|
||||
return res;
|
||||
}
|
||||
return animeElementM(res.body, anime);
|
||||
}
|
||||
|
||||
getVideoList(MManga anime) async {
|
||||
@@ -122,10 +128,10 @@ getVideoList(MManga anime) async {
|
||||
|
||||
final res = await MBridge.http('GET', json.encode(datas));
|
||||
|
||||
if (res.isEmpty) {
|
||||
return [];
|
||||
if (res.hasError) {
|
||||
return res;
|
||||
}
|
||||
final html = json.decode(res)["html"];
|
||||
final html = json.decode(res.body)["html"];
|
||||
|
||||
final names = MBridge.querySelectorAll(html,
|
||||
selector: "div.server-item",
|
||||
@@ -159,7 +165,7 @@ getVideoList(MManga anime) async {
|
||||
|
||||
final resE = await MBridge.http('GET', json.encode(datasE));
|
||||
String url = MBridge.substringBefore(
|
||||
MBridge.substringAfter(resE, "\"link\":\""), "\"");
|
||||
MBridge.substringAfter(resE.body, "\"link\":\""), "\"");
|
||||
print(url);
|
||||
List<MVideo> a = [];
|
||||
if (name.contains("Vidstreaming")) {
|
||||
|
||||
@@ -3,10 +3,11 @@ import 'package:bridge_lib/bridge_lib.dart';
|
||||
|
||||
getPopularAnime(MManga anime) async {
|
||||
final data = {"url": "${anime.baseUrl}/popular.html?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, '//*[@class="img"]/a/@href');
|
||||
anime.names = MBridge.xpath(res, '//*[@class="img"]/a/@title');
|
||||
anime.images = MBridge.xpath(res, '//*[@class="img"]/a/img/@src');
|
||||
@@ -17,10 +18,11 @@ getLatestUpdatesAnime(MManga anime) async {
|
||||
final url =
|
||||
"https://ajax.gogo-load.com/ajax/page-recent-release-ongoing.html?page=${anime.page}&type=1";
|
||||
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, '//*[@class="added_series_body popular"]/ul/li/a[1]/@href');
|
||||
anime.names = MBridge.xpath(
|
||||
@@ -46,10 +48,11 @@ getAnimeDetail(MManga anime) async {
|
||||
];
|
||||
|
||||
final data = {"url": "${anime.baseUrl}${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="anime_info_body_bg"]/p[@class="type"][5]/text()')
|
||||
@@ -70,7 +73,11 @@ getAnimeDetail(MManga anime) async {
|
||||
final urlEp =
|
||||
"https://ajax.gogo-load.com/ajax/load-list-episode?ep_start=0&ep_end=4000&id=$id";
|
||||
final dataEp = {"url": urlEp};
|
||||
final resEp = await MBridge.http('GET', json.encode(dataEp));
|
||||
final responseresEp = await MBridge.http('GET', json.encode(dataEp));
|
||||
if (responseresEp.hasError) {
|
||||
return response;
|
||||
}
|
||||
String resEp = responseresEp.body;
|
||||
anime.urls = MBridge.xpath(resEp, '//*[@id="episode_related"]/li/a/@href');
|
||||
final names = MBridge.xpath(
|
||||
resEp, '//*[@id="episode_related"]/li/a/div[@class="name"]/text()');
|
||||
@@ -88,11 +95,12 @@ getAnimeDetail(MManga anime) async {
|
||||
getVideoList(MManga anime) async {
|
||||
final datas = {"url": "${anime.baseUrl}${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 serverUrls =
|
||||
MBridge.xpath(res, '//*[@class="anime_muti_link"]/ul/li/a/@data-video');
|
||||
@@ -128,10 +136,11 @@ searchAnime(MManga anime) async {
|
||||
final url =
|
||||
"${anime.baseUrl}/search.html?keyword=${anime.query}&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, '//*[@class="img"]/a/@href');
|
||||
anime.names = MBridge.xpath(res, '//*[@class="img"]/a/@title');
|
||||
anime.images = MBridge.xpath(res, '//*[@class="img"]/a/img/@src');
|
||||
|
||||
@@ -6,10 +6,11 @@ getPopularAnime(MManga anime) async {
|
||||
"url":
|
||||
"${anime.baseUrl}/api/DramaList/List?page=${anime.page}&type=0&sub=0&country=0&status=0&order=1&pageSize=40"
|
||||
};
|
||||
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 jsonRes = json.decode(res);
|
||||
final datas = jsonRes["data"] as List;
|
||||
anime.names = datas.map((e) => e["title"]).toList();
|
||||
@@ -29,10 +30,11 @@ getLatestUpdatesAnime(MManga anime) async {
|
||||
"url":
|
||||
"${anime.baseUrl}/api/DramaList/List?page=${anime.page}&type=0&sub=0&country=0&status=0&order=12&pageSize=40"
|
||||
};
|
||||
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 jsonRes = json.decode(res);
|
||||
final datas = jsonRes["data"] as List;
|
||||
anime.names = datas.map((e) => e["title"]).toList();
|
||||
@@ -57,10 +59,11 @@ getAnimeDetail(MManga anime) async {
|
||||
];
|
||||
|
||||
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 jsonRes = json.decode(res);
|
||||
final status = jsonRes["status"] ?? "";
|
||||
print(status);
|
||||
@@ -99,17 +102,18 @@ getAnimeDetail(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 id = MBridge.substringAfter(
|
||||
MBridge.substringBefore(anime.link, ".png"), "Episode/");
|
||||
final jsonRes = json.decode(res);
|
||||
final subRes = await MBridge.http(
|
||||
'GET', json.encode({"url": "${anime.baseUrl}/api/Sub/$id"}));
|
||||
var jsonSubRes = json.decode(subRes);
|
||||
var jsonSubRes = json.decode(subRes.body);
|
||||
|
||||
List<MTrack> subtitles = [];
|
||||
|
||||
@@ -143,10 +147,11 @@ searchAnime(MManga anime) async {
|
||||
final data = {
|
||||
"url": "${anime.baseUrl}/api/DramaList/Search?q=${anime.query}&type=0"
|
||||
};
|
||||
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;
|
||||
var jsonRes = json.decode(res) as List;
|
||||
anime.names = jsonRes.map((e) => e["title"]).toList();
|
||||
anime.images = jsonRes.map((e) => e["thumbnail"] ?? "").toList();
|
||||
|
||||
Reference in New Issue
Block a user