mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 10:51:17 +00:00
Refactor
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import 'dart:convert';
|
||||
import 'package:bridge_lib/bridge_lib.dart';
|
||||
|
||||
getPopularManga(MangaModel manga) async {
|
||||
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 res = await MBridge.http('GET', json.encode(data));
|
||||
@@ -16,20 +16,20 @@ String lang(String lang) {
|
||||
return "langs=$lang";
|
||||
}
|
||||
|
||||
getLatestUpdatesManga(MangaModel manga) async {
|
||||
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 res = await MBridge.http('GET', json.encode(data));
|
||||
return mangaElementM(res, manga);
|
||||
}
|
||||
|
||||
searchManga(MangaModel manga) async {
|
||||
searchManga(MManga manga) async {
|
||||
final data = {"url": "${manga.baseUrl}/search?word=${manga.query}&page=${manga.page}", "sourceId": manga.sourceId};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
return mangaElementM(res, manga);
|
||||
}
|
||||
|
||||
getMangaDetail(MangaModel manga) async {
|
||||
getMangaDetail(MManga manga) async {
|
||||
final statusList = [
|
||||
{
|
||||
"Ongoing": 0,
|
||||
@@ -88,7 +88,7 @@ getMangaDetail(MangaModel manga) async {
|
||||
return manga;
|
||||
}
|
||||
|
||||
getChapterUrl(MangaModel manga) async {
|
||||
getChapterPages(MManga manga) async {
|
||||
final datas = {"url": "${manga.baseUrl}${manga.link}", "sourceId": manga.sourceId};
|
||||
final res = await MBridge.http('GET', json.encode(datas));
|
||||
if (res.isEmpty) {
|
||||
@@ -114,7 +114,7 @@ getChapterUrl(MangaModel manga) async {
|
||||
return pagesUrl;
|
||||
}
|
||||
|
||||
MangaModel mangaElementM(String res, MangaModel manga) async {
|
||||
MManga mangaElementM(String res, MManga manga) async {
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import '../../../../model/source.dart';
|
||||
import '../../../../utils/utils.dart';
|
||||
|
||||
const batotoVersion = "0.0.2";
|
||||
const batotoVersion = "0.0.3";
|
||||
const batotoSourceCodeUrl =
|
||||
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/main/manga/src/all/batoto/batoto-v$batotoVersion.dart";
|
||||
|
||||
@@ -128,6 +128,5 @@ List<Source> _batotoSourcesList = languages
|
||||
isNsfw: isNsfw,
|
||||
dateFormatLocale: "en",
|
||||
version: batotoVersion,
|
||||
appMinVerReq: "0.0.43",
|
||||
sourceCodeUrl: batotoSourceCodeUrl))
|
||||
.toList();
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import 'package:bridge_lib/bridge_lib.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
getLatestUpdatesManga(MangaModel manga) async {
|
||||
final url = "${manga.apiUrl}/v1.0/search?sort=uploaded&page=${manga.page}&tachiyomi=true";
|
||||
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 res = await MBridge.http('GET', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
@@ -20,7 +21,7 @@ getLatestUpdatesManga(MangaModel manga) async {
|
||||
return manga;
|
||||
}
|
||||
|
||||
getMangaDetail(MangaModel manga) async {
|
||||
getMangaDetail(MManga manga) async {
|
||||
final statusList = [
|
||||
{
|
||||
"1": 0,
|
||||
@@ -32,16 +33,19 @@ getMangaDetail(MangaModel manga) async {
|
||||
|
||||
final headers = getHeader(manga.baseUrl);
|
||||
|
||||
final urll = "${manga.apiUrl}${manga.link.replaceAll("#", '')}?tachiyomi=true";
|
||||
final urll =
|
||||
"${manga.apiUrl}${manga.link.replaceAll("#", '')}?tachiyomi=true";
|
||||
final data = {"url": urll, "headers": headers};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
}
|
||||
manga.author = MBridge.jsonPathToString(res, r'$.authors[*].name', '');
|
||||
manga.genre = MBridge.jsonPathToString(res, r'$.genres[*].name', "_.").split("_.");
|
||||
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);
|
||||
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};
|
||||
@@ -54,19 +58,32 @@ getMangaDetail(MangaModel manga) async {
|
||||
final newDataReq = {"url": newChapUrlReq, "headers": headers};
|
||||
final newRequest = await MBridge.http('GET', json.encode(newDataReq));
|
||||
|
||||
manga.urls = MBridge.jsonPathToString(newRequest, r'$.chapters[*].hid', "_.").split("_.");
|
||||
final chapDate = MBridge.jsonPathToString(newRequest, r'$.chapters[*].created_at', "_.").split("_.");
|
||||
manga.chaptersDateUploads =MBridge.listParseDateTime(chapDate, "yyyy-MM-dd'T'HH:mm:ss'Z'", "en");
|
||||
manga.chaptersVolumes = MBridge.jsonPathToString(newRequest, r'$.chapters[*].vol', "_.").split("_.");
|
||||
manga.chaptersScanlators = MBridge.jsonPathToString(newRequest, r'$.chapters[*].group_name', "_.").split("_.");
|
||||
manga.names = MBridge.jsonPathToString(newRequest, r'$.chapters[*].title', "_.").split("_.");
|
||||
manga.chaptersChaps = MBridge.jsonPathToString(newRequest, r'$.chapters[*].chap', "_.").split("_.");
|
||||
manga.urls = MBridge.jsonPathToString(newRequest, r'$.chapters[*].hid', "_.")
|
||||
.split("_.");
|
||||
final chapDate =
|
||||
MBridge.jsonPathToString(newRequest, r'$.chapters[*].created_at', "_.")
|
||||
.split("_.");
|
||||
manga.chaptersDateUploads =
|
||||
MBridge.listParseDateTime(chapDate, "yyyy-MM-dd'T'HH:mm:ss'Z'", "en");
|
||||
manga.chaptersVolumes =
|
||||
MBridge.jsonPathToString(newRequest, r'$.chapters[*].vol', "_.")
|
||||
.split("_.");
|
||||
manga.chaptersScanlators =
|
||||
MBridge.jsonPathToString(newRequest, r'$.chapters[*].group_name', "_.")
|
||||
.split("_.");
|
||||
manga.names =
|
||||
MBridge.jsonPathToString(newRequest, r'$.chapters[*].title', "_.")
|
||||
.split("_.");
|
||||
manga.chaptersChaps =
|
||||
MBridge.jsonPathToString(newRequest, r'$.chapters[*].chap', "_.")
|
||||
.split("_.");
|
||||
|
||||
return manga;
|
||||
}
|
||||
|
||||
getPopularManga(MangaModel manga) async {
|
||||
final urll = "${manga.apiUrl}/v1.0/search?sort=follow&page=${manga.page}&tachiyomi=true";
|
||||
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 res = await MBridge.http('GET', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
@@ -83,7 +100,7 @@ getPopularManga(MangaModel manga) async {
|
||||
return manga;
|
||||
}
|
||||
|
||||
searchManga(MangaModel manga) async {
|
||||
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 res = await MBridge.http('GET', json.encode(data));
|
||||
@@ -101,20 +118,22 @@ searchManga(MangaModel manga) async {
|
||||
return manga;
|
||||
}
|
||||
|
||||
getChapterUrl(MangaModel manga) async {
|
||||
getChapterPages(MManga manga) async {
|
||||
final url = "${manga.apiUrl}/chapter/${manga.link}?tachiyomi=true";
|
||||
final data = {"url": url, "headers": getHeader(url)};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
return [];
|
||||
}
|
||||
return MBridge.jsonPathToString(res, r'$.chapter.images[*].url', '_.').split('_.');
|
||||
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"
|
||||
'User-Agent':
|
||||
"Tachiyomi Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:110.0) Gecko/20100101 Firefox/110.0"
|
||||
};
|
||||
return headers;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import '../../../../model/source.dart';
|
||||
import '../../../../utils/utils.dart';
|
||||
|
||||
const comickVersion = "0.0.2";
|
||||
const comickVersion = "0.0.3";
|
||||
const comickSourceCodeUrl =
|
||||
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/main/manga/src/all/comick/comick-v$comickVersion.dart";
|
||||
|
||||
|
||||
@@ -1,43 +1,198 @@
|
||||
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 res = await MBridge.http('GET', json.encode(datas));
|
||||
|
||||
return parseManga(res, 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 ress = await MBridge.http('GET', json.encode(datas));
|
||||
if (ress.isEmpty) {
|
||||
return manga;
|
||||
}
|
||||
|
||||
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));
|
||||
return parseManga(res, 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.isEmpty) {
|
||||
return manga;
|
||||
}
|
||||
return parseManga(res, 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 res = await MBridge.http('GET', json.encode(datas));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
}
|
||||
|
||||
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 res = await MBridge.http('GET', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
return [];
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
String getMDXContentRating() {
|
||||
String ctnRating =
|
||||
"&contentRating[]=suggestive&contentRating[]=safe&contentRating[]=erotica&contentRating[]=pornographic";
|
||||
return ctnRating;
|
||||
}
|
||||
|
||||
getPopularManga(MangaModel 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, "headers": null};
|
||||
final res = await MBridge.http('GET', json.encode(datas));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
}
|
||||
|
||||
List<String> data = MBridge.listParse(
|
||||
MBridge.jsonPathToString(res, r'$.data[*]', '_.').split("_."), 0);
|
||||
List<String> urlList = [];
|
||||
List<String> titleList = [];
|
||||
List<String> imageList = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
final expressionId =
|
||||
MBridge.regExp(r'$.data[a].id', r'\[a\]', "[$i]", 0, 1);
|
||||
final id = MBridge.jsonPathToString(res, expressionId, '_.');
|
||||
titleList.add(findTitle(res, i, manga.lang));
|
||||
urlList.add("/manga/$id");
|
||||
imageList.add(getCover(res, i, id));
|
||||
}
|
||||
manga.names = titleList;
|
||||
manga.urls = urlList;
|
||||
manga.images = imageList;
|
||||
return manga;
|
||||
}
|
||||
|
||||
MangaModel getChapters(
|
||||
MangaModel manga, int length, String paginatedChapterListA) {
|
||||
MManga getChapters(MManga manga, int length, String paginatedChapterListA) {
|
||||
String scanlators = "".toString();
|
||||
String chapNames = "".toString();
|
||||
String chapDate = "".toString();
|
||||
@@ -120,289 +275,52 @@ MangaModel getChapters(
|
||||
return manga;
|
||||
}
|
||||
|
||||
getMangaDetail(MangaModel 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, "headers": null};
|
||||
final res = await MBridge.http('GET', json.encode(datas));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
}
|
||||
|
||||
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<MangaModel> 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.isEmpty) {
|
||||
} else {
|
||||
chapNames.add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var element in chapterListA) {
|
||||
for (var url in element.urls) {
|
||||
if (url.isEmpty) {
|
||||
} else {
|
||||
chapterUrl.add(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var element in chapterListA) {
|
||||
for (var chapDate in element.chaptersDateUploads) {
|
||||
if (chapDate.isEmpty) {
|
||||
} else {
|
||||
chapterDate.add(chapDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var element in chapterListA) {
|
||||
for (var scanlator in element.chaptersScanlators) {
|
||||
if (scanlator.isEmpty) {
|
||||
} else {
|
||||
scanlators.add(scanlator);
|
||||
}
|
||||
}
|
||||
}
|
||||
manga.urls = chapterUrl;
|
||||
manga.chaptersDateUploads = chapterDate;
|
||||
manga.chaptersScanlators = scanlators;
|
||||
manga.names = chapNames;
|
||||
return manga;
|
||||
}
|
||||
|
||||
getLatestUpdatesManga(MangaModel 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, "headers": null};
|
||||
final ress = await MBridge.http('GET', json.encode(datas));
|
||||
if (ress.isEmpty) {
|
||||
return manga;
|
||||
}
|
||||
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, "headers": null};
|
||||
final res = await MBridge.http('GET', json.encode(datass));
|
||||
List<String> data = MBridge.listParse(
|
||||
MBridge.jsonPathToString(res, r'$.data[*]', '_.').split("_."), 0);
|
||||
List<String> urlList = [];
|
||||
List<String> titleList = [];
|
||||
List<String> imageList = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
final expressionId =
|
||||
MBridge.regExp(r'$.data[a].id', r'\[a\]', "[$i]", 0, 1);
|
||||
final id = MBridge.jsonPathToString(res, expressionId, '_.');
|
||||
titleList.add(findTitle(res, i, manga.lang));
|
||||
urlList.add("/manga/$id");
|
||||
imageList.add(getCover(res, i, id));
|
||||
}
|
||||
manga.names = titleList;
|
||||
manga.urls = urlList;
|
||||
manga.images = imageList;
|
||||
return manga;
|
||||
}
|
||||
|
||||
searchManga(MangaModel 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, "headers": null};
|
||||
final res = await MBridge.http('GET', json.encode(datas));
|
||||
if (res.isEmpty) {
|
||||
return manga;
|
||||
}
|
||||
List<String> data = MBridge.listParse(
|
||||
MBridge.jsonPathToString(res, r'$.data[*]', '_.').split("_."), 0);
|
||||
List<String> urlList = [];
|
||||
List<String> titleList = [];
|
||||
List<String> imageList = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
final expressionId =
|
||||
MBridge.regExp(r'$.data[a].id', r'\[a\]', "[$i]", 0, 1);
|
||||
final id = MBridge.jsonPathToString(res, expressionId, '_.');
|
||||
titleList.add(findTitle(res, i, manga.lang));
|
||||
urlList.add("/manga/$id");
|
||||
imageList.add(getCover(res, i, id));
|
||||
}
|
||||
manga.names = titleList;
|
||||
manga.urls = urlList;
|
||||
manga.images = imageList;
|
||||
return manga;
|
||||
}
|
||||
|
||||
getChapterUrl(MangaModel manga) async {
|
||||
final url = "https://api.mangadex.org/at-home/server/${manga.link}";
|
||||
final data = {"url": url, "headers": null};
|
||||
final res = await MBridge.http('GET', json.encode(data));
|
||||
if (res.isEmpty) {
|
||||
return [];
|
||||
}
|
||||
final host = MBridge.jsonPathToString(res, r'$.baseUrl', '');
|
||||
final hash = MBridge.jsonPathToString(res, r'$.chapter.hash', '');
|
||||
List<String> pageSuffix = [];
|
||||
List<String> pageUrls = [];
|
||||
List<String> chapterDatas = MBridge.listParse(
|
||||
MBridge.jsonPathToString(res, r'$.chapter.data[*]', '.--').split('.--'),
|
||||
0);
|
||||
for (var d in chapterDatas) {
|
||||
pageSuffix.add("/data/$hash/$d");
|
||||
}
|
||||
for (var url in pageSuffix) {
|
||||
pageUrls.add("$host$url");
|
||||
}
|
||||
|
||||
return pageUrls;
|
||||
}
|
||||
|
||||
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, "headers": null};
|
||||
final datas = {"url": url};
|
||||
return await MBridge.http('GET', json.encode(datas));
|
||||
}
|
||||
|
||||
String findTitle(String dataRes, int mangaIndex, String lang) {
|
||||
String expressionAltTitlesA = MBridge.regExp(
|
||||
r'$.data[a].attributes.altTitles[b]', r'\[a\]', "[$mangaIndex]", 0, 1);
|
||||
String expressionAltTitles =
|
||||
MBridge.regExp(expressionAltTitlesA, r'\[b\]', "[*].$lang", 0, 1);
|
||||
|
||||
String altTitles =
|
||||
MBridge.jsonPathToString(dataRes, expressionAltTitles, '_.');
|
||||
|
||||
if (altTitles.isEmpty) {
|
||||
expressionAltTitles = MBridge.regExp(
|
||||
r'$.data[a].attributes.altTitles[?@.en].en',
|
||||
r'\[a\]',
|
||||
"[$mangaIndex]",
|
||||
0,
|
||||
1);
|
||||
altTitles = MBridge.jsonPathToString(dataRes, expressionAltTitles, '_.');
|
||||
}
|
||||
List<String> dataAltTitles = MBridge.listParse(altTitles.split('_.'), 0);
|
||||
final expressionTitle = MBridge.regExp(
|
||||
r'$.data[a].attributes.title.en', r'\[a\]', "[$mangaIndex]", 0, 1);
|
||||
final title = MBridge.jsonPathToString(dataRes, expressionTitle, '_.');
|
||||
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) {
|
||||
return dataAltTitles[0];
|
||||
} else {
|
||||
return title;
|
||||
for (var r in altTitlesJ) {
|
||||
final altTitle = MBridge.getMapValue(json.encode(r), "en");
|
||||
if (altTitle.isNotEmpty) {
|
||||
return altTitle;
|
||||
}
|
||||
}
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
String getCover(String dataRes, int mangaIndex, String mangaId) {
|
||||
final expressionRelationAll = MBridge.regExp(
|
||||
r'$.data[a].relationships[*]', r'\[a\]', "[$mangaIndex]", 0, 1);
|
||||
List<String> relationDatas = MBridge.listParse(
|
||||
MBridge.jsonPathToString(dataRes, expressionRelationAll, '_.')
|
||||
.split("_."),
|
||||
0);
|
||||
String getCover(Map<String, dynamic> dataRes) {
|
||||
final relationships = dataRes["relationships"];
|
||||
String coverFileName = "".toString();
|
||||
for (var j = 0; j < relationDatas.length; j++) {
|
||||
final expressionData = MBridge.regExp(
|
||||
r'$.data[a].relationships[b]', r'\[a\]', "[$mangaIndex]", 0, 1);
|
||||
final expressionRelationType =
|
||||
MBridge.regExp(expressionData, r'\[b\]', "[$j].type", 0, 1);
|
||||
final relationType =
|
||||
MBridge.jsonPathToString(dataRes, expressionRelationType, '');
|
||||
for (var a in relationships) {
|
||||
final relationType = a["type"];
|
||||
if (relationType == "cover_art") {
|
||||
if (coverFileName.isEmpty) {
|
||||
final expressionRelationCoverFile = MBridge.regExp(
|
||||
expressionData, r'\[b\]', "[$j].attributes.fileName", 0, 1);
|
||||
coverFileName =
|
||||
MBridge.jsonPathToString(dataRes, expressionRelationCoverFile, '');
|
||||
|
||||
coverFileName =
|
||||
"https://uploads.mangadex.org/covers/$mangaId/$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;
|
||||
}
|
||||
@@ -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.2";
|
||||
const mangadexVersion = "0.0.3";
|
||||
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