mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 10:51:17 +00:00
WIP
This commit is contained in:
@@ -1,228 +0,0 @@
|
||||
import 'dart:convert';
|
||||
import 'package:bridge_lib/bridge_lib.dart';
|
||||
|
||||
getPopularManga(MManga manga) async {
|
||||
final url =
|
||||
"${manga.baseUrl}/browse?${lang(manga.lang)}&sort=views_a&page=${manga.page}";
|
||||
final data = {"url": url, "sourceId": manga.sourceId};
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
return mangaElementM(res, manga);
|
||||
}
|
||||
|
||||
String lang(String lang) {
|
||||
lang = lang.replaceAll("-", "_");
|
||||
if (lang == "all") {
|
||||
return "";
|
||||
}
|
||||
return "langs=$lang";
|
||||
}
|
||||
|
||||
getLatestUpdatesManga(MManga manga) async {
|
||||
final url =
|
||||
"${manga.baseUrl}/browse?${lang(manga.lang)}&sort=update&page=${manga.page}";
|
||||
final data = {"url": url, "sourceId": manga.sourceId};
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
return mangaElementM(res, manga);
|
||||
}
|
||||
|
||||
searchManga(MManga manga) async {
|
||||
final data = {
|
||||
"url": "${manga.baseUrl}/search?word=${manga.query}&page=${manga.page}",
|
||||
"sourceId": manga.sourceId
|
||||
};
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
return mangaElementM(res, manga);
|
||||
}
|
||||
|
||||
getMangaDetail(MManga manga) async {
|
||||
final statusList = [
|
||||
{
|
||||
"Ongoing": 0,
|
||||
"Completed": 1,
|
||||
"Cancelled": 3,
|
||||
"Hiatus": 2,
|
||||
}
|
||||
];
|
||||
|
||||
final url = "${manga.baseUrl}${manga.link}";
|
||||
final data = {"url": url, "sourceId": manga.sourceId};
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
|
||||
final workStatus = MBridge.xpath(res,
|
||||
'//*[@class="attr-item"]/b[contains(text(),"Original work")]/following-sibling::span[1]/text()')
|
||||
.first;
|
||||
manga.status = MBridge.parseStatus(workStatus, statusList);
|
||||
|
||||
manga.author = MBridge.xpath(res,
|
||||
'//*[@class="attr-item"]/b[contains(text(),"Authors")]/following-sibling::span[1]/text()')
|
||||
.first;
|
||||
manga.genre = MBridge.xpath(res,
|
||||
'//*[@class="attr-item"]/b[contains(text(),"Genres")]/following-sibling::span[1]/text()')
|
||||
.first
|
||||
.split(",");
|
||||
manga.description =
|
||||
MBridge.xpath(res, '//*[@class="limit-html"]/text()').first;
|
||||
|
||||
List<String> chapsElement = MBridge.querySelectorAll(res,
|
||||
selector: "div.main div.p-2",
|
||||
typeElement: 2,
|
||||
attributes: "",
|
||||
typeRegExp: 0);
|
||||
List<String> times = [];
|
||||
List<String> chapsUrls = [];
|
||||
List<String> chapsNames = [];
|
||||
List<String> scanlators = [];
|
||||
for (var element in chapsElement) {
|
||||
final urlElement = MBridge.querySelectorAll(element,
|
||||
selector: "a.chapt", typeElement: 2, attributes: "", typeRegExp: 0)
|
||||
.first;
|
||||
final group = MBridge.xpath(element, '//*[@class="extra"]/a/text()').first;
|
||||
final name = MBridge.xpath(urlElement, '//a/text()').first;
|
||||
final url = MBridge.xpath(urlElement, '//a/@href').first;
|
||||
final time =
|
||||
MBridge.xpath(element, '//*[@class="extra"]/i[@class="ps-3"]/text()')
|
||||
.first;
|
||||
times.add(time);
|
||||
chapsUrls.add(url);
|
||||
scanlators.add(group);
|
||||
chapsNames.add(name.replaceAll("\n ", "").replaceAll(" ", ""));
|
||||
}
|
||||
|
||||
manga.urls = chapsUrls;
|
||||
manga.names = chapsNames;
|
||||
manga.chaptersScanlators = scanlators;
|
||||
manga.chaptersDateUploads =
|
||||
MBridge.listParseDateTime(times, "MMM dd,yyyy", "en");
|
||||
|
||||
return manga;
|
||||
}
|
||||
|
||||
getChapterPages(MManga manga) async {
|
||||
final datas = {
|
||||
"url": "${manga.baseUrl}${manga.link}",
|
||||
"sourceId": manga.sourceId
|
||||
};
|
||||
final response = await MBridge.http('GET', json.encode(datas));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
final script = MBridge.xpath(res,
|
||||
'//script[contains(text(), "imgHttpLis") and contains(text(), "batoWord") and contains(text(), "batoPass")]/text()')
|
||||
.first;
|
||||
final imgHttpLisString = MBridge.substringBefore(
|
||||
MBridge.substringAfterLast(script, 'const imgHttpLis ='), ';');
|
||||
var imgHttpLis = json.decode(imgHttpLisString);
|
||||
final batoWord = MBridge.substringBefore(
|
||||
MBridge.substringAfterLast(script, 'const batoWord ='), ';');
|
||||
final batoPass = MBridge.substringBefore(
|
||||
MBridge.substringAfterLast(script, 'const batoPass ='), ';');
|
||||
final evaluatedPass = MBridge.deobfuscateJsPassword(batoPass);
|
||||
final imgAccListString =
|
||||
MBridge.decryptAESCryptoJS(batoWord.replaceAll('"', ""), evaluatedPass);
|
||||
var imgAccList = json.decode(imgAccListString);
|
||||
List<String> pagesUrl = [];
|
||||
for (int i = 0; i < imgHttpLis.length; i++) {
|
||||
String imgUrl = imgHttpLis[i];
|
||||
String imgAcc = imgAccList[i];
|
||||
pagesUrl.add("$imgUrl?$imgAcc");
|
||||
}
|
||||
|
||||
return pagesUrl;
|
||||
}
|
||||
|
||||
MManga mangaElementM(String res, MManga manga) async {
|
||||
final lang = manga.lang.replaceAll("-", "_");
|
||||
|
||||
var resB = MBridge.querySelectorAll(res,
|
||||
selector: "div#series-list div.col",
|
||||
typeElement: 2,
|
||||
attributes: "",
|
||||
typeRegExp: 0);
|
||||
|
||||
List<String> images = [];
|
||||
List<String> urls = [];
|
||||
List<String> names = [];
|
||||
|
||||
for (var element in resB) {
|
||||
if (manga.lang == "all" ||
|
||||
manga.lang == "en" && element.contains('no-flag') ||
|
||||
element.contains('data-lang="$lang"')) {
|
||||
final item = MBridge.querySelectorAll(element,
|
||||
selector: "a.item-cover",
|
||||
typeElement: 2,
|
||||
attributes: "",
|
||||
typeRegExp: 0)
|
||||
.first;
|
||||
final img = MBridge.querySelectorAll(item,
|
||||
selector: "img", typeElement: 3, attributes: "src", typeRegExp: 0)
|
||||
.first;
|
||||
final url = MBridge.querySelectorAll(item,
|
||||
selector: "a", typeElement: 3, attributes: "href", typeRegExp: 0)
|
||||
.first;
|
||||
images.add(img);
|
||||
urls.add(url);
|
||||
final title = MBridge.querySelectorAll(element,
|
||||
selector: "a.item-title",
|
||||
typeElement: 0,
|
||||
attributes: "",
|
||||
typeRegExp: 0)
|
||||
.first;
|
||||
names.add(title);
|
||||
}
|
||||
}
|
||||
manga.urls = urls;
|
||||
manga.names = names;
|
||||
manga.images = images;
|
||||
final nextPage = MBridge.xpath(res,
|
||||
'//li[@class="page-item disabled"]/a/span[contains(text(),"»")]/text()');
|
||||
manga.hasNextPage = true;
|
||||
|
||||
return manga;
|
||||
}
|
||||
|
||||
Map<String, String> getMirrorPref() {
|
||||
return {
|
||||
"bato.to": "https://bato.to",
|
||||
"batocomic.com": "https://batocomic.com",
|
||||
"batocomic.net": "https://batocomic.net",
|
||||
"batocomic.org": "https://batocomic.org",
|
||||
"batotoo.com": "https://batotoo.com",
|
||||
"batotwo.com": "https://batotwo.com",
|
||||
"battwo.com": "https://battwo.com",
|
||||
"comiko.net": "https://comiko.net",
|
||||
"comiko.org": "https://comiko.org",
|
||||
"mangatoto.com": "https://mangatoto.com",
|
||||
"mangatoto.net": "https://mangatoto.net",
|
||||
"mangatoto.org": "https://mangatoto.org",
|
||||
"readtoto.com": "https://readtoto.com",
|
||||
"readtoto.net": "https://readtoto.net",
|
||||
"readtoto.org": "https://readtoto.org",
|
||||
"dto.to": "https://dto.to",
|
||||
"hto.to": "https://hto.to",
|
||||
"mto.to": "https://mto.to",
|
||||
"wto.to": "https://wto.to",
|
||||
"xbato.com": "https://xbato.com",
|
||||
"xbato.net": "https://xbato.net",
|
||||
"xbato.org": "https://xbato.org",
|
||||
"zbato.com": "https://zbato.com",
|
||||
"zbato.net": "https://zbato.net",
|
||||
"zbato.org": "https://zbato.org",
|
||||
};
|
||||
}
|
||||
241
manga/src/all/batoto/batoto-v0.0.35.dart
Normal file
241
manga/src/all/batoto/batoto-v0.0.35.dart
Normal file
@@ -0,0 +1,241 @@
|
||||
import 'package:mangayomi/bridge_lib.dart';
|
||||
import 'package:mangayomi/utils.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
class Batoto extends MSourceProvider {
|
||||
Batoto();
|
||||
|
||||
@override
|
||||
Future<MPages> getPopular(MSource sourceInfo, int page) async {
|
||||
final url =
|
||||
"${sourceInfo.baseUrl}/browse?${lang(sourceInfo.lang)}&sort=views_a&page=$page";
|
||||
final data = {"url": url};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
return mangaElementM(res, sourceInfo);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MPages> getLatestUpdates(MSource sourceInfo, int page) async {
|
||||
final url =
|
||||
"${sourceInfo.baseUrl}/browse?${lang(sourceInfo.lang)}&sort=update&page=$page";
|
||||
final data = {"url": url};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
return mangaElementM(res, sourceInfo);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MPages> search(MSource sourceInfo, String query, int page) async {
|
||||
final url = "${sourceInfo.baseUrl}/search?word=$query&page=$page";
|
||||
final data = {"url": url};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
return mangaElementM(res, sourceInfo);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MManga> getDetail(MSource sourceInfo, String url) async {
|
||||
final statusList = [
|
||||
{"Ongoing": 0, "Completed": 1, "Cancelled": 3, "Hiatus": 2}
|
||||
];
|
||||
|
||||
final data = {"url": "${sourceInfo.baseUrl}$url"};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
MManga manga = MManga();
|
||||
final workStatus = MBridge.xpath(res,
|
||||
'//*[@class="attr-item"]/b[contains(text(),"Original work")]/following-sibling::span[1]/text()')
|
||||
.first;
|
||||
manga.status = MBridge.parseStatus(workStatus, statusList);
|
||||
|
||||
manga.author = MBridge.xpath(res,
|
||||
'//*[@class="attr-item"]/b[contains(text(),"Authors")]/following-sibling::span[1]/text()')
|
||||
.first;
|
||||
manga.genre = MBridge.xpath(res,
|
||||
'//*[@class="attr-item"]/b[contains(text(),"Genres")]/following-sibling::span[1]/text()')
|
||||
.first
|
||||
.split(",");
|
||||
manga.description =
|
||||
MBridge.xpath(res, '//*[@class="limit-html"]/text()').first;
|
||||
|
||||
List<String> chapsElement = MBridge.querySelectorAll(res,
|
||||
selector: "div.main div.p-2",
|
||||
typeElement: 2,
|
||||
attributes: "",
|
||||
typeRegExp: 0);
|
||||
List<String> times = [];
|
||||
List<String> chapsUrls = [];
|
||||
List<String> chapsNames = [];
|
||||
List<String> scanlators = [];
|
||||
for (var element in chapsElement) {
|
||||
final urlElement = MBridge.querySelectorAll(element,
|
||||
selector: "a.chapt",
|
||||
typeElement: 2,
|
||||
attributes: "",
|
||||
typeRegExp: 0)
|
||||
.first;
|
||||
final group =
|
||||
MBridge.xpath(element, '//*[@class="extra"]/a/text()').first;
|
||||
final name = MBridge.xpath(urlElement, '//a/text()').first;
|
||||
final url = MBridge.xpath(urlElement, '//a/@href').first;
|
||||
final time =
|
||||
MBridge.xpath(element, '//*[@class="extra"]/i[@class="ps-3"]/text()')
|
||||
.first;
|
||||
times.add(time);
|
||||
chapsUrls.add(url);
|
||||
scanlators.add(group);
|
||||
chapsNames.add(name.replaceAll("\n ", "").replaceAll(" ", ""));
|
||||
}
|
||||
var dateUploads = MBridge.parseDates(
|
||||
times, sourceInfo.dateFormat, sourceInfo.dateFormatLocale);
|
||||
List<MChapter>? chaptersList = [];
|
||||
for (var i = 0; i < chapsNames.length; i++) {
|
||||
MChapter chapter = MChapter();
|
||||
chapter.name = chapsNames[i];
|
||||
chapter.url = chapsUrls[i];
|
||||
chapter.scanlator = scanlators[i];
|
||||
chapter.dateUpload = dateUploads[i];
|
||||
chaptersList.add(chapter);
|
||||
}
|
||||
manga.chapters = chaptersList;
|
||||
return manga;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<String>> getPageList(MSource sourceInfo, String url) async {
|
||||
final datas = {"url": "${sourceInfo.baseUrl}$url"};
|
||||
final res = await MBridge.http('GET', json.encode(datas));
|
||||
|
||||
final script = MBridge.xpath(res,
|
||||
'//script[contains(text(), "imgHttpLis") and contains(text(), "batoWord") and contains(text(), "batoPass")]/text()')
|
||||
.first;
|
||||
final imgHttpLisString = Substring(script)
|
||||
.substringAfterLast('const imgHttpLis =')
|
||||
.substringBefore(';')
|
||||
.text;
|
||||
var imgHttpLis = json.decode(imgHttpLisString);
|
||||
final batoWord = Substring(script)
|
||||
.substringAfterLast('const batoWord =')
|
||||
.substringBefore(';')
|
||||
.text;
|
||||
final batoPass = Substring(script)
|
||||
.substringAfterLast('const batoPass =')
|
||||
.substringBefore(';')
|
||||
.text;
|
||||
final evaluatedPass = MBridge.deobfuscateJsPassword(batoPass);
|
||||
final imgAccListString =
|
||||
MBridge.decryptAESCryptoJS(batoWord.replaceAll('"', ""), evaluatedPass);
|
||||
var imgAccList = json.decode(imgAccListString);
|
||||
List<String> pagesUrl = [];
|
||||
for (int i = 0; i < imgHttpLis.length; i++) {
|
||||
String imgUrl = imgHttpLis[i];
|
||||
String imgAcc = imgAccList[i];
|
||||
pagesUrl.add("$imgUrl?$imgAcc");
|
||||
}
|
||||
|
||||
return pagesUrl;
|
||||
}
|
||||
|
||||
MPages mangaElementM(String res, MSource sourceInfo) async {
|
||||
final lang = sourceInfo.lang.replaceAll("-", "_");
|
||||
|
||||
var resB = MBridge.querySelectorAll(res,
|
||||
selector: "div#series-list div.col",
|
||||
typeElement: 2,
|
||||
attributes: "",
|
||||
typeRegExp: 0);
|
||||
|
||||
List<String> images = [];
|
||||
List<String> urls = [];
|
||||
List<String> names = [];
|
||||
|
||||
for (var element in resB) {
|
||||
if (sourceInfo.lang == "all" ||
|
||||
sourceInfo.lang == "en" && element.contains('no-flag') ||
|
||||
element.contains('data-lang="$lang"')) {
|
||||
final item = MBridge.querySelectorAll(element,
|
||||
selector: "a.item-cover",
|
||||
typeElement: 2,
|
||||
attributes: "",
|
||||
typeRegExp: 0)
|
||||
.first;
|
||||
final img = MBridge.querySelectorAll(item,
|
||||
selector: "img",
|
||||
typeElement: 3,
|
||||
attributes: "src",
|
||||
typeRegExp: 0)
|
||||
.first;
|
||||
final url = MBridge.querySelectorAll(item,
|
||||
selector: "a",
|
||||
typeElement: 3,
|
||||
attributes: "href",
|
||||
typeRegExp: 0)
|
||||
.first;
|
||||
images.add(img);
|
||||
urls.add(url);
|
||||
final title = MBridge.querySelectorAll(element,
|
||||
selector: "a.item-title",
|
||||
typeElement: 0,
|
||||
attributes: "",
|
||||
typeRegExp: 0)
|
||||
.first;
|
||||
names.add(title);
|
||||
}
|
||||
}
|
||||
List<MManga> mangaList = [];
|
||||
|
||||
for (var i = 0; i < urls.length; i++) {
|
||||
MManga manga = MManga();
|
||||
manga.name = names[i];
|
||||
manga.imageUrl = images[i];
|
||||
manga.link = urls[i];
|
||||
mangaList.add(manga);
|
||||
}
|
||||
|
||||
return MPages(mangaList, true);
|
||||
}
|
||||
|
||||
String lang(String lang) {
|
||||
lang = lang.replaceAll("-", "_");
|
||||
if (lang == "all") {
|
||||
return "";
|
||||
}
|
||||
return "langs=$lang";
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<MVideo>> getVideoList(MSource sourceInfo, String url) async {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, String> getMirrorPref() {
|
||||
return {
|
||||
"bato.to": "https://bato.to",
|
||||
"batocomic.com": "https://batocomic.com",
|
||||
"batocomic.net": "https://batocomic.net",
|
||||
"batocomic.org": "https://batocomic.org",
|
||||
"batotoo.com": "https://batotoo.com",
|
||||
"batotwo.com": "https://batotwo.com",
|
||||
"battwo.com": "https://battwo.com",
|
||||
"comiko.net": "https://comiko.net",
|
||||
"comiko.org": "https://comiko.org",
|
||||
"mangatoto.com": "https://mangatoto.com",
|
||||
"mangatoto.net": "https://mangatoto.net",
|
||||
"mangatoto.org": "https://mangatoto.org",
|
||||
"readtoto.com": "https://readtoto.com",
|
||||
"readtoto.net": "https://readtoto.net",
|
||||
"readtoto.org": "https://readtoto.org",
|
||||
"dto.to": "https://dto.to",
|
||||
"hto.to": "https://hto.to",
|
||||
"mto.to": "https://mto.to",
|
||||
"wto.to": "https://wto.to",
|
||||
"xbato.com": "https://xbato.com",
|
||||
"xbato.net": "https://xbato.net",
|
||||
"xbato.org": "https://xbato.org",
|
||||
"zbato.com": "https://zbato.com",
|
||||
"zbato.net": "https://zbato.net",
|
||||
"zbato.org": "https://zbato.org",
|
||||
};
|
||||
}
|
||||
|
||||
Batoto main() {
|
||||
return Batoto();
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import '../../../../model/source.dart';
|
||||
import '../../../../utils/utils.dart';
|
||||
|
||||
const batotoVersion = "0.0.3";
|
||||
const batotoVersion = "0.0.35";
|
||||
const batotoSourceCodeUrl =
|
||||
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/main/manga/src/all/batoto/batoto-v$batotoVersion.dart";
|
||||
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
import 'package:bridge_lib/bridge_lib.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
getLatestUpdatesManga(MManga manga) async {
|
||||
final url =
|
||||
"${manga.apiUrl}/v1.0/search?sort=uploaded&page=${manga.page}&tachiyomi=true";
|
||||
final data = {"url": url, "headers": getHeader(manga.baseUrl)};
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
manga.names = MBridge.jsonPathToList(res, r'$.title', 0);
|
||||
List<String> ids = MBridge.jsonPathToList(res, r'$.hid', 0);
|
||||
List<String> mangaUrls = [];
|
||||
for (var id in ids) {
|
||||
mangaUrls.add("/comic/$id/#");
|
||||
}
|
||||
manga.urls = mangaUrls;
|
||||
manga.images = MBridge.jsonPathToList(res, r'$.cover_url', 0);
|
||||
return manga;
|
||||
}
|
||||
|
||||
getMangaDetail(MManga manga) async {
|
||||
final statusList = [
|
||||
{
|
||||
"1": 0,
|
||||
"2": 1,
|
||||
"3": 3,
|
||||
"4": 2,
|
||||
}
|
||||
];
|
||||
|
||||
final headers = getHeader(manga.baseUrl);
|
||||
|
||||
final urll =
|
||||
"${manga.apiUrl}${manga.link.replaceAll("#", '')}?tachiyomi=true";
|
||||
final data = {"url": urll, "headers": headers};
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
manga.author = MBridge.jsonPathToString(res, r'$.authors[*].name', '');
|
||||
manga.genre =
|
||||
MBridge.jsonPathToString(res, r'$.genres[*].name', "_.").split("_.");
|
||||
manga.description = MBridge.jsonPathToString(res, r'$..desc', '');
|
||||
manga.status = MBridge.parseStatus(
|
||||
MBridge.jsonPathToString(res, r'$..comic.status', ''), statusList);
|
||||
final chapUrlReq =
|
||||
"${manga.apiUrl}${manga.link.replaceAll("#", '')}chapters?lang=${manga.lang}&tachiyomi=true&page=1";
|
||||
final dataReq = {"url": chapUrlReq, "headers": headers};
|
||||
final request = await MBridge.http('GET', json.encode(dataReq));
|
||||
if (request.hasError) {
|
||||
return response;
|
||||
}
|
||||
var total = MBridge.jsonPathToString(request.body, r'$.total', '');
|
||||
final chapterLimit = MBridge.intParse("$total");
|
||||
final newChapUrlReq =
|
||||
"${manga.apiUrl}${manga.link.replaceAll("#", '')}chapters?limit=$chapterLimit&lang=${manga.lang}&tachiyomi=true&page=1";
|
||||
|
||||
final newDataReq = {"url": newChapUrlReq, "headers": headers};
|
||||
final newRequest = await MBridge.http('GET', json.encode(newDataReq));
|
||||
if (newRequest.hasError) {
|
||||
return response;
|
||||
}
|
||||
manga.urls =
|
||||
MBridge.jsonPathToString(newRequest.body, r'$.chapters[*].hid', "_.")
|
||||
.split("_.");
|
||||
final chapDate = MBridge.jsonPathToString(
|
||||
newRequest.body, r'$.chapters[*].created_at', "_.")
|
||||
.split("_.");
|
||||
manga.chaptersDateUploads =
|
||||
MBridge.listParseDateTime(chapDate, "yyyy-MM-dd'T'HH:mm:ss'Z'", "en");
|
||||
manga.chaptersVolumes =
|
||||
MBridge.jsonPathToString(newRequest.body, r'$.chapters[*].vol', "_.")
|
||||
.split("_.");
|
||||
manga.chaptersScanlators = MBridge.jsonPathToString(
|
||||
newRequest.body, r'$.chapters[*].group_name', "_.")
|
||||
.split("_.");
|
||||
manga.names =
|
||||
MBridge.jsonPathToString(newRequest.body, r'$.chapters[*].title', "_.")
|
||||
.split("_.");
|
||||
manga.chaptersChaps =
|
||||
MBridge.jsonPathToString(newRequest.body, r'$.chapters[*].chap', "_.")
|
||||
.split("_.");
|
||||
|
||||
return manga;
|
||||
}
|
||||
|
||||
getPopularManga(MManga manga) async {
|
||||
final urll =
|
||||
"${manga.apiUrl}/v1.0/search?sort=follow&page=${manga.page}&tachiyomi=true";
|
||||
final data = {"url": urll, "headers": getHeader(manga.baseUrl)};
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
manga.names = MBridge.jsonPathToList(res, r'$.title', 0);
|
||||
List<String> ids = MBridge.jsonPathToList(res, r'$.hid', 0);
|
||||
List<String> mangaUrls = [];
|
||||
for (var id in ids) {
|
||||
mangaUrls.add("/comic/$id/#");
|
||||
}
|
||||
manga.urls = mangaUrls;
|
||||
manga.images = MBridge.jsonPathToList(res, r'$.cover_url', 0);
|
||||
return manga;
|
||||
}
|
||||
|
||||
searchManga(MManga manga) async {
|
||||
final urll = "${manga.apiUrl}/v1.0/search?q=${manga.query}&tachiyomi=true";
|
||||
final data = {"url": urll, "headers": getHeader(manga.baseUrl)};
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
manga.names = MBridge.jsonPathToList(res, r'$.title', 0);
|
||||
List<String> ids = MBridge.jsonPathToList(res, r'$.hid', 0);
|
||||
List<String> mangaUrls = [];
|
||||
for (var id in ids) {
|
||||
mangaUrls.add("/comic/$id/#");
|
||||
}
|
||||
manga.urls = mangaUrls;
|
||||
manga.images = MBridge.jsonPathToList(res, r'$.cover_url', 0);
|
||||
return manga;
|
||||
}
|
||||
|
||||
getChapterPages(MManga manga) async {
|
||||
final url = "${manga.apiUrl}/chapter/${manga.link}?tachiyomi=true";
|
||||
final data = {"url": url, "headers": getHeader(url)};
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
return MBridge.jsonPathToString(res, r'$.chapter.images[*].url', '_.')
|
||||
.split('_.');
|
||||
}
|
||||
|
||||
Map<String, String> getHeader(String url) {
|
||||
final headers = {
|
||||
"Referer": "$url/",
|
||||
'User-Agent':
|
||||
"Tachiyomi Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:110.0) Gecko/20100101 Firefox/110.0"
|
||||
};
|
||||
return headers;
|
||||
}
|
||||
194
manga/src/all/comick/comick-v0.0.35.dart
Normal file
194
manga/src/all/comick/comick-v0.0.35.dart
Normal file
@@ -0,0 +1,194 @@
|
||||
import 'package:mangayomi/bridge_lib.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
class ComickFun extends MSourceProvider {
|
||||
ComickFun();
|
||||
|
||||
@override
|
||||
Future<MPages> getPopular(MSource sourceInfo, int page) async {
|
||||
final url =
|
||||
"${sourceInfo.apiUrl}/v1.0/search?sort=follow&page=$page&tachiyomi=true";
|
||||
final data = {"url": url, "headers": getHeader(sourceInfo.baseUrl)};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
return mangaRes(res);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MPages> getLatestUpdates(MSource sourceInfo, int page) async {
|
||||
final url =
|
||||
"${sourceInfo.apiUrl}/v1.0/search?sort=uploaded&page=$page&tachiyomi=true";
|
||||
final data = {"url": url, "headers": getHeader(sourceInfo.baseUrl)};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
return mangaRes(res);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MPages> search(MSource sourceInfo, String query, int page) async {
|
||||
final url = "${sourceInfo.apiUrl}/v1.0/search?q=$query&tachiyomi=true";
|
||||
final data = {"url": url, "headers": getHeader(sourceInfo.baseUrl)};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
return mangaRes(res);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MManga> getDetail(MSource sourceInfo, String url) async {
|
||||
final statusList = [
|
||||
{"1": 0, "2": 1, "3": 3, "4": 2}
|
||||
];
|
||||
|
||||
final headers = getHeader(sourceInfo.baseUrl);
|
||||
|
||||
final urll =
|
||||
"${sourceInfo.apiUrl}${url.replaceAll("#", '')}?tachiyomi=true";
|
||||
final data = {"url": urll, "headers": headers};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
MManga manga = MManga();
|
||||
manga.author = MBridge.jsonPathToString(res, r'$.authors[*].name', '');
|
||||
manga.genre =
|
||||
MBridge.jsonPathToString(res, r'$.genres[*].name', "_.").split("_.");
|
||||
manga.description = MBridge.jsonPathToString(res, r'$..desc', '');
|
||||
manga.status = MBridge.parseStatus(
|
||||
MBridge.jsonPathToString(res, r'$..comic.status', ''), statusList);
|
||||
final chapUrlReq =
|
||||
"${sourceInfo.apiUrl}${url.replaceAll("#", '')}chapters?lang=${sourceInfo.lang}&tachiyomi=true&page=1";
|
||||
final dataReq = {"url": chapUrlReq, "headers": headers};
|
||||
final request = await MBridge.http('GET', json.encode(dataReq));
|
||||
var total = MBridge.jsonPathToString(request, r'$.total', '');
|
||||
final chapterLimit = int.parse(total);
|
||||
final newChapUrlReq =
|
||||
"${sourceInfo.apiUrl}${url.replaceAll("#", '')}chapters?limit=$chapterLimit&lang=${sourceInfo.lang}&tachiyomi=true&page=1";
|
||||
|
||||
final newDataReq = {"url": newChapUrlReq, "headers": headers};
|
||||
final newRequest = await MBridge.http('GET', json.encode(newDataReq));
|
||||
|
||||
final chapsUrls =
|
||||
MBridge.jsonPathToString(newRequest, r'$.chapters[*].hid', "_.")
|
||||
.split("_.");
|
||||
final chapDate =
|
||||
MBridge.jsonPathToString(newRequest, r'$.chapters[*].created_at', "_.")
|
||||
.split("_.");
|
||||
final chaptersVolumes =
|
||||
MBridge.jsonPathToString(newRequest, r'$.chapters[*].vol', "_.")
|
||||
.split("_.");
|
||||
final chaptersScanlators =
|
||||
MBridge.jsonPathToString(newRequest, r'$.chapters[*].group_name', "_.")
|
||||
.split("_.");
|
||||
final chapsNames =
|
||||
MBridge.jsonPathToString(newRequest, r'$.chapters[*].title', "_.")
|
||||
.split("_.");
|
||||
final chaptersChaps =
|
||||
MBridge.jsonPathToString(newRequest, r'$.chapters[*].chap', "_.")
|
||||
.split("_.");
|
||||
|
||||
var dateUploads = MBridge.parseDates(
|
||||
chapDate, sourceInfo.dateFormat, sourceInfo.dateFormatLocale);
|
||||
List<MChapter>? chaptersList = [];
|
||||
for (var i = 0; i < chapsNames.length; i++) {
|
||||
String title = "";
|
||||
String scanlator = "";
|
||||
if (chaptersChaps.isNotEmpty && chaptersVolumes.isNotEmpty) {
|
||||
title = beautifyChapterName(chaptersVolumes[i], chaptersChaps[i],
|
||||
chapsNames[i], sourceInfo.lang);
|
||||
} else {
|
||||
title = chapsNames[i];
|
||||
}
|
||||
if (chaptersScanlators.isNotEmpty) {
|
||||
scanlator = chaptersScanlators[i]
|
||||
.toString()
|
||||
.replaceAll(']', "")
|
||||
.replaceAll("[", "");
|
||||
}
|
||||
MChapter chapter = MChapter();
|
||||
chapter.name = title;
|
||||
chapter.url = chapsUrls[i];
|
||||
chapter.scanlator = scanlator == "null" ? "" : scanlator;
|
||||
chapter.dateUpload = dateUploads[i];
|
||||
chaptersList.add(chapter);
|
||||
}
|
||||
manga.chapters = chaptersList;
|
||||
return manga;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<String>> getPageList(MSource sourceInfo, String url) async {
|
||||
final urll = "${sourceInfo.apiUrl}/chapter/$url?tachiyomi=true";
|
||||
final data = {"url": urll, "headers": getHeader(url)};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
return MBridge.jsonPathToString(res, r'$.chapter.images[*].url', '_.')
|
||||
.split('_.');
|
||||
}
|
||||
|
||||
MPages mangaRes(String res) async {
|
||||
final names = MBridge.jsonPathToList(res, r'$.title', 0);
|
||||
List<String> ids = MBridge.jsonPathToList(res, r'$.hid', 0);
|
||||
List<String> mangaUrls = [];
|
||||
for (var id in ids) {
|
||||
mangaUrls.add("/comic/$id/#");
|
||||
}
|
||||
final urls = mangaUrls;
|
||||
final images = MBridge.jsonPathToList(res, r'$.cover_url', 0);
|
||||
List<MManga> mangaList = [];
|
||||
for (var i = 0; i < urls.length; i++) {
|
||||
MManga manga = MManga();
|
||||
manga.name = names[i];
|
||||
manga.imageUrl = images[i];
|
||||
manga.link = urls[i];
|
||||
mangaList.add(manga);
|
||||
}
|
||||
|
||||
return MPages(mangaList, true);
|
||||
}
|
||||
|
||||
Map<String, String> getHeader(String url) {
|
||||
final headers = {
|
||||
"Referer": "$url/",
|
||||
'User-Agent':
|
||||
"Tachiyomi Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:110.0) Gecko/20100101 Firefox/110.0"
|
||||
};
|
||||
return headers;
|
||||
}
|
||||
|
||||
String beautifyChapterName(
|
||||
String vol, String chap, String title, String lang) {
|
||||
String result = "";
|
||||
|
||||
if (vol != "null" && vol.isNotEmpty) {
|
||||
if (chap != "null" && chap.isEmpty) {
|
||||
result += "Volume $vol ";
|
||||
} else {
|
||||
result += "Vol. $vol ";
|
||||
}
|
||||
}
|
||||
|
||||
if (chap != "null" && chap.isNotEmpty) {
|
||||
if (vol != "null" && vol.isEmpty) {
|
||||
if (lang != "null" && lang == "fr") {
|
||||
result += "Chapitre $chap";
|
||||
} else {
|
||||
result += "Chapter $chap";
|
||||
}
|
||||
} else {
|
||||
result += "Ch. $chap ";
|
||||
}
|
||||
}
|
||||
|
||||
if (title != "null" && title.isNotEmpty) {
|
||||
if (chap != "null" && chap.isEmpty) {
|
||||
result += title;
|
||||
} else {
|
||||
result += " : $title";
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<MVideo>> getVideoList(MSource sourceInfo, String url) async {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
ComickFun main() {
|
||||
return ComickFun();
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import '../../../../model/source.dart';
|
||||
import '../../../../utils/utils.dart';
|
||||
|
||||
const comickVersion = "0.0.3";
|
||||
const comickVersion = "0.0.35";
|
||||
const comickSourceCodeUrl =
|
||||
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/main/manga/src/all/comick/comick-v$comickVersion.dart";
|
||||
|
||||
|
||||
@@ -1,333 +0,0 @@
|
||||
import 'package:bridge_lib/bridge_lib.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
getPopularManga(MManga manga) async {
|
||||
int page = (20 * (manga.page - 1));
|
||||
final url =
|
||||
"https://api.mangadex.org/manga?limit=20&offset=$page&availableTranslatedLanguage[]=en&includes[]=cover_art${getMDXContentRating()}&order[followedCount]=desc";
|
||||
final datas = {"url": url};
|
||||
final response = await MBridge.http('GET', json.encode(datas));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
return parseManga(response.body, manga);
|
||||
}
|
||||
|
||||
getLatestUpdatesManga(MManga manga) async {
|
||||
int page = (20 * (manga.page - 1));
|
||||
final urll =
|
||||
"https://api.mangadex.org/chapter?limit=20&offset=$page&translatedLanguage[]=${manga.lang}&includeFutureUpdates=0&order[publishAt]=desc&includeFuturePublishAt=0&includeEmptyPages=0";
|
||||
final datas = {"url": urll};
|
||||
final response = await MBridge.http('GET', json.encode(datas));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String ress = response.body;
|
||||
|
||||
final mangaIds = MBridge.listParse(
|
||||
MBridge.jsonPathToString(ress, r'$.data[*].relationships[*].id', '.--')
|
||||
.split('.--'),
|
||||
3);
|
||||
String mangaa = "".toString();
|
||||
for (var id in mangaIds) {
|
||||
mangaa += "&ids[]=$id";
|
||||
}
|
||||
final newUrl =
|
||||
"https://api.mangadex.org/manga?includes[]=cover_art&limit=${mangaIds.length}${getMDXContentRating()}$mangaa";
|
||||
final datass = {"url": newUrl};
|
||||
final res = await MBridge.http('GET', json.encode(datass));
|
||||
if (res.hasError) {
|
||||
return res;
|
||||
}
|
||||
return parseManga(res.body, manga);
|
||||
}
|
||||
|
||||
searchManga(MManga manga) async {
|
||||
final url =
|
||||
"https://api.mangadex.org/manga?includes[]=cover_art&offset=0&limit=20&title=${manga.query}${getMDXContentRating()}&order[followedCount]=desc&availableTranslatedLanguage[]=${manga.lang}";
|
||||
final datas = {"url": url};
|
||||
final res = await MBridge.http('GET', json.encode(datas));
|
||||
if (res.hasError) {
|
||||
return res;
|
||||
}
|
||||
return parseManga(res.body, manga);
|
||||
}
|
||||
|
||||
getMangaDetail(MManga manga) async {
|
||||
final statusList = [
|
||||
{
|
||||
"ongoing": 0,
|
||||
"completed": 1,
|
||||
"hiatus": 2,
|
||||
"cancelled": 3,
|
||||
}
|
||||
];
|
||||
final url =
|
||||
"https://api.mangadex.org${manga.link}?includes[]=cover_art&includes[]=author&includes[]=artist";
|
||||
final datas = {"url": url};
|
||||
final response = await MBridge.http('GET', json.encode(datas));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
String res = response.body;
|
||||
manga.author = MBridge.jsonPathToString(
|
||||
res, r'$..data.relationships[*].attributes.name', ', ');
|
||||
|
||||
String expressionDescriptionA = r'$..data.attributes.description.en';
|
||||
String expressionDescription = MBridge.regExp(
|
||||
r'$..data.attributes.description[a]', r'\[a\]', ".${manga.lang}", 0, 1);
|
||||
|
||||
String description = MBridge.jsonPathToString(res, expressionDescription, '');
|
||||
if (description.isEmpty) {
|
||||
description = MBridge.jsonPathToString(res, expressionDescriptionA, '');
|
||||
}
|
||||
manga.description = description;
|
||||
List<String> genres = [];
|
||||
|
||||
final genre = MBridge.listParse(
|
||||
MBridge.jsonPathToString(
|
||||
res, r'$..data.attributes.tags[*].attributes.name.en', '.-')
|
||||
.split('.-'),
|
||||
0);
|
||||
genres = genre;
|
||||
String contentRating =
|
||||
MBridge.jsonPathToString(res, r'$..data.attributes.contentRating', '');
|
||||
if (contentRating == "safe") {
|
||||
} else {
|
||||
genres.add(contentRating);
|
||||
}
|
||||
String publicationDemographic = MBridge.jsonPathToString(
|
||||
res, r'$..data.attributes.publicationDemographic', '');
|
||||
if (publicationDemographic == "null") {
|
||||
} else {
|
||||
genres.add(publicationDemographic);
|
||||
}
|
||||
manga.genre = genres;
|
||||
String statusRes =
|
||||
MBridge.jsonPathToString(res, r'$..data.attributes.status', '');
|
||||
manga.status = MBridge.parseStatus(statusRes, statusList);
|
||||
final mangaId = MBridge.listParse(manga.link.split('/'), 2)[0];
|
||||
final paginatedChapterList =
|
||||
await paginatedChapterListRequest(mangaId, 0, manga.lang);
|
||||
final chapterList =
|
||||
MBridge.jsonPathToString(paginatedChapterList, r'$.data[*]', '_.')
|
||||
.split('_.');
|
||||
int limit = MBridge.intParse(
|
||||
MBridge.jsonPathToString(paginatedChapterList, r'$.limit', ''));
|
||||
int offset = MBridge.intParse(
|
||||
MBridge.jsonPathToString(paginatedChapterList, r'$.offset', ''));
|
||||
int total = MBridge.intParse(
|
||||
MBridge.jsonPathToString(paginatedChapterList, r'$.total', ''));
|
||||
List<MManga> chapterListA = [];
|
||||
List<String> chapNames = [];
|
||||
List<String> scanlators = [];
|
||||
List<String> chapterUrl = [];
|
||||
List<String> chapterDate = [];
|
||||
|
||||
final list = getChapters(
|
||||
manga, MBridge.intParse("${chapterList.length}"), paginatedChapterList);
|
||||
|
||||
chapterListA.add(list);
|
||||
var hasMoreResults = (limit + offset) < total;
|
||||
while (hasMoreResults) {
|
||||
offset += limit;
|
||||
var newRequest =
|
||||
await paginatedChapterListRequest(mangaId, offset, manga.lang);
|
||||
int total =
|
||||
MBridge.intParse(MBridge.jsonPathToString(newRequest, r'$.total', ''));
|
||||
final chapterList =
|
||||
MBridge.jsonPathToString(paginatedChapterList, r'$.data[*]', '_.')
|
||||
.split('_.');
|
||||
final list = getChapters(
|
||||
manga, MBridge.intParse("${chapterList.length}"), newRequest);
|
||||
chapterListA.add(list);
|
||||
hasMoreResults = (limit + offset) < total;
|
||||
}
|
||||
for (var element in chapterListA) {
|
||||
for (var name in element.names) {
|
||||
if (name.isNotEmpty) {
|
||||
chapNames.add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var element in chapterListA) {
|
||||
for (var url in element.urls) {
|
||||
if (url.isNotEmpty) {
|
||||
chapterUrl.add(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var element in chapterListA) {
|
||||
for (var chapDate in element.chaptersDateUploads) {
|
||||
if (chapDate.isNotEmpty) {
|
||||
chapterDate.add(chapDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var element in chapterListA) {
|
||||
for (var scanlator in element.chaptersScanlators) {
|
||||
if (scanlator.isNotEmpty) {
|
||||
scanlators.add(scanlator);
|
||||
}
|
||||
}
|
||||
}
|
||||
manga.urls = chapterUrl;
|
||||
manga.chaptersDateUploads = chapterDate;
|
||||
manga.chaptersScanlators = scanlators;
|
||||
manga.names = chapNames;
|
||||
return manga;
|
||||
}
|
||||
|
||||
getChapterPages(MManga manga) async {
|
||||
final url = "https://api.mangadex.org/at-home/server/${manga.link}";
|
||||
final data = {"url": url};
|
||||
final response = await MBridge.http('GET', json.encode(data));
|
||||
if (response.hasError) {
|
||||
return response;
|
||||
}
|
||||
final dataRes = json.decode(response.body);
|
||||
final host = dataRes["baseUrl"];
|
||||
final hash = dataRes["chapter"]["hash"];
|
||||
final chapterDatas = dataRes["chapter"]["data"] as List;
|
||||
return chapterDatas.map((e) => "$host/data/$hash/$e").toList();
|
||||
}
|
||||
|
||||
String getMDXContentRating() {
|
||||
String ctnRating =
|
||||
"&contentRating[]=suggestive&contentRating[]=safe&contentRating[]=erotica&contentRating[]=pornographic";
|
||||
return ctnRating;
|
||||
}
|
||||
|
||||
MManga getChapters(MManga manga, int length, String paginatedChapterListA) {
|
||||
String scanlators = "".toString();
|
||||
String chapNames = "".toString();
|
||||
String chapDate = "".toString();
|
||||
String chapterUrl = "".toString();
|
||||
String paginatedChapterList = paginatedChapterListA.toString();
|
||||
final dataList =
|
||||
MBridge.jsonPathToList(paginatedChapterList, r'$.data[*]', 0);
|
||||
for (var res in dataList) {
|
||||
String scan = "".toString();
|
||||
final groups = MBridge.jsonPathToList(res,
|
||||
r'$.relationships[?@.id!="00e03853-1b96-4f41-9542-c71b8692033b"]', 0);
|
||||
String chapName = "".toString();
|
||||
for (var element in groups) {
|
||||
final data = MBridge.getMapValue(element, "attributes", encode: true);
|
||||
if (data.isEmpty) {
|
||||
} else {
|
||||
final name = MBridge.getMapValue(data, "name");
|
||||
scan += "$name".toString();
|
||||
final username = MBridge.getMapValue(data, "username");
|
||||
if (username.isEmpty) {
|
||||
} else {
|
||||
if (scan.isEmpty) {
|
||||
scan += "Uploaded by $username".toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (scan.isEmpty) {
|
||||
scan = "No Group".toString();
|
||||
}
|
||||
final dataRes = MBridge.getMapValue(res, "attributes", encode: true);
|
||||
if (dataRes.isEmpty) {
|
||||
} else {
|
||||
final data = MBridge.getMapValue(res, "attributes", encode: true);
|
||||
final volume = MBridge.getMapValue(data, "volume");
|
||||
if (volume.isEmpty) {
|
||||
} else {
|
||||
if (volume == "null") {
|
||||
} else {
|
||||
chapName = "Vol.$volume ".toString();
|
||||
}
|
||||
}
|
||||
final chapter = MBridge.getMapValue(data, "chapter");
|
||||
if (chapter.isEmpty) {
|
||||
} else {
|
||||
if (chapter == "null") {
|
||||
} else {
|
||||
chapName += "Ch.$chapter ".toString();
|
||||
}
|
||||
}
|
||||
final title = MBridge.getMapValue(data, "title");
|
||||
if (title.isEmpty) {
|
||||
} else {
|
||||
if (title == "null") {
|
||||
} else {
|
||||
if (chapName.isEmpty) {
|
||||
} else {
|
||||
chapName += "- ".toString();
|
||||
}
|
||||
chapName += "$title".toString();
|
||||
}
|
||||
}
|
||||
if (chapName.isEmpty) {
|
||||
chapName += "Oneshot".toString();
|
||||
}
|
||||
final date = MBridge.getMapValue(data, "publishAt");
|
||||
final id = MBridge.getMapValue(res, "id");
|
||||
chapterUrl += "._$id";
|
||||
chapDate += "._._$date";
|
||||
scanlators += "._$scan";
|
||||
chapNames += "._$chapName";
|
||||
}
|
||||
}
|
||||
manga.chaptersDateUploads = MBridge.listParseDateTime(
|
||||
chapDate.split("._._"), "yyyy-MM-dd'T'HH:mm:ss+SSS", "en_US");
|
||||
|
||||
manga.urls = chapterUrl.split("._");
|
||||
manga.chaptersScanlators = scanlators.split("._");
|
||||
manga.names = chapNames.split("._");
|
||||
return manga;
|
||||
}
|
||||
|
||||
Future<String> paginatedChapterListRequest(
|
||||
String mangaId, int offset, String lang) async {
|
||||
final url =
|
||||
'https://api.mangadex.org/manga/$mangaId/feed?limit=500&offset=$offset&includes[]=user&includes[]=scanlation_group&order[volume]=desc&order[chapter]=desc&translatedLanguage[]=$lang&includeFuturePublishAt=0&includeEmptyPages=0${getMDXContentRating()}';
|
||||
final datas = {"url": url};
|
||||
final response = await MBridge.http('GET', json.encode(datas));
|
||||
return response.body;
|
||||
}
|
||||
|
||||
String findTitle(Map<String, dynamic> dataRes, String lang) {
|
||||
final altTitlesJ = dataRes["attributes"]["altTitles"];
|
||||
final titleJ = dataRes["attributes"]["title"];
|
||||
final title = MBridge.getMapValue(json.encode(titleJ), "en");
|
||||
if (title.isEmpty) {
|
||||
for (var r in altTitlesJ) {
|
||||
final altTitle = MBridge.getMapValue(json.encode(r), "en");
|
||||
if (altTitle.isNotEmpty) {
|
||||
return altTitle;
|
||||
}
|
||||
}
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
String getCover(Map<String, dynamic> dataRes) {
|
||||
final relationships = dataRes["relationships"];
|
||||
String coverFileName = "".toString();
|
||||
for (var a in relationships) {
|
||||
final relationType = a["type"];
|
||||
if (relationType == "cover_art") {
|
||||
if (coverFileName.isEmpty) {
|
||||
coverFileName =
|
||||
"https://uploads.mangadex.org/covers/${dataRes["id"]}/${a["attributes"]["fileName"]}";
|
||||
}
|
||||
}
|
||||
}
|
||||
return coverFileName;
|
||||
}
|
||||
|
||||
MManga parseManga(String res, MManga manga) {
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
}
|
||||
final datasRes = json.decode(res);
|
||||
final resJson = datasRes["data"] as List;
|
||||
manga.names = resJson.map((e) => findTitle(e, manga.lang)).toList();
|
||||
manga.urls = resJson.map((e) => "/manga/${e["id"]}").toList();
|
||||
manga.images = resJson.map((e) => getCover(e)).toList();
|
||||
return manga;
|
||||
}
|
||||
280
manga/src/all/mangadex/mangadex-v0.0.35.dart
Normal file
280
manga/src/all/mangadex/mangadex-v0.0.35.dart
Normal file
@@ -0,0 +1,280 @@
|
||||
import 'package:mangayomi/bridge_lib.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
class MangaDex extends MSourceProvider {
|
||||
MangaDex();
|
||||
|
||||
@override
|
||||
Future<MPages> getPopular(MSource sourceInfo, int page) async {
|
||||
page = (20 * (page - 1));
|
||||
final url =
|
||||
"https://api.mangadex.org/manga?limit=20&offset=$page&availableTranslatedLanguage[]=en&includes[]=cover_art${getMDXContentRating()}&order[followedCount]=desc";
|
||||
final datas = {"url": url};
|
||||
final res = await MBridge.http('GET', json.encode(datas));
|
||||
return mangaRes(res, sourceInfo);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MPages> getLatestUpdates(MSource sourceInfo, int page) async {
|
||||
page = (20 * (page - 1));
|
||||
final urll =
|
||||
"https://api.mangadex.org/chapter?limit=20&offset=$page&translatedLanguage[]=${sourceInfo.lang}&includeFutureUpdates=0&order[publishAt]=desc&includeFuturePublishAt=0&includeEmptyPages=0";
|
||||
final datas = {"url": urll};
|
||||
final ress = await MBridge.http('GET', json.encode(datas));
|
||||
final mangaIds =
|
||||
MBridge.jsonPathToString(ress, r'$.data[*].relationships[*].id', '.--')
|
||||
.split('.--');
|
||||
String mangaIdss = "".toString();
|
||||
for (var id in mangaIds) {
|
||||
mangaIdss += "&ids[]=$id";
|
||||
}
|
||||
final newUrl =
|
||||
"https://api.mangadex.org/manga?includes[]=cover_art&limit=${mangaIds.length}${getMDXContentRating()}$mangaIdss";
|
||||
final res = await MBridge.http('GET', json.encode({"url": newUrl}));
|
||||
return mangaRes(res, sourceInfo);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MPages> search(MSource sourceInfo, String query, int page) async {
|
||||
final url =
|
||||
"https://api.mangadex.org/manga?includes[]=cover_art&offset=0&limit=20&title=$query${getMDXContentRating()}&order[followedCount]=desc&availableTranslatedLanguage[]=${sourceInfo.lang}";
|
||||
|
||||
final res = await MBridge.http('GET', json.encode({"url": url}));
|
||||
return mangaRes(res, sourceInfo);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MManga> getDetail(MSource sourceInfo, String url) async {
|
||||
final statusList = [
|
||||
{"ongoing": 0, "completed": 1, "hiatus": 2, "cancelled": 3}
|
||||
];
|
||||
|
||||
final urll =
|
||||
"https://api.mangadex.org$url?includes[]=cover_art&includes[]=author&includes[]=artist";
|
||||
final res = await MBridge.http('GET', json.encode({"url": urll}));
|
||||
MManga manga = MManga();
|
||||
manga.author = MBridge.jsonPathToString(
|
||||
res, r'$..data.relationships[*].attributes.name', ', ');
|
||||
|
||||
String expressionDescriptionA = r'$..data.attributes.description.en';
|
||||
String expressionDescription = MBridge.regExp(
|
||||
r'$..data.attributes.description[a]',
|
||||
r'\[a\]',
|
||||
".${sourceInfo.lang}",
|
||||
0,
|
||||
1);
|
||||
|
||||
String description =
|
||||
MBridge.jsonPathToString(res, expressionDescription, '');
|
||||
if (description.isEmpty) {
|
||||
description = MBridge.jsonPathToString(res, expressionDescriptionA, '');
|
||||
}
|
||||
manga.description = description;
|
||||
List<String> genres = [];
|
||||
|
||||
genres = MBridge.jsonPathToString(
|
||||
res, r'$..data.attributes.tags[*].attributes.name.en', '.-')
|
||||
.split('.-');
|
||||
|
||||
String contentRating =
|
||||
MBridge.jsonPathToString(res, r'$..data.attributes.contentRating', '');
|
||||
if (contentRating != "safe") {
|
||||
genres.add(contentRating);
|
||||
}
|
||||
String publicationDemographic = MBridge.jsonPathToString(
|
||||
res, r'$..data.attributes.publicationDemographic', '');
|
||||
if (publicationDemographic == "null") {
|
||||
} else {
|
||||
genres.add(publicationDemographic);
|
||||
}
|
||||
manga.genre = genres;
|
||||
String statusRes =
|
||||
MBridge.jsonPathToString(res, r'$..data.attributes.status', '');
|
||||
manga.status = MBridge.parseStatus(statusRes, statusList);
|
||||
final mangaId = url.split('/').last;
|
||||
|
||||
final paginatedChapterList =
|
||||
await paginatedChapterListRequest(mangaId, 0, sourceInfo.lang);
|
||||
final chapterList =
|
||||
MBridge.jsonPathToString(paginatedChapterList, r'$.data[*]', '_.')
|
||||
.split('_.');
|
||||
int limit = int.parse(
|
||||
MBridge.jsonPathToString(paginatedChapterList, r'$.limit', ''));
|
||||
int offset = int.parse(
|
||||
MBridge.jsonPathToString(paginatedChapterList, r'$.offset', ''));
|
||||
int total = int.parse(
|
||||
MBridge.jsonPathToString(paginatedChapterList, r'$.total', ''));
|
||||
List<MChapter> chapterListA = [];
|
||||
|
||||
final list =
|
||||
getChapters(int.parse("${chapterList.length}"), paginatedChapterList);
|
||||
|
||||
chapterListA.addAll(list);
|
||||
var hasMoreResults = (limit + offset) < total;
|
||||
while (hasMoreResults) {
|
||||
offset += limit;
|
||||
var newRequest =
|
||||
await paginatedChapterListRequest(mangaId, offset, sourceInfo.lang);
|
||||
int total =
|
||||
int.parse(MBridge.jsonPathToString(newRequest, r'$.total', ''));
|
||||
final chapterList =
|
||||
MBridge.jsonPathToString(paginatedChapterList, r'$.data[*]', '_.')
|
||||
.split('_.');
|
||||
final list = getChapters(int.parse("${chapterList.length}"), newRequest);
|
||||
chapterListA.addAll(list);
|
||||
hasMoreResults = (limit + offset) < total;
|
||||
}
|
||||
|
||||
manga.chapters = chapterListA;
|
||||
return manga;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<String>> getPageList(MSource sourceInfo, String url) async {
|
||||
final urll = "https://api.mangadex.org/at-home/server/$url";
|
||||
|
||||
final res = await MBridge.http('GET', json.encode({"url": urll}));
|
||||
|
||||
final dataRes = json.decode(res);
|
||||
final host = dataRes["baseUrl"];
|
||||
final hash = dataRes["chapter"]["hash"];
|
||||
final chapterDatas = dataRes["chapter"]["data"] as List;
|
||||
return chapterDatas.map((e) => "$host/data/$hash/$e").toList();
|
||||
}
|
||||
|
||||
MPages mangaRes(String res, MSource sourceInfo) {
|
||||
final datasRes = json.decode(res);
|
||||
final resJson = datasRes["data"] as List;
|
||||
List<MManga> mangaList = [];
|
||||
for (var e in resJson) {
|
||||
MManga manga = MManga();
|
||||
manga.name = findTitle(e, sourceInfo.lang);
|
||||
manga.imageUrl = getCover(e);
|
||||
manga.link = "/manga/${e["id"]}";
|
||||
mangaList.add(manga);
|
||||
}
|
||||
return MPages(mangaList, true);
|
||||
}
|
||||
|
||||
List<MChapter> getChapters(int length, String paginatedChapterListA) {
|
||||
List<MChapter> chaptersList = [];
|
||||
String paginatedChapterList = paginatedChapterListA.toString();
|
||||
final dataList =
|
||||
MBridge.jsonPathToList(paginatedChapterList, r'$.data[*]', 0);
|
||||
for (var res in dataList) {
|
||||
String scan = "".toString();
|
||||
final groups = MBridge.jsonPathToList(res,
|
||||
r'$.relationships[?@.id!="00e03853-1b96-4f41-9542-c71b8692033b"]', 0);
|
||||
String chapName = "".toString();
|
||||
for (var element in groups) {
|
||||
final data = MBridge.getMapValue(element, "attributes", encode: true);
|
||||
if (data.isNotEmpty) {
|
||||
final name = MBridge.getMapValue(data, "name");
|
||||
scan += "$name".toString();
|
||||
final username = MBridge.getMapValue(data, "username");
|
||||
if (username.isNotEmpty) {
|
||||
if (scan.isEmpty) {
|
||||
scan += "Uploaded by $username".toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (scan.isEmpty) {
|
||||
scan = "No Group".toString();
|
||||
}
|
||||
final dataRes = MBridge.getMapValue(res, "attributes", encode: true);
|
||||
if (dataRes.isNotEmpty) {
|
||||
final data = MBridge.getMapValue(res, "attributes", encode: true);
|
||||
final volume = MBridge.getMapValue(data, "volume");
|
||||
if (volume.isNotEmpty) {
|
||||
if (volume != "null") {
|
||||
chapName = "Vol.$volume ".toString();
|
||||
}
|
||||
}
|
||||
final chapter = MBridge.getMapValue(data, "chapter");
|
||||
if (chapter.isNotEmpty) {
|
||||
if (chapter != "null") {
|
||||
chapName += "Ch.$chapter ".toString();
|
||||
}
|
||||
}
|
||||
final title = MBridge.getMapValue(data, "title");
|
||||
if (title.isNotEmpty) {
|
||||
if (title != "null") {
|
||||
if (chapName.isNotEmpty) {
|
||||
chapName += "- ".toString();
|
||||
}
|
||||
chapName += "$title".toString();
|
||||
}
|
||||
}
|
||||
if (chapName.isEmpty) {
|
||||
chapName += "Oneshot".toString();
|
||||
}
|
||||
final date = MBridge.getMapValue(data, "publishAt");
|
||||
final id = MBridge.getMapValue(res, "id");
|
||||
MChapter chapterr = MChapter();
|
||||
chapterr.name = chapName;
|
||||
chapterr.url = id;
|
||||
chapterr.scanlator = scan;
|
||||
chapterr.dateUpload = MBridge.parseDates(
|
||||
[date], "yyyy-MM-dd'T'HH:mm:ss+SSS", "en_US")
|
||||
.first;
|
||||
chaptersList.add(chapterr);
|
||||
}
|
||||
}
|
||||
|
||||
return chaptersList;
|
||||
}
|
||||
|
||||
Future<String> paginatedChapterListRequest(
|
||||
String mangaId, int offset, String lang) async {
|
||||
final url =
|
||||
'https://api.mangadex.org/manga/$mangaId/feed?limit=500&offset=$offset&includes[]=user&includes[]=scanlation_group&order[volume]=desc&order[chapter]=desc&translatedLanguage[]=$lang&includeFuturePublishAt=0&includeEmptyPages=0${getMDXContentRating()}';
|
||||
final res = await MBridge.http('GET', json.encode({"url": url}));
|
||||
return res;
|
||||
}
|
||||
|
||||
String getMDXContentRating() {
|
||||
String ctnRating =
|
||||
"&contentRating[]=suggestive&contentRating[]=safe&contentRating[]=erotica&contentRating[]=pornographic";
|
||||
return ctnRating;
|
||||
}
|
||||
|
||||
String findTitle(Map<String, dynamic> dataRes, String lang) {
|
||||
final altTitlesJ = dataRes["attributes"]["altTitles"];
|
||||
final titleJ = dataRes["attributes"]["title"];
|
||||
final title = MBridge.getMapValue(json.encode(titleJ), "en");
|
||||
if (title.isEmpty) {
|
||||
for (var r in altTitlesJ) {
|
||||
final altTitle = MBridge.getMapValue(json.encode(r), "en");
|
||||
if (altTitle.isNotEmpty) {
|
||||
return altTitle;
|
||||
}
|
||||
}
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
String getCover(Map<String, dynamic> dataRes) {
|
||||
final relationships = dataRes["relationships"];
|
||||
String coverFileName = "".toString();
|
||||
for (var a in relationships) {
|
||||
final relationType = a["type"];
|
||||
if (relationType == "cover_art") {
|
||||
if (coverFileName.isEmpty) {
|
||||
coverFileName =
|
||||
"https://uploads.mangadex.org/covers/${dataRes["id"]}/${a["attributes"]["fileName"]}";
|
||||
}
|
||||
}
|
||||
}
|
||||
return coverFileName;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<MVideo>> getVideoList(MSource sourceInfo, String url) async {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
MangaDex main() {
|
||||
return MangaDex();
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import '../../../../utils/utils.dart';
|
||||
const apiUrl = 'https://api.mangadex.org';
|
||||
const baseUrl = 'https://mangadex.org';
|
||||
const isNsfw = true;
|
||||
const mangadexVersion = "0.0.3";
|
||||
const mangadexVersion = "0.0.35";
|
||||
const mangadexSourceCodeUrl =
|
||||
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/main/manga/src/all/mangadex/mangadex-v$mangadexVersion.dart";
|
||||
String _iconUrl = getIconUrl("mangadex", "all");
|
||||
|
||||
Reference in New Issue
Block a user