mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 10:51:17 +00:00
Catch http error response
This commit is contained in:
@@ -3,33 +3,28 @@ import 'package:bridge_lib/bridge_lib.dart';
|
||||
|
||||
searchManga(MManga manga) async {
|
||||
final headers = getHeader(manga.baseUrl);
|
||||
|
||||
String res = "".toString();
|
||||
MHttpResponse response = MHttpResponse();
|
||||
if (!useNewQueryEndpoint(manga.source)) {
|
||||
final url = "${manga.apiUrl}/series/search";
|
||||
final body = {"term": manga.query};
|
||||
final data = {"url": url, "headers": headers, "body": body};
|
||||
res = await MBridge.http('POST', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
}
|
||||
response = await MBridge.http('POST', json.encode(data));
|
||||
} else {
|
||||
final newEndpointUrl =
|
||||
"${manga.apiUrl}/query/?page=${manga.page}&query_string=${manga.query}&series_status=All&order=desc&orderBy=total_views&perPage=12&tags_ids=[]&series_type=Comic";
|
||||
|
||||
final newEndpointData = {"url": newEndpointUrl, "headers": headers};
|
||||
res = await MBridge.http('GET', json.encode(newEndpointData));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
}
|
||||
response = await MBridge.http('GET', json.encode(newEndpointData));
|
||||
}
|
||||
|
||||
return MMangaRes(res, manga);
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
return mMangaRes(response, manga);
|
||||
}
|
||||
|
||||
getPopularManga(MManga manga) async {
|
||||
final headers = getHeader(manga.baseUrl);
|
||||
String res = "".toString();
|
||||
MHttpResponse response = MHttpResponse();
|
||||
if (!useNewQueryEndpoint(manga.source)) {
|
||||
final url = "${manga.apiUrl}/series/querysearch";
|
||||
print(url);
|
||||
@@ -47,8 +42,7 @@ getPopularManga(MManga manga) async {
|
||||
"sourceId": manga.sourceId,
|
||||
"body": body
|
||||
};
|
||||
|
||||
res = await MBridge.http('POST', json.encode(data));
|
||||
response = await MBridge.http('POST', json.encode(data));
|
||||
} else {
|
||||
final newEndpointUrl =
|
||||
"${manga.apiUrl}/query/?page=${manga.page}&query_string=&series_status=All&order=desc&orderBy=total_views&perPage=12&tags_ids=[]&series_type=Comic";
|
||||
@@ -58,17 +52,14 @@ getPopularManga(MManga manga) async {
|
||||
"headers": headers,
|
||||
"sourceId": manga.sourceId
|
||||
};
|
||||
res = await MBridge.http('GET', json.encode(newEndpointData));
|
||||
response = await MBridge.http('GET', json.encode(newEndpointData));
|
||||
}
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
}
|
||||
return MMangaRes(res, manga);
|
||||
return mMangaRes(response, manga);
|
||||
}
|
||||
|
||||
getLatestUpdatesManga(MManga manga) async {
|
||||
final headers = getHeader(manga.baseUrl);
|
||||
String res = "".toString();
|
||||
MHttpResponse response = MHttpResponse();
|
||||
if (!useNewQueryEndpoint(manga.source)) {
|
||||
final url = "${manga.apiUrl}/series/querysearch";
|
||||
final body = {
|
||||
@@ -84,20 +75,16 @@ getLatestUpdatesManga(MManga manga) async {
|
||||
"sourceId": manga.sourceId,
|
||||
"body": body
|
||||
};
|
||||
res = await MBridge.http('POST', json.encode(data));
|
||||
response = await MBridge.http('POST', json.encode(data));
|
||||
} else {
|
||||
final newEndpointUrl =
|
||||
"${manga.apiUrl}/query/?page=${manga.page}&query_string=&series_status=All&order=desc&orderBy=latest&perPage=12&tags_ids=[]&series_type=Comic";
|
||||
|
||||
final newEndpointData = {"url": newEndpointUrl, "headers": headers};
|
||||
res = await MBridge.http('GET', json.encode(newEndpointData));
|
||||
print(res);
|
||||
response = await MBridge.http('GET', json.encode(newEndpointData));
|
||||
}
|
||||
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
}
|
||||
return MMangaRes(res, manga);
|
||||
return mMangaRes(response, manga);
|
||||
}
|
||||
|
||||
getMangaDetail(MManga manga) async {
|
||||
@@ -105,11 +92,11 @@ getMangaDetail(MManga manga) async {
|
||||
final headers = getHeader(manga.baseUrl);
|
||||
final url = "${manga.apiUrl}/series/$currentSlug";
|
||||
final data = {"url": url, "headers": headers};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
print("${manga.apiUrl}/series/$currentSlug");
|
||||
String res = response.body;
|
||||
manga.author = MBridge.getMapValue(res, "author");
|
||||
|
||||
manga.description = MBridge.getMapValue(res, "description");
|
||||
@@ -159,18 +146,24 @@ getMangaDetail(MManga manga) async {
|
||||
}
|
||||
|
||||
getChapterPages(MManga manga) async {
|
||||
String res = "".toString();
|
||||
MHttpResponse response = MHttpResponse();
|
||||
final headers = getHeader(manga.baseUrl);
|
||||
|
||||
String res = "".toString();
|
||||
if (!useslugStrategy(manga.source)) {
|
||||
String chapterId = MBridge.substringAfter(manga.link, '#');
|
||||
|
||||
final url = "${manga.apiUrl}/series/chapter/$chapterId";
|
||||
final data = {"url": url, "headers": headers};
|
||||
res = await MBridge.http('GET', json.encode(data));
|
||||
response = await MBridge.http('GET', json.encode(data));
|
||||
res = response.body;
|
||||
} else {
|
||||
final url = "${manga.baseUrl}${manga.link}";
|
||||
final data = {"url": url, "headers": headers};
|
||||
res = await MBridge.http('GET', json.encode(data));
|
||||
response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
res = response.body;
|
||||
List<String> pageUrls = [];
|
||||
var imagesRes = MBridge.querySelectorAll(res,
|
||||
selector: "div.min-h-screen > div.container > p.items-center",
|
||||
@@ -183,9 +176,8 @@ getChapterPages(MManga manga) async {
|
||||
|
||||
return pageUrls.where((e) => e.isNotEmpty).toList();
|
||||
}
|
||||
|
||||
if (res.isEmpty) {
|
||||
return [];
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
final pages = MBridge.jsonPathToList(res, r"$.content.images[*]", 0);
|
||||
List<String> pageUrls = [];
|
||||
@@ -220,11 +212,11 @@ bool useslugStrategy(String sourceName) {
|
||||
return sources.contains(sourceName);
|
||||
}
|
||||
|
||||
MManga MMangaRes(String res, MManga manga) {
|
||||
MManga mMangaRes(MHttpResponse response, MManga manga) {
|
||||
String res = response.body;
|
||||
List<String> names = [];
|
||||
List<String> urls = [];
|
||||
List<String> images = [];
|
||||
|
||||
if (res.startsWith("{")) {
|
||||
for (var a in json.decode(res)["data"]) {
|
||||
String thumbnail = a["thumbnail"];
|
||||
|
||||
@@ -4,10 +4,11 @@ import 'package:bridge_lib/bridge_lib.dart';
|
||||
getPopularManga(MManga manga) async {
|
||||
final url = "${manga.baseUrl}/manga/page/${manga.page}/?m_orderby=views";
|
||||
final data = {"url": url, "sourceId": manga.sourceId};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
manga.urls = MBridge.xpath(res, '//*[@class^="post-title"]/h3/a/@href');
|
||||
var images = MBridge.xpath(res, '//*[@id^="manga-item"]/a/img/@data-src');
|
||||
if (images.isEmpty) {
|
||||
@@ -70,12 +71,13 @@ getMangaDetail(MManga manga) async {
|
||||
"Cancelado": 3,
|
||||
}
|
||||
];
|
||||
|
||||
MHttpResponse response = MHttpResponse();
|
||||
final datas = {"url": manga.link, "sourceId": manga.sourceId};
|
||||
final res = await MBridge.http('GET', json.encode(datas));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
response = await MBridge.http('GET', json.encode(datas));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
manga.author = MBridge.querySelectorAll(res,
|
||||
selector: "div.author-content > a",
|
||||
typeElement: 0,
|
||||
@@ -126,21 +128,23 @@ getMangaDetail(MManga manga) async {
|
||||
"${baseUrl}wp-admin/admin-ajax.php?action=manga_get_chapters&manga=$mangaId";
|
||||
final datasP = {"url": url, "headers": headers, "sourceId": manga.sourceId};
|
||||
|
||||
String resP = await MBridge.http('POST', json.encode(datasP));
|
||||
if (resP == "400") {
|
||||
response = await MBridge.http('POST', json.encode(datasP));
|
||||
if (response.statusCode != 200) {
|
||||
final urlP = "${manga.link}ajax/chapters";
|
||||
final datasP = {
|
||||
"url": urlP,
|
||||
"headers": headers,
|
||||
"sourceId": manga.sourceId
|
||||
};
|
||||
resP = await MBridge.http('POST', json.encode(datasP));
|
||||
response = await MBridge.http('POST', json.encode(datasP));
|
||||
}
|
||||
|
||||
String resP = response.body;
|
||||
manga.urls = MBridge.xpath(resP, "//li/a/@href");
|
||||
var chaptersNames = MBridge.xpath(resP, "//li/a/text()");
|
||||
|
||||
var dateF = MBridge.xpath(resP, "//li/span/i/text()");
|
||||
if (MBridge.xpath(resP, "//li/a/text()", "").isEmpty) {
|
||||
if (dateF.isEmpty) {
|
||||
final resWebview = await MBridge.getHtmlViaWebview(manga.link,
|
||||
"//*[@id='manga-chapters-holder']/div[2]/div/ul/li/a/@href");
|
||||
manga.urls = MBridge.xpath(resWebview,
|
||||
@@ -176,10 +180,11 @@ getMangaDetail(MManga manga) async {
|
||||
|
||||
getChapterPages(MManga manga) async {
|
||||
final datas = {"url": manga.link, "sourceId": manga.sourceId};
|
||||
final res = await MBridge.http('GET', json.encode(datas));
|
||||
if (res.isEmpty) {
|
||||
return [];
|
||||
final response = await MBridge.http('GET', json.encode(datas));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
final pagesSelectorRes = MBridge.querySelectorAll(res,
|
||||
selector:
|
||||
"div.page-break, li.blocks-gallery-item, .reading-content, .text-left img",
|
||||
@@ -225,10 +230,11 @@ getChapterPages(MManga manga) async {
|
||||
getLatestUpdatesManga(MManga manga) async {
|
||||
final url = "${manga.baseUrl}/manga/page/${manga.page}/?m_orderby=latest";
|
||||
final datas = {"url": url, "sourceId": manga.sourceId};
|
||||
final res = await MBridge.http('GET', json.encode(datas));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
final response = await MBridge.http('GET', json.encode(datas));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
manga.urls = MBridge.xpath(res, '//*[@class^="post-title"]/h3/a/@href');
|
||||
var images = MBridge.xpath(res, '//*[@id^="manga-item"]/a/img/@data-src');
|
||||
if (images.isEmpty) {
|
||||
@@ -248,10 +254,11 @@ getLatestUpdatesManga(MManga manga) async {
|
||||
searchManga(MManga manga) async {
|
||||
final urll = "${manga.baseUrl}/?s=${manga.query}&post_type=wp-manga";
|
||||
final datas = {"url": urll, "sourceId": manga.sourceId};
|
||||
final res = await MBridge.http('GET', json.encode(datas));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
final response = await MBridge.http('GET', json.encode(datas));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
manga.urls =
|
||||
MBridge.xpath(res, '//*[@class^="tab-thumb c-image-hover"]/a/@href');
|
||||
var images = MBridge.xpath(
|
||||
|
||||
@@ -2,28 +2,38 @@ import 'dart:convert';
|
||||
import 'package:bridge_lib/bridge_lib.dart';
|
||||
|
||||
getPopularManga(MManga manga) async {
|
||||
final url = "${manga.baseUrl}${getMangaUrlDirectory(manga.source)}/?page=${manga.page}&order=popular";
|
||||
final url =
|
||||
"${manga.baseUrl}${getMangaUrlDirectory(manga.source)}/?page=${manga.page}&order=popular";
|
||||
final data = {"url": url, "sourceId": manga.sourceId};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
manga.urls = MBridge.xpath(res, '//*[ @class="imgu" or @class="bsx"]/a/@href');
|
||||
manga.names = MBridge.xpath(res, '//*[ @class="imgu" or @class="bsx"]/a/@title');
|
||||
manga.images = MBridge.xpath(res, '//*[ @class="imgu" or @class="bsx"]/a/div[1]/img/@src');
|
||||
String res = response.body;
|
||||
manga.urls =
|
||||
MBridge.xpath(res, '//*[ @class="imgu" or @class="bsx"]/a/@href');
|
||||
manga.names =
|
||||
MBridge.xpath(res, '//*[ @class="imgu" or @class="bsx"]/a/@title');
|
||||
manga.images = MBridge.xpath(
|
||||
res, '//*[ @class="imgu" or @class="bsx"]/a/div[1]/img/@src');
|
||||
return manga;
|
||||
}
|
||||
|
||||
getLatestUpdatesManga(MManga manga) async {
|
||||
final url = "${manga.baseUrl}${getMangaUrlDirectory(manga.source)}/?page=${manga.page}&order=update";
|
||||
final url =
|
||||
"${manga.baseUrl}${getMangaUrlDirectory(manga.source)}/?page=${manga.page}&order=update";
|
||||
final data = {"url": url, "sourceId": manga.sourceId};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
manga.urls = MBridge.xpath(res, '//*[ @class="imgu" or @class="bsx"]/a/@href');
|
||||
manga.names = MBridge.xpath(res, '//*[ @class="imgu" or @class="bsx"]/a/@title');
|
||||
manga.images = MBridge.xpath(res, '//*[ @class="imgu" or @class="bsx"]/a/div[1]/img/@src');
|
||||
String res = response.body;
|
||||
manga.urls =
|
||||
MBridge.xpath(res, '//*[ @class="imgu" or @class="bsx"]/a/@href');
|
||||
manga.names =
|
||||
MBridge.xpath(res, '//*[ @class="imgu" or @class="bsx"]/a/@title');
|
||||
manga.images = MBridge.xpath(
|
||||
res, '//*[ @class="imgu" or @class="bsx"]/a/div[1]/img/@src');
|
||||
return manga;
|
||||
}
|
||||
|
||||
@@ -81,11 +91,11 @@ getMangaDetail(MManga manga) async {
|
||||
];
|
||||
|
||||
final datas = {"url": manga.link, "sourceId": manga.sourceId};
|
||||
final res = await MBridge.http('GET', json.encode(datas));
|
||||
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
final response = await MBridge.http('GET', json.encode(datas));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
manga.author = MBridge.xpath(
|
||||
res,
|
||||
'//*[@class="imptdt" and contains(text(), "Author") or @class="infotable" and contains(text(), "Author") or @class="infotable" and contains(text(), "Auteur") or @class="fmed" and contains(text(), "Auteur") or @class="infotable" and contains(text(), "Autor")]/text()',
|
||||
@@ -97,7 +107,10 @@ getMangaDetail(MManga manga) async {
|
||||
.replaceAll("[Add, ]", "");
|
||||
|
||||
manga.description = MBridge.querySelectorAll(res,
|
||||
selector: ".desc, .entry-content[itemprop=description]", typeElement: 0, attributes: "", typeRegExp: 0)
|
||||
selector: ".desc, .entry-content[itemprop=description]",
|
||||
typeElement: 0,
|
||||
attributes: "",
|
||||
typeRegExp: 0)
|
||||
.first;
|
||||
|
||||
final status = MBridge.xpath(
|
||||
@@ -111,7 +124,8 @@ getMangaDetail(MManga manga) async {
|
||||
|
||||
manga.status = MBridge.parseStatus(status, statusList);
|
||||
|
||||
manga.genre = MBridge.xpath(res, '//*[@class="gnr" or @class="mgen" or @class="seriestugenre" ]/a/text()');
|
||||
manga.genre = MBridge.xpath(res,
|
||||
'//*[@class="gnr" or @class="mgen" or @class="seriestugenre" ]/a/text()');
|
||||
manga.urls = MBridge.xpath(res,
|
||||
'//*[@class="bxcl" or @class="cl" or @class="chbox" or @class="eph-num" or @id="chapterlist"]/div/a[not(@href="#/chapter-{{number}}")]/@href');
|
||||
manga.names = MBridge.xpath(res,
|
||||
@@ -120,32 +134,37 @@ getMangaDetail(MManga manga) async {
|
||||
final chaptersDateUploads = MBridge.xpath(res,
|
||||
'//*[@class="bxcl" or @class="cl" or @class="chbox" or @class="eph-num" or @id="chapterlist"]/div/a/span[@class="chapterdate" and not(text()="{{date}}")]/text()');
|
||||
|
||||
manga.chaptersDateUploads = MBridge.listParseDateTime(chaptersDateUploads, manga.dateFormat, manga.dateFormatLocale);
|
||||
manga.chaptersDateUploads = MBridge.listParseDateTime(
|
||||
chaptersDateUploads, manga.dateFormat, manga.dateFormatLocale);
|
||||
|
||||
return manga;
|
||||
}
|
||||
|
||||
searchManga(MManga manga) async {
|
||||
final url = "${manga.baseUrl}${getMangaUrlDirectory(manga.source)}/?&title=${manga.query}&page=${manga.page}";
|
||||
final url =
|
||||
"${manga.baseUrl}${getMangaUrlDirectory(manga.source)}/?&title=${manga.query}&page=${manga.page}";
|
||||
final data = {"url": url, "sourceId": manga.sourceId};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
manga.urls = MBridge.xpath(res, '//*[ @class="imgu" or @class="bsx"]/a/@href');
|
||||
manga.names = MBridge.xpath(res, '//*[ @class="imgu" or @class="bsx"]/a/@title');
|
||||
manga.images = MBridge.xpath(res, '//*[ @class="imgu" or @class="bsx"]/a/div[1]/img/@src');
|
||||
String res = response.body;
|
||||
manga.urls =
|
||||
MBridge.xpath(res, '//*[ @class="imgu" or @class="bsx"]/a/@href');
|
||||
manga.names =
|
||||
MBridge.xpath(res, '//*[ @class="imgu" or @class="bsx"]/a/@title');
|
||||
manga.images = MBridge.xpath(
|
||||
res, '//*[ @class="imgu" or @class="bsx"]/a/div[1]/img/@src');
|
||||
return manga;
|
||||
}
|
||||
|
||||
getChapterPages(MManga manga) async {
|
||||
final datas = {"url": manga.link, "sourceId": manga.sourceId};
|
||||
|
||||
final res = await MBridge.http('GET', json.encode(datas));
|
||||
|
||||
if (res.isEmpty) {
|
||||
return [];
|
||||
final response = await MBridge.http('GET', json.encode(datas));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
var pages = [];
|
||||
List<String> pagesUrl = [];
|
||||
pages = MBridge.xpath(res, '//*[@id="readerarea"]/p/img/@src');
|
||||
@@ -153,7 +172,8 @@ getChapterPages(MManga manga) async {
|
||||
pages = MBridge.xpath(res, '//*[@id="readerarea"]/img/@src');
|
||||
}
|
||||
if (pages.isEmpty || pages.length == 1) {
|
||||
final images = MBridge.regExp(res, "\"images\"\\s*:\\s*(\\[.*?])", "", 1, 1);
|
||||
final images =
|
||||
MBridge.regExp(res, "\"images\"\\s*:\\s*(\\[.*?])", "", 1, 1);
|
||||
final pages = MBridge.jsonDecodeToList(images, 0);
|
||||
for (var page in pages) {
|
||||
pagesUrl.add(page);
|
||||
|
||||
@@ -4,10 +4,11 @@ import 'package:bridge_lib/bridge_lib.dart';
|
||||
searchManga(MManga manga) async {
|
||||
final url = "${manga.baseUrl}/search?query=${manga.query}";
|
||||
final data = {"url": url, "sourceId": manga.sourceId};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
final jsonList = json.decode(res)["suggestions"];
|
||||
List<String> urls = [];
|
||||
List<String> names = [];
|
||||
@@ -26,7 +27,8 @@ searchManga(MManga manga) async {
|
||||
if (manga.source == "Manga-FR") {
|
||||
images.add("${manga.baseUrl}/uploads/manga/$data.jpg");
|
||||
} else {
|
||||
images.add("${manga.baseUrl}/uploads/manga/$data/cover/cover_250x350.jpg");
|
||||
images
|
||||
.add("${manga.baseUrl}/uploads/manga/$data/cover/cover_250x350.jpg");
|
||||
}
|
||||
}
|
||||
manga.names = names;
|
||||
@@ -36,12 +38,14 @@ searchManga(MManga manga) async {
|
||||
}
|
||||
|
||||
getPopularManga(MManga manga) async {
|
||||
final url = "${manga.baseUrl}/filterList?page=${manga.page}&sortBy=views&asc=false";
|
||||
final url =
|
||||
"${manga.baseUrl}/filterList?page=${manga.page}&sortBy=views&asc=false";
|
||||
final data = {"url": url, "sourceId": manga.sourceId};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
manga.urls = MBridge.xpath(res, '//*[ @class="chart-title"]/@href');
|
||||
manga.names = MBridge.xpath(res, '//*[ @class="chart-title"]/text()');
|
||||
List<String> images = [];
|
||||
@@ -50,7 +54,8 @@ getPopularManga(MManga manga) async {
|
||||
if (manga.source == "Manga-FR") {
|
||||
images.add("${manga.baseUrl}/uploads/manga/${slug}.jpg");
|
||||
} else {
|
||||
images.add("${manga.baseUrl}/uploads/manga/${slug}/cover/cover_250x350.jpg");
|
||||
images.add(
|
||||
"${manga.baseUrl}/uploads/manga/${slug}/cover/cover_250x350.jpg");
|
||||
}
|
||||
}
|
||||
manga.images = images;
|
||||
@@ -77,10 +82,11 @@ getMangaDetail(MManga manga) async {
|
||||
];
|
||||
|
||||
final datas = {"url": manga.link, "sourceId": manga.sourceId};
|
||||
final res = await MBridge.http('GET', json.encode(datas));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
final response = await MBridge.http('GET', json.encode(datas));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
manga.author = MBridge.xpath(res,
|
||||
'//*[@class="dl-horizontal"]/dt[contains(text(), "Auteur(s)") or contains(text(), "Author(s)") or contains(text(), "Autor(es)") or contains(text(), "Yazar(lar) or contains(text(), "Mangaka(lar)")]//following-sibling::dd[1]/text()')
|
||||
.first;
|
||||
@@ -88,13 +94,17 @@ getMangaDetail(MManga manga) async {
|
||||
'//*[@class="dl-horizontal"]/dt[contains(text(), "Statut") or contains(text(), "Status") or contains(text(), "Estado") or contains(text(), "Durum")]/following-sibling::dd[1]/text()')
|
||||
.first;
|
||||
manga.status = MBridge.parseStatus(status, statusList);
|
||||
manga.description = MBridge.xpath(res, '//*[@class="well" or @class="manga well"]/p/text()').first;
|
||||
manga.description =
|
||||
MBridge.xpath(res, '//*[@class="well" or @class="manga well"]/p/text()')
|
||||
.first;
|
||||
manga.genre = MBridge.xpath(res,
|
||||
'//*[@class="dl-horizontal"]/dt[contains(text(), "Categories") or contains(text(), "Categorias") or contains(text(), "Categorías") or contains(text(), "Catégories") or contains(text(), "Kategoriler" or contains(text(), "Kategorie") or contains(text(), "Kategori") or contains(text(), "Tagi"))]/following-sibling::dd[1]/text()');
|
||||
manga.names = MBridge.xpath(res, '//*[@class="chapter-title-rtl"]/a/text()');
|
||||
manga.urls = MBridge.xpath(res, '//*[@class="chapter-title-rtl"]/a/@href');
|
||||
final date = MBridge.xpath(res, '//*[@class="date-chapter-title-rtl"]/text()');
|
||||
manga.chaptersDateUploads = MBridge.listParseDateTime(date, "d MMM. yyyy", "en_US");
|
||||
final date =
|
||||
MBridge.xpath(res, '//*[@class="date-chapter-title-rtl"]/text()');
|
||||
manga.chaptersDateUploads =
|
||||
MBridge.listParseDateTime(date, "d MMM. yyyy", "en_US");
|
||||
|
||||
return manga;
|
||||
}
|
||||
@@ -102,10 +112,11 @@ getMangaDetail(MManga manga) async {
|
||||
getLatestUpdatesManga(MManga manga) async {
|
||||
final url = "${manga.baseUrl}/latest-release?page=${manga.page}";
|
||||
final data = {"url": url, "sourceId": manga.sourceId};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
manga.urls = MBridge.xpath(res, '//*[@class="manga-item"]/h3/a/@href');
|
||||
manga.names = MBridge.xpath(res, '//*[@class="manga-item"]/h3/a/text()');
|
||||
List<String> images = [];
|
||||
@@ -114,7 +125,8 @@ getLatestUpdatesManga(MManga manga) async {
|
||||
if (manga.source == "Manga-FR") {
|
||||
images.add("${manga.baseUrl}/uploads/manga/${slug}.jpg");
|
||||
} else {
|
||||
images.add("${manga.baseUrl}/uploads/manga/${slug}/cover/cover_250x350.jpg");
|
||||
images.add(
|
||||
"${manga.baseUrl}/uploads/manga/${slug}/cover/cover_250x350.jpg");
|
||||
}
|
||||
}
|
||||
manga.images = images;
|
||||
@@ -123,12 +135,14 @@ getLatestUpdatesManga(MManga manga) async {
|
||||
|
||||
getChapterPages(MManga manga) async {
|
||||
final datas = {"url": manga.link, "sourceId": manga.sourceId};
|
||||
final res = await MBridge.http('GET', json.encode(datas));
|
||||
if (res.isEmpty) {
|
||||
return [];
|
||||
final response = await MBridge.http('GET', json.encode(datas));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
List<String> pagesUrl = [];
|
||||
final pages = MBridge.xpath(res, '//*[@id="all"]/img[@class="img-responsive"]/@data-src');
|
||||
final pages = MBridge.xpath(
|
||||
res, '//*[@id="all"]/img[@class="img-responsive"]/@data-src');
|
||||
for (var page in pages) {
|
||||
if (page.startsWith('//')) {
|
||||
pagesUrl.add(page.replaceAll('//', 'https://'));
|
||||
|
||||
@@ -3,10 +3,11 @@ import 'package:bridge_lib/bridge_lib.dart';
|
||||
|
||||
getPopularManga(MManga manga) async {
|
||||
final data = {"url": "${manga.baseUrl}/search/"};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
final directory = directoryFromDocument(res);
|
||||
final resSort = MBridge.sortMapList(json.decode(directory), "vm", 1);
|
||||
|
||||
@@ -15,10 +16,11 @@ getPopularManga(MManga manga) async {
|
||||
|
||||
getLatestUpdatesManga(MManga manga) async {
|
||||
final data = {"url": "${manga.baseUrl}/search/"};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
final directory = directoryFromDocument(res);
|
||||
final resSort = MBridge.sortMapList(json.decode(directory), "lt", 1);
|
||||
|
||||
@@ -27,10 +29,11 @@ getLatestUpdatesManga(MManga manga) async {
|
||||
|
||||
searchManga(MManga manga) async {
|
||||
final data = {"url": "${manga.baseUrl}/search/"};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
final directory = directoryFromDocument(res);
|
||||
final resSort = MBridge.sortMapList(json.decode(directory), "lt", 1);
|
||||
final datas = json.decode(resSort) as List;
|
||||
@@ -52,10 +55,11 @@ getMangaDetail(MManga manga) async {
|
||||
final headers = getHeader(manga.baseUrl);
|
||||
final url = '${manga.baseUrl}/manga/${manga.link}';
|
||||
final data = {"url": url, "headers": headers};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
manga.author = MBridge.xpath(res,
|
||||
'//li[contains(@class,"list-group-item") and contains(text(),"Author")]/a/text()')
|
||||
.first;
|
||||
@@ -99,7 +103,12 @@ getChapterPages(MManga manga) async {
|
||||
final url = '${manga.baseUrl}${manga.link}';
|
||||
List<String> pages = [];
|
||||
final data = {"url": url, "headers": headers};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
|
||||
final script =
|
||||
MBridge.xpath(res, '//script[contains(text(), "MainFunction")]/text()')
|
||||
.first;
|
||||
|
||||
Reference in New Issue
Block a user