mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 10:51:17 +00:00
add source preference
This commit is contained in:
@@ -356,7 +356,7 @@ class Madara extends MProvider {
|
||||
}
|
||||
|
||||
@override
|
||||
List<dynamic> getFilterList() {
|
||||
List<dynamic> getFilterList(MSource source) {
|
||||
return [
|
||||
TextFilter("AuthorFilter", "Author"),
|
||||
TextFilter("ArtistFilter", "Artist"),
|
||||
|
||||
@@ -236,7 +236,7 @@ class MangaReader extends MProvider {
|
||||
}
|
||||
|
||||
@override
|
||||
List<dynamic> getFilterList() {
|
||||
List<dynamic> getFilterList(MSource source) {
|
||||
return [
|
||||
SeparatorFilter(),
|
||||
TextFilter("AuthorFilter", "Author"),
|
||||
|
||||
@@ -232,7 +232,7 @@ class MMRCMS extends MProvider {
|
||||
return pagesUrl;
|
||||
}
|
||||
|
||||
List<dynamic> getFilterList() {
|
||||
List<dynamic> getFilterList(MSource source) {
|
||||
return [
|
||||
HeaderFilter("NOTE: Ignored if using text search!"),
|
||||
SeparatorFilter(),
|
||||
|
||||
@@ -10,9 +10,15 @@ class NepNep extends MProvider {
|
||||
final res = await http('GET', json.encode(data));
|
||||
|
||||
final directory = directoryFromDocument(res);
|
||||
final resSort = sortMapList(json.decode(directory), "vm", 1);
|
||||
final resSort = (json.decode(directory) as List<Map<String, dynamic>>);
|
||||
resSort.sort(
|
||||
(Map<String, dynamic> a, Map<String, dynamic> b) =>
|
||||
(a["vm"] as String).compareTo(b["vm"] as String),
|
||||
);
|
||||
|
||||
return parseDirectory(resSort);
|
||||
// sortMapList(json.decode(directory), "vm", 1);
|
||||
|
||||
return parseDirectory(json.encode(resSort));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -308,7 +314,7 @@ class NepNep extends MProvider {
|
||||
}
|
||||
|
||||
@override
|
||||
List<dynamic> getFilterList() {
|
||||
List<dynamic> getFilterList(MSource source) {
|
||||
return [
|
||||
TextFilter("YearFilter", "Years"),
|
||||
TextFilter("AuthorFilter", "Author"),
|
||||
|
||||
@@ -7,7 +7,7 @@ class Batoto extends MProvider {
|
||||
@override
|
||||
Future<MPages> getPopular(MSource source, int page) async {
|
||||
final url =
|
||||
"${source.baseUrl}/browse?${lang(source.lang)}&sort=views_a&page=$page";
|
||||
"${preferenceMirror(source.id)}/browse?${lang(source.lang)}&sort=views_a&page=$page";
|
||||
final data = {"url": url};
|
||||
final res = await http('GET', json.encode(data));
|
||||
return mangaElementM(res, source);
|
||||
@@ -16,7 +16,7 @@ class Batoto extends MProvider {
|
||||
@override
|
||||
Future<MPages> getLatestUpdates(MSource source, int page) async {
|
||||
final url =
|
||||
"${source.baseUrl}/browse?${lang(source.lang)}&sort=update&page=$page";
|
||||
"${preferenceMirror(source.id)}/browse?${lang(source.lang)}&sort=update&page=$page";
|
||||
final data = {"url": url};
|
||||
final res = await http('GET', json.encode(data));
|
||||
return mangaElementM(res, source);
|
||||
@@ -30,7 +30,7 @@ class Batoto extends MProvider {
|
||||
String min = "";
|
||||
String max = "";
|
||||
if (query.isNotEmpty) {
|
||||
url = "${source.baseUrl}/search?word=$query&page=$page";
|
||||
url = "${preferenceMirror(source.id)}/search?word=$query&page=$page";
|
||||
for (var filter in filters) {
|
||||
if (filter.type == "LetterFilter") {
|
||||
if (filter.state == 1) {
|
||||
@@ -39,7 +39,7 @@ class Batoto extends MProvider {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
url = "${source.baseUrl}/browse";
|
||||
url = "${preferenceMirror(source.id)}/browse";
|
||||
for (var filter in filters) {
|
||||
if (filter.type == "LangGroupFilter") {
|
||||
final langs = (filter.state as List).where((e) => e.state).toList();
|
||||
@@ -111,7 +111,7 @@ class Batoto extends MProvider {
|
||||
{"Ongoing": 0, "Completed": 1, "Cancelled": 3, "Hiatus": 2}
|
||||
];
|
||||
|
||||
final data = {"url": "${source.baseUrl}$url"};
|
||||
final data = {"url": "${preferenceMirror(source.id)}$url"};
|
||||
final res = await http('GET', json.encode(data));
|
||||
MManga manga = MManga();
|
||||
final workStatus = xpath(res,
|
||||
@@ -171,7 +171,7 @@ class Batoto extends MProvider {
|
||||
|
||||
@override
|
||||
Future<List<String>> getPageList(MSource source, String url) async {
|
||||
final datas = {"url": "${source.baseUrl}$url"};
|
||||
final datas = {"url": "${preferenceMirror(source.id)}$url"};
|
||||
final res = await http('GET', json.encode(datas));
|
||||
|
||||
final script = xpath(res,
|
||||
@@ -273,7 +273,7 @@ class Batoto extends MProvider {
|
||||
}
|
||||
|
||||
@override
|
||||
List<dynamic> getFilterList() {
|
||||
List<dynamic> getFilterList(MSource source) {
|
||||
return [
|
||||
SelectFilter("LetterFilter", "Letter matching mode (Slow)", 0, [
|
||||
SelectFilterOption("Disabled", "disabled"),
|
||||
@@ -1663,36 +1663,51 @@ class Batoto extends MProvider {
|
||||
SeparatorFilter(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
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",
|
||||
};
|
||||
@override
|
||||
List<dynamic> getSourcePreferences(MSource source) {
|
||||
return [
|
||||
ListPreference(
|
||||
key: "mirror",
|
||||
title: "Mirror",
|
||||
summary: "",
|
||||
valueIndex: 0,
|
||||
entries: mirrorEntries,
|
||||
entryValues: mirrorEntries.map((e) => "https://$e").toList()),
|
||||
];
|
||||
}
|
||||
|
||||
List<String> mirrorEntries = [
|
||||
"bato.to",
|
||||
"batocomic.com",
|
||||
"batocomic.net",
|
||||
"batocomic.org",
|
||||
"batotoo.com",
|
||||
"batotwo.com",
|
||||
"battwo.com",
|
||||
"comiko.net",
|
||||
"comiko.org",
|
||||
"mangatoto.com",
|
||||
"mangatoto.net",
|
||||
"mangatoto.org",
|
||||
"readtoto.com",
|
||||
"readtoto.net",
|
||||
"readtoto.org",
|
||||
"dto.to",
|
||||
"hto.to",
|
||||
"mto.to",
|
||||
"wto.to",
|
||||
"xbato.com",
|
||||
"xbato.net",
|
||||
"xbato.org",
|
||||
"zbato.com",
|
||||
"zbato.net",
|
||||
"zbato.org",
|
||||
];
|
||||
|
||||
String preferenceMirror(int sourceId) {
|
||||
return getPreferenceValue(sourceId, "mirror");
|
||||
}
|
||||
}
|
||||
|
||||
Batoto main() {
|
||||
@@ -1,7 +1,7 @@
|
||||
import '../../../../model/source.dart';
|
||||
import '../../../../utils/utils.dart';
|
||||
|
||||
const batotoVersion = "0.0.4";
|
||||
const batotoVersion = "0.0.45";
|
||||
const batotoSourceCodeUrl =
|
||||
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/main/manga/src/all/batoto/batoto-v$batotoVersion.dart";
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ class ComickFun extends MProvider {
|
||||
}
|
||||
|
||||
@override
|
||||
List<dynamic> getFilterList() {
|
||||
List<dynamic> getFilterList(MSource source) {
|
||||
return [
|
||||
HeaderFilter("The filter is ignored when using text search."),
|
||||
GroupFilter("GenreFilter", "Genre", [
|
||||
|
||||
@@ -8,7 +8,7 @@ class MangaDex extends MProvider {
|
||||
Future<MPages> getPopular(MSource source, int page) async {
|
||||
page = (20 * (page - 1));
|
||||
final url =
|
||||
"https://api.mangadex.org/manga?limit=20&offset=$page&availableTranslatedLanguage[]=${source.lang}&includes[]=cover_art${getMDXContentRating()}&order[followedCount]=desc";
|
||||
"https://api.mangadex.org/manga?limit=20&offset=$page&availableTranslatedLanguage[]=${source.lang}&includes[]=cover_art${preferenceContentRating(source.id)}${preferenceOriginalLanguages(source.id)}&order[followedCount]=desc";
|
||||
final datas = {"url": url};
|
||||
final res = await http('GET', json.encode(datas));
|
||||
return mangaRes(res, source);
|
||||
@@ -24,12 +24,12 @@ class MangaDex extends MProvider {
|
||||
final mangaIds =
|
||||
jsonPathToString(ress, r'$.data[*].relationships[*].id', '.--')
|
||||
.split('.--');
|
||||
String mangaIdss = "".toString();
|
||||
String mangaIdss = "";
|
||||
for (var id in mangaIds) {
|
||||
mangaIdss += "&ids[]=$id";
|
||||
}
|
||||
final newUrl =
|
||||
"https://api.mangadex.org/manga?includes[]=cover_art&limit=${mangaIds.length}${getMDXContentRating()}$mangaIdss";
|
||||
"https://api.mangadex.org/manga?includes[]=cover_art&limit=${mangaIds.length}${preferenceContentRating(source.id)}${preferenceOriginalLanguages(source.id)}$mangaIdss";
|
||||
final res = await http('GET', json.encode({"url": newUrl}));
|
||||
return mangaRes(res, source);
|
||||
}
|
||||
@@ -188,7 +188,7 @@ class MangaDex extends MProvider {
|
||||
final mangaId = url.split('/').last;
|
||||
|
||||
final paginatedChapterList =
|
||||
await paginatedChapterListRequest(mangaId, 0, source.lang);
|
||||
await paginatedChapterListRequest(mangaId, 0, source.lang, source.id);
|
||||
final chapterList =
|
||||
jsonPathToString(paginatedChapterList, r'$.data[*]', '_.').split('_.');
|
||||
int limit =
|
||||
@@ -206,8 +206,8 @@ class MangaDex extends MProvider {
|
||||
var hasMoreResults = (limit + offset) < total;
|
||||
while (hasMoreResults) {
|
||||
offset += limit;
|
||||
var newRequest =
|
||||
await paginatedChapterListRequest(mangaId, offset, source.lang);
|
||||
var newRequest = await paginatedChapterListRequest(
|
||||
mangaId, offset, source.lang, source.id);
|
||||
int total = int.parse(jsonPathToString(newRequest, r'$.total', ''));
|
||||
final chapterList =
|
||||
jsonPathToString(paginatedChapterList, r'$.data[*]', '_.')
|
||||
@@ -244,7 +244,7 @@ class MangaDex extends MProvider {
|
||||
for (var e in resJson) {
|
||||
MManga manga = MManga();
|
||||
manga.name = findTitle(json.encode(e), source.lang);
|
||||
manga.imageUrl = getCover(json.encode(e));
|
||||
manga.imageUrl = getCover(json.encode(e), source.id);
|
||||
manga.link = "/manga/${getMapValue(json.encode(e), "id")}";
|
||||
mangaList.add(manga);
|
||||
}
|
||||
@@ -253,28 +253,28 @@ class MangaDex extends MProvider {
|
||||
|
||||
List<MChapter> getChapters(int length, String paginatedChapterListA) {
|
||||
List<MChapter> chaptersList = [];
|
||||
String paginatedChapterList = paginatedChapterListA.toString();
|
||||
String paginatedChapterList = paginatedChapterListA;
|
||||
final dataList = jsonPathToList(paginatedChapterList, r'$.data[*]', 0);
|
||||
for (var res in dataList) {
|
||||
String scan = "".toString();
|
||||
String scan = "";
|
||||
final groups = jsonPathToList(res,
|
||||
r'$.relationships[?@.id!="00e03853-1b96-4f41-9542-c71b8692033b"]', 0);
|
||||
String chapName = "".toString();
|
||||
String chapName = "";
|
||||
for (var element in groups) {
|
||||
final data = getMapValue(element, "attributes", encode: true);
|
||||
if (data.isNotEmpty) {
|
||||
final name = getMapValue(data, "name");
|
||||
scan += "$name".toString();
|
||||
scan += "$name";
|
||||
final username = getMapValue(data, "username");
|
||||
if (username.isNotEmpty) {
|
||||
if (scan.isEmpty) {
|
||||
scan += "Uploaded by $username".toString();
|
||||
scan += "Uploaded by $username";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (scan.isEmpty) {
|
||||
scan = "No Group".toString();
|
||||
scan = "No Group";
|
||||
}
|
||||
final dataRes = getMapValue(res, "attributes", encode: true);
|
||||
if (dataRes.isNotEmpty) {
|
||||
@@ -282,26 +282,26 @@ class MangaDex extends MProvider {
|
||||
final volume = getMapValue(data, "volume");
|
||||
if (volume.isNotEmpty) {
|
||||
if (volume != "null") {
|
||||
chapName = "Vol.$volume ".toString();
|
||||
chapName = "Vol.$volume ";
|
||||
}
|
||||
}
|
||||
final chapter = getMapValue(data, "chapter");
|
||||
if (chapter.isNotEmpty) {
|
||||
if (chapter != "null") {
|
||||
chapName += "Ch.$chapter ".toString();
|
||||
chapName += "Ch.$chapter ";
|
||||
}
|
||||
}
|
||||
final title = getMapValue(data, "title");
|
||||
if (title.isNotEmpty) {
|
||||
if (title != "null") {
|
||||
if (chapName.isNotEmpty) {
|
||||
chapName += "- ".toString();
|
||||
chapName += "- ";
|
||||
}
|
||||
chapName += "$title".toString();
|
||||
chapName += "$title";
|
||||
}
|
||||
}
|
||||
if (chapName.isEmpty) {
|
||||
chapName += "Oneshot".toString();
|
||||
chapName += "Oneshot";
|
||||
}
|
||||
final date = getMapValue(data, "publishAt");
|
||||
final id = getMapValue(res, "id");
|
||||
@@ -319,19 +319,13 @@ class MangaDex extends MProvider {
|
||||
}
|
||||
|
||||
Future<String> paginatedChapterListRequest(
|
||||
String mangaId, int offset, String lang) async {
|
||||
String mangaId, int offset, String lang, int sourceId) 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()}';
|
||||
'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${preferenceContentRating(sourceId)}';
|
||||
final res = await http('GET', json.encode({"url": url}));
|
||||
return res;
|
||||
}
|
||||
|
||||
String getMDXContentRating() {
|
||||
String ctnRating =
|
||||
"&contentRating[]=suggestive&contentRating[]=safe&contentRating[]=erotica&contentRating[]=pornographic";
|
||||
return ctnRating;
|
||||
}
|
||||
|
||||
String findTitle(String dataRes, String lang) {
|
||||
final attributes = getMapValue(dataRes, "attributes", encode: true);
|
||||
final altTitlesJ =
|
||||
@@ -349,7 +343,8 @@ class MangaDex extends MProvider {
|
||||
return title;
|
||||
}
|
||||
|
||||
String getCover(String dataRes) {
|
||||
String getCover(String dataRes, int sourceId) {
|
||||
final coverQuality = getPreferenceValue(sourceId, "cover_quality");
|
||||
final relationships = json
|
||||
.decode(getMapValue(dataRes, "relationships", encode: true)) as List;
|
||||
String coverFileName = "".toString();
|
||||
@@ -360,7 +355,7 @@ class MangaDex extends MProvider {
|
||||
final attributes =
|
||||
getMapValue(json.encode(a), "attributes", encode: true);
|
||||
coverFileName =
|
||||
"https://uploads.mangadex.org/covers/${getMapValue(dataRes, "id")}/${getMapValue(attributes, "fileName")}";
|
||||
"https://uploads.mangadex.org/covers/${getMapValue(dataRes, "id")}/${getMapValue(attributes, "fileName")}$coverQuality";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -368,7 +363,7 @@ class MangaDex extends MProvider {
|
||||
}
|
||||
|
||||
@override
|
||||
List<dynamic> getFilterList() {
|
||||
List<dynamic> getFilterList(MSource source) {
|
||||
return [
|
||||
CheckBoxFilter(
|
||||
"Has available chapters", "", "HasAvailableChaptersFilter"),
|
||||
@@ -510,6 +505,83 @@ class MangaDex extends MProvider {
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
List<dynamic> getSourcePreferences(MSource source) {
|
||||
return [
|
||||
ListPreference(
|
||||
key: "cover_quality",
|
||||
title: "Cover quality",
|
||||
summary: "",
|
||||
valueIndex: 0,
|
||||
entries: ["Original", "Medium", "Low"],
|
||||
entryValues: ["", ".512.jpg", ".256.jpg"]),
|
||||
MultiSelectListPreference(
|
||||
key: "content_rating",
|
||||
title: "Default content rating",
|
||||
summary: "Show content with the selected rating by default",
|
||||
valueIndex: 0,
|
||||
entries: [
|
||||
"safe",
|
||||
"suggestive",
|
||||
"erotica",
|
||||
"pornographic"
|
||||
],
|
||||
entryValues: [
|
||||
"contentRating[]=safe",
|
||||
"contentRating[]=suggestive",
|
||||
"contentRating[]=erotica",
|
||||
"contentRating[]=pornographic"
|
||||
],
|
||||
values: [
|
||||
"contentRating[]=safe",
|
||||
"contentRating[]=suggestive"
|
||||
]),
|
||||
MultiSelectListPreference(
|
||||
key: "original_languages",
|
||||
title: "Filter original languages",
|
||||
summary:
|
||||
"Only show content that was originaly published in the selected languages in both latest and browse",
|
||||
valueIndex: 0,
|
||||
entries: [
|
||||
"Japanese",
|
||||
"Chinese",
|
||||
"Korean"
|
||||
],
|
||||
entryValues: [
|
||||
"originalLanguage[]=ja",
|
||||
"originalLanguage[]=zh&originalLanguage[]=zh-hk",
|
||||
"originalLanguage[]=ko"
|
||||
],
|
||||
values: []),
|
||||
];
|
||||
}
|
||||
|
||||
String preferenceContentRating(int sourceId) {
|
||||
final contentRating =
|
||||
getPreferenceValue(sourceId, "content_rating") as List<String>;
|
||||
String contentRatingStr = "";
|
||||
if (contentRating.isNotEmpty) {
|
||||
contentRatingStr = "&";
|
||||
for (var ctn in contentRating) {
|
||||
contentRatingStr += "&$ctn";
|
||||
}
|
||||
}
|
||||
return contentRatingStr;
|
||||
}
|
||||
|
||||
String preferenceOriginalLanguages(int sourceId) {
|
||||
final originalLanguages =
|
||||
getPreferenceValue(sourceId, "original_languages") as List<String>;
|
||||
String originalLanguagesStr = "";
|
||||
if (originalLanguages.isNotEmpty) {
|
||||
originalLanguagesStr = "&";
|
||||
for (var language in originalLanguages) {
|
||||
originalLanguagesStr += "&$language";
|
||||
}
|
||||
}
|
||||
return originalLanguagesStr;
|
||||
}
|
||||
|
||||
String ll(String url) {
|
||||
if (url.contains("?")) {
|
||||
return "&";
|
||||
@@ -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.45";
|
||||
const mangadexVersion = "0.0.5";
|
||||
const mangadexSourceCodeUrl =
|
||||
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/main/manga/src/all/mangadex/mangadex-v$mangadexVersion.dart";
|
||||
String _iconUrl = getIconUrl("mangadex", "all");
|
||||
|
||||
@@ -259,7 +259,7 @@ class MangaHere extends MProvider {
|
||||
}
|
||||
|
||||
@override
|
||||
List<dynamic> getFilterList() {
|
||||
List<dynamic> getFilterList(MSource source) {
|
||||
return [
|
||||
SelectFilter("TypeList", "Type", 1, [
|
||||
SelectFilterOption("American Manga", "5"),
|
||||
|
||||
Reference in New Issue
Block a user