mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-15 19:30:29 +00:00
Refactor
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import 'dart:convert';
|
||||
import 'package:bridge_lib/bridge_lib.dart';
|
||||
|
||||
searchManga(MangaModel manga) async {
|
||||
searchManga(MManga manga) async {
|
||||
final headers = getHeader(manga.baseUrl);
|
||||
final url = "${manga.baseUrl}/search?title=${manga.query}&page=${manga.page}";
|
||||
|
||||
@@ -11,14 +11,16 @@ searchManga(MangaModel manga) async {
|
||||
return manga;
|
||||
}
|
||||
|
||||
manga.names = MBridge.xpath(res, '//*[contains(@class, "manga-list-4-list")]/li/a/@title');
|
||||
manga.images =
|
||||
MBridge.xpath(res, '//*[contains(@class, "manga-list-4-list")]/li/a/img[@class="manga-list-4-cover"]/@src');
|
||||
manga.urls = MBridge.xpath(res, '//*[contains(@class, "manga-list-4-list")]/li/a/@href');
|
||||
manga.names = MBridge.xpath(
|
||||
res, '//*[contains(@class, "manga-list-4-list")]/li/a/@title');
|
||||
manga.images = MBridge.xpath(res,
|
||||
'//*[contains(@class, "manga-list-4-list")]/li/a/img[@class="manga-list-4-cover"]/@src');
|
||||
manga.urls = MBridge.xpath(
|
||||
res, '//*[contains(@class, "manga-list-4-list")]/li/a/@href');
|
||||
return manga;
|
||||
}
|
||||
|
||||
getLatestUpdatesManga(MangaModel manga) async {
|
||||
getLatestUpdatesManga(MManga manga) async {
|
||||
final headers = getHeader(manga.baseUrl);
|
||||
final url = "${manga.baseUrl}/directory/${manga.page}.htm?latest";
|
||||
|
||||
@@ -28,14 +30,16 @@ getLatestUpdatesManga(MangaModel manga) async {
|
||||
return manga;
|
||||
}
|
||||
|
||||
manga.names = MBridge.xpath(res, '//*[ contains(@class, "manga-list-1-list")]/li/a/@title');
|
||||
manga.images =
|
||||
MBridge.xpath(res, '//*[ contains(@class, "manga-list-1-list")]/li/a/img[@class="manga-list-1-cover"]/@src');
|
||||
manga.urls = MBridge.xpath(res, '//*[ contains(@class, "manga-list-1-list")]/li/a/@href');
|
||||
manga.names = MBridge.xpath(
|
||||
res, '//*[ contains(@class, "manga-list-1-list")]/li/a/@title');
|
||||
manga.images = MBridge.xpath(res,
|
||||
'//*[ contains(@class, "manga-list-1-list")]/li/a/img[@class="manga-list-1-cover"]/@src');
|
||||
manga.urls = MBridge.xpath(
|
||||
res, '//*[ contains(@class, "manga-list-1-list")]/li/a/@href');
|
||||
return manga;
|
||||
}
|
||||
|
||||
getMangaDetail(MangaModel manga) async {
|
||||
getMangaDetail(MManga manga) async {
|
||||
final statusList = [
|
||||
{
|
||||
"Ongoing": 0,
|
||||
@@ -49,20 +53,28 @@ getMangaDetail(MangaModel manga) async {
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
}
|
||||
manga.author = MBridge.xpath(res, '//*[@class="detail-info-right-say"]/a/text()').first;
|
||||
manga.description = MBridge.xpath(res, '//*[@class="fullcontent"]/text()').first;
|
||||
final status = MBridge.xpath(res, '//*[@class="detail-info-right-title-tip"]/text()').first;
|
||||
manga.author =
|
||||
MBridge.xpath(res, '//*[@class="detail-info-right-say"]/a/text()').first;
|
||||
manga.description =
|
||||
MBridge.xpath(res, '//*[@class="fullcontent"]/text()').first;
|
||||
final status =
|
||||
MBridge.xpath(res, '//*[@class="detail-info-right-title-tip"]/text()')
|
||||
.first;
|
||||
manga.status = MBridge.parseStatus(status, statusList);
|
||||
manga.genre = MBridge.xpath(res, '//*[@class="detail-info-right-tag-list"]/a/text()');
|
||||
manga.genre =
|
||||
MBridge.xpath(res, '//*[@class="detail-info-right-tag-list"]/a/text()');
|
||||
manga.urls = MBridge.xpath(res, '//*[@class="detail-main-list"]/li/a/@href');
|
||||
manga.names = MBridge.xpath(res, '//*[@class="detail-main-list"]/li/a/div/p[@class="title3"]/text()');
|
||||
final chapterDates = MBridge.xpath(res, '//*[@class="detail-main-list"]/li/a/div/p[@class="title2"]/text()');
|
||||
manga.names = MBridge.xpath(
|
||||
res, '//*[@class="detail-main-list"]/li/a/div/p[@class="title3"]/text()');
|
||||
final chapterDates = MBridge.xpath(
|
||||
res, '//*[@class="detail-main-list"]/li/a/div/p[@class="title2"]/text()');
|
||||
|
||||
manga.chaptersDateUploads = MBridge.listParseDateTime(chapterDates, manga.dateFormat, manga.dateFormatLocale);
|
||||
manga.chaptersDateUploads = MBridge.listParseDateTime(
|
||||
chapterDates, manga.dateFormat, manga.dateFormatLocale);
|
||||
return manga;
|
||||
}
|
||||
|
||||
getPopularManga(MangaModel manga) async {
|
||||
getPopularManga(MManga manga) async {
|
||||
final headers = getHeader(manga.baseUrl);
|
||||
final url = "${manga.baseUrl}/directory/${manga.page}.htm";
|
||||
|
||||
@@ -72,14 +84,16 @@ getPopularManga(MangaModel manga) async {
|
||||
return manga;
|
||||
}
|
||||
|
||||
manga.names = MBridge.xpath(res, '//*[ contains(@class, "manga-list-1-list")]/li/a/@title');
|
||||
manga.images =
|
||||
MBridge.xpath(res, '//*[ contains(@class, "manga-list-1-list")]/li/a/img[@class="manga-list-1-cover"]/@src');
|
||||
manga.urls = MBridge.xpath(res, '//*[ contains(@class, "manga-list-1-list")]/li/a/@href');
|
||||
manga.names = MBridge.xpath(
|
||||
res, '//*[ contains(@class, "manga-list-1-list")]/li/a/@title');
|
||||
manga.images = MBridge.xpath(res,
|
||||
'//*[ contains(@class, "manga-list-1-list")]/li/a/img[@class="manga-list-1-cover"]/@src');
|
||||
manga.urls = MBridge.xpath(
|
||||
res, '//*[ contains(@class, "manga-list-1-list")]/li/a/@href');
|
||||
return manga;
|
||||
}
|
||||
|
||||
getChapterUrl(MangaModel manga) async {
|
||||
getChapterPages(MManga manga) async {
|
||||
final headers = getHeader(manga.baseUrl);
|
||||
final url = "${manga.baseUrl}${manga.link}";
|
||||
final data = {"url": url, "headers": headers};
|
||||
@@ -90,32 +104,41 @@ getChapterUrl(MangaModel manga) async {
|
||||
final pages = MBridge.xpath(res, "//body/div/div/span/a/text()");
|
||||
List<String> pageUrls = [];
|
||||
if (pages.isEmpty) {
|
||||
final script =
|
||||
MBridge.xpath(res, "//script[contains(text(),'function(p,a,c,k,e,d)')]/text()").first.replaceAll("eval", "");
|
||||
final script = MBridge.xpath(
|
||||
res, "//script[contains(text(),'function(p,a,c,k,e,d)')]/text()")
|
||||
.first
|
||||
.replaceAll("eval", "");
|
||||
String deobfuscatedScript = MBridge.evalJs(script);
|
||||
int a = deobfuscatedScript.indexOf("newImgs=['") + 10;
|
||||
int b = deobfuscatedScript.indexOf("'];");
|
||||
List<String> urls = MBridge.listParse(deobfuscatedScript.substring(a, b).split("','"), 0);
|
||||
List<String> urls = deobfuscatedScript.substring(a, b).split("','");
|
||||
for (var url in urls) {
|
||||
pageUrls.add("https:$url");
|
||||
}
|
||||
} else {
|
||||
final pagesNumberList = pages;
|
||||
int pagesNumber = MBridge.intParse(pagesNumberList[pagesNumberList.length - 2]);
|
||||
int pagesNumber =
|
||||
MBridge.intParse(pagesNumberList[pagesNumberList.length - 2]);
|
||||
int secretKeyScriptLocation = res.indexOf("eval(function(p,a,c,k,e,d)");
|
||||
int secretKeyScriptEndLocation = res.indexOf("</script>", secretKeyScriptLocation);
|
||||
String secretKeyScript = res.substring(secretKeyScriptLocation, secretKeyScriptEndLocation).replaceAll("eval", "");
|
||||
int secretKeyScriptEndLocation =
|
||||
res.indexOf("</script>", secretKeyScriptLocation);
|
||||
String secretKeyScript = res
|
||||
.substring(secretKeyScriptLocation, secretKeyScriptEndLocation)
|
||||
.replaceAll("eval", "");
|
||||
String secretKeyDeobfuscatedScript = MBridge.evalJs(secretKeyScript);
|
||||
int secretKeyStartLoc = secretKeyDeobfuscatedScript.indexOf("'");
|
||||
int secretKeyEndLoc = secretKeyDeobfuscatedScript.indexOf(";");
|
||||
|
||||
String secretKey = secretKeyDeobfuscatedScript.substring(secretKeyStartLoc, secretKeyEndLoc);
|
||||
String secretKey = secretKeyDeobfuscatedScript.substring(
|
||||
secretKeyStartLoc, secretKeyEndLoc);
|
||||
int chapterIdStartLoc = res.indexOf("chapterid");
|
||||
String chapterId = res.substring(chapterIdStartLoc + 11, res.indexOf(";", chapterIdStartLoc));
|
||||
String chapterId = res.substring(
|
||||
chapterIdStartLoc + 11, res.indexOf(";", chapterIdStartLoc));
|
||||
String pageBase = url.substring(0, url.lastIndexOf("/"));
|
||||
for (int i = 1; i <= pagesNumber; i++) {
|
||||
String pageLink = "$pageBase/chapterfun.ashx?cid=$chapterId&page=$i&key=$secretKey";
|
||||
String responseText = MBridge.stringParse("", 0);
|
||||
String pageLink =
|
||||
"$pageBase/chapterfun.ashx?cid=$chapterId&page=$i&key=$secretKey";
|
||||
String responseText = "".toString();
|
||||
for (int tr = 1; tr <= 3; tr++) {
|
||||
if (responseText.isEmpty) {
|
||||
final headers = {
|
||||
@@ -127,23 +150,26 @@ getChapterUrl(MangaModel manga) async {
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
};
|
||||
final data = {"url": pageLink, "headers": headers};
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
responseText = MBridge.stringParse(response, 0);
|
||||
responseText = await MBridge.http('GET', json.encode(data));
|
||||
|
||||
if (responseText.isEmpty) {
|
||||
secretKey = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
String deobfuscatedScript = MBridge.evalJs(responseText.replaceAll("eval", ""));
|
||||
String deobfuscatedScript =
|
||||
MBridge.evalJs(responseText.replaceAll("eval", ""));
|
||||
|
||||
int baseLinkStartPos = deobfuscatedScript.indexOf("pix=") + 5;
|
||||
int baseLinkEndPos = deobfuscatedScript.indexOf(";", baseLinkStartPos) - 1;
|
||||
String baseLink = deobfuscatedScript.substring(baseLinkStartPos, baseLinkEndPos);
|
||||
int baseLinkEndPos =
|
||||
deobfuscatedScript.indexOf(";", baseLinkStartPos) - 1;
|
||||
String baseLink =
|
||||
deobfuscatedScript.substring(baseLinkStartPos, baseLinkEndPos);
|
||||
|
||||
int imageLinkStartPos = deobfuscatedScript.indexOf("pvalue=") + 9;
|
||||
int imageLinkEndPos = deobfuscatedScript.indexOf("\"", imageLinkStartPos);
|
||||
String imageLink = deobfuscatedScript.substring(imageLinkStartPos, imageLinkEndPos);
|
||||
String imageLink =
|
||||
deobfuscatedScript.substring(imageLinkStartPos, imageLinkEndPos);
|
||||
pageUrls.add("https:$baseLink$imageLink");
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import '../../../../model/source.dart';
|
||||
import '../../../../utils/utils.dart';
|
||||
|
||||
Source get mangahereSource => _mangahereSource;
|
||||
const mangahereVersion = "0.0.2";
|
||||
const mangahereVersion = "0.0.3";
|
||||
const mangahereSourceCodeUrl =
|
||||
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/main/manga/src/en/mangahere/mangahere-v$mangahereVersion.dart";
|
||||
Source _mangahereSource = Source(
|
||||
|
||||
Reference in New Issue
Block a user