mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 10:51:17 +00:00
add filter method
This commit is contained in:
@@ -67,11 +67,53 @@ class Madara extends MProvider {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MPages> search(MSource source, String query, int page) async {
|
||||
final data = {
|
||||
"url": "${source.baseUrl}/?s=$query&post_type=wp-manga",
|
||||
"sourceId": source.id
|
||||
};
|
||||
Future<MPages> search(
|
||||
MSource source, String query, int page, FilterList filterList) async {
|
||||
final filters = filterList.filters;
|
||||
|
||||
String url = "${source.baseUrl}/?s=$query&post_type=wp-manga";
|
||||
|
||||
for (var filter in filters) {
|
||||
if (filter.type == "AuthorFilter") {
|
||||
if (filter.state.isNotEmpty) {
|
||||
url += "${ll(url)}author=${Uri.encodeComponent(filter.state)}";
|
||||
}
|
||||
} else if (filter.type == "ArtistFilter") {
|
||||
if (filter.state.isNotEmpty) {
|
||||
url += "${ll(url)}artist=${Uri.encodeComponent(filter.state)}";
|
||||
}
|
||||
} else if (filter.type == "YearFilter") {
|
||||
if (filter.state.isNotEmpty) {
|
||||
url += "${ll(url)}release=${Uri.encodeComponent(filter.state)}";
|
||||
}
|
||||
} else if (filter.type == "StatusFilter") {
|
||||
final status = (filter.state as List).where((e) => e.state).toList();
|
||||
if (status.isNotEmpty) {
|
||||
for (var st in status) {
|
||||
url += "${ll(url)}status[]=${st.value},";
|
||||
}
|
||||
}
|
||||
} else if (filter.type == "OrderByFilter") {
|
||||
if (filter.state != 0) {
|
||||
final order = filter.values[filter.state].value;
|
||||
url += "${ll(url)}m_orderby=$order";
|
||||
}
|
||||
} else if (filter.type == "AdultContentFilter") {
|
||||
final ctn = filter.values[filter.state].value;
|
||||
if (ctn.isNotEmpty) {
|
||||
url += "${ll(url)}adult=$ctn";
|
||||
}
|
||||
} else if (filter.type == "GenreListFilter") {
|
||||
final genres = (filter.state as List).where((e) => e.state).toList();
|
||||
if (genres.isNotEmpty) {
|
||||
for (var genre in genres) {
|
||||
url += "${ll(url)}genre[]=${genre.value},";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final data = {"url": url, "sourceId": source.id};
|
||||
final res = await http('GET', json.encode(data));
|
||||
|
||||
List<MManga> mangaList = [];
|
||||
@@ -312,6 +354,41 @@ class Madara extends MProvider {
|
||||
}
|
||||
return pageUrls;
|
||||
}
|
||||
|
||||
List<dynamic> getFilterList() {
|
||||
return [
|
||||
TextFilter("AuthorFilter", "Author"),
|
||||
TextFilter("ArtistFilter", "Artist"),
|
||||
TextFilter("YearFilter", "Year of Released"),
|
||||
GroupFilter("StatusFilter", "Status", [
|
||||
CheckBoxFilter("Completed", "end"),
|
||||
CheckBoxFilter("Ongoing", "on-going"),
|
||||
CheckBoxFilter("Canceled", "canceled"),
|
||||
CheckBoxFilter("On Hold", "on-hold"),
|
||||
]),
|
||||
SelectFilter("OrderByFilter", "Order By", 0, [
|
||||
SelectFilterOption("Relevance", ""),
|
||||
SelectFilterOption("Latest", "latest"),
|
||||
SelectFilterOption("A-Z", "alphabet"),
|
||||
SelectFilterOption("Rating", "rating"),
|
||||
SelectFilterOption("Trending", "trending"),
|
||||
SelectFilterOption("Most Views", "views"),
|
||||
SelectFilterOption("New", "new-manga"),
|
||||
]),
|
||||
SelectFilter("AdultContentFilter", "Adult Content", 0, [
|
||||
SelectFilterOption("All", ""),
|
||||
SelectFilterOption("None", "0"),
|
||||
SelectFilterOption("Only", "1"),
|
||||
])
|
||||
];
|
||||
}
|
||||
|
||||
String ll(String url) {
|
||||
if (url.contains("?")) {
|
||||
return "&";
|
||||
}
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
Madara main() {
|
||||
@@ -1,7 +1,7 @@
|
||||
import '../../../model/source.dart';
|
||||
import '../../../utils/utils.dart';
|
||||
|
||||
const madaraVersion = "0.0.35";
|
||||
const madaraVersion = "0.0.4";
|
||||
const madaraSourceCodeUrl =
|
||||
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/main/manga/multisrc/madara/madara-v$madaraVersion.dart";
|
||||
const defaultDateFormat = "MMMM dd, yyyy";
|
||||
|
||||
@@ -25,9 +25,49 @@ class MangaReader extends MProvider {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MPages> search(MSource source, String query, int page) async {
|
||||
final url =
|
||||
Future<MPages> search(
|
||||
MSource source, String query, int page, FilterList filterList) async {
|
||||
final filters = filterList.filters;
|
||||
|
||||
String url =
|
||||
"${source.baseUrl}${getMangaUrlDirectory(source.name)}/?&title=$query&page=$page";
|
||||
|
||||
for (var filter in filters) {
|
||||
if (filter.type == "AuthorFilter") {
|
||||
url += "${ll(url)}author=${Uri.encodeComponent(filter.state)}";
|
||||
} else if (filter.type == "YearFilter") {
|
||||
url += "${ll(url)}yearx=${Uri.encodeComponent(filter.state)}";
|
||||
} else if (filter.type == "StatusFilter") {
|
||||
final status = filter.values[filter.state].value;
|
||||
url += "${ll(url)}status=$status";
|
||||
} else if (filter.type == "TypeFilter") {
|
||||
final type = filter.values[filter.state].value;
|
||||
url += "${ll(url)}type=$type";
|
||||
} else if (filter.type == "OrderByFilter") {
|
||||
final order = filter.values[filter.state].value;
|
||||
url += "${ll(url)}order=$order";
|
||||
} else if (filter.type == "GenreListFilter") {
|
||||
final included = (filter.state as List)
|
||||
.where((e) => e.state == 1 ? true : false)
|
||||
.toList();
|
||||
final excluded = (filter.state as List)
|
||||
.where((e) => e.state == 2 ? true : false)
|
||||
.toList();
|
||||
if (included.isNotEmpty) {
|
||||
url += "${ll(url)}genres[]=";
|
||||
for (var val in included) {
|
||||
url += "${val.value},";
|
||||
}
|
||||
}
|
||||
if (excluded.isNotEmpty) {
|
||||
url += "${ll(url)}genres[]=";
|
||||
for (var val in excluded) {
|
||||
url += "-${val.value},";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final data = {"url": url, "sourceId": source.id};
|
||||
final res = await http('GET', json.encode(data));
|
||||
|
||||
@@ -195,6 +235,47 @@ class MangaReader extends MProvider {
|
||||
return MPages(mangaList, true);
|
||||
}
|
||||
|
||||
List<dynamic> getFilterList() {
|
||||
return [
|
||||
SeparatorFilter(),
|
||||
TextFilter("AuthorFilter", "Author"),
|
||||
TextFilter("YearFilter", "Year"),
|
||||
SelectFilter("StatusFilter", "Status", 0, [
|
||||
SelectFilterOption("All", ""),
|
||||
SelectFilterOption("Ongoing", "ongoing"),
|
||||
SelectFilterOption("Completed", "completed"),
|
||||
SelectFilterOption("Hiatus", "hiatus"),
|
||||
SelectFilterOption("Dropped", "dropped"),
|
||||
]),
|
||||
SelectFilter("TypeFilter", "Type", 0, [
|
||||
SelectFilterOption("All", ""),
|
||||
SelectFilterOption("Manga", "Manga"),
|
||||
SelectFilterOption("Manhwa", "Manhwa"),
|
||||
SelectFilterOption("Manhua", "Manhua"),
|
||||
SelectFilterOption("Comic", "Comic"),
|
||||
]),
|
||||
SelectFilter("OrderByFilter", "Sort By", 0, [
|
||||
SelectFilterOption("Default", ""),
|
||||
SelectFilterOption("A-Z", "title"),
|
||||
SelectFilterOption("Z-A", "titlereverse"),
|
||||
SelectFilterOption("Latest Update", "update"),
|
||||
SelectFilterOption("Latest Added", "latest"),
|
||||
SelectFilterOption("Popular", "popular"),
|
||||
]),
|
||||
HeaderFilter("Genre exclusion is not available for all sources"),
|
||||
GroupFilter("GenreListFilter", "Genre", [
|
||||
TriStateFilter("Press reset to attempt to fetch genres", ""),
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
String ll(String url) {
|
||||
if (url.contains("?")) {
|
||||
return "&";
|
||||
}
|
||||
return "?";
|
||||
}
|
||||
|
||||
String getMangaUrlDirectory(String sourceName) {
|
||||
if (sourceName == "Sushi-Scan") {
|
||||
return "/catalogue";
|
||||
@@ -1,7 +1,7 @@
|
||||
import '../../../model/source.dart';
|
||||
import '../../../utils/utils.dart';
|
||||
|
||||
const mangareaderVersion = "0.0.45";
|
||||
const mangareaderVersion = "0.0.5";
|
||||
const mangareaderSourceCodeUrl =
|
||||
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/main/manga/multisrc/mangareader/mangareader-v$mangareaderVersion.dart";
|
||||
const defaultDateFormat = "MMMM dd, yyyy";
|
||||
|
||||
@@ -68,32 +68,74 @@ class MMRCMS extends MProvider {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MPages> search(MSource source, String query, int page) async {
|
||||
final url = "${source.baseUrl}/search?query=$query";
|
||||
Future<MPages> search(
|
||||
MSource source, String query, int page, FilterList filterList) async {
|
||||
final filters = filterList.filters;
|
||||
String url = "";
|
||||
if (query.isNotEmpty) {
|
||||
url = "${source.baseUrl}/search?query=$query";
|
||||
} else {
|
||||
url = "${source.baseUrl}/filterList?page=$page";
|
||||
for (var filter in filters) {
|
||||
if (filter.type == "AuthorFilter") {
|
||||
url += "${ll(url)}author=${Uri.encodeComponent(filter.state)}";
|
||||
} else if (filter.type == "SortFilter") {
|
||||
url += "${ll(url)}sortBy=${filter.values[filter.state.index].value}";
|
||||
final asc = filter.state.ascending ? "asc=true" : "asc=false";
|
||||
url += "${ll(url)}$asc";
|
||||
} else if (filter.type == "CategoryFilter") {
|
||||
if (filter.state != 0) {
|
||||
final cat = filter.values[filter.state].value;
|
||||
url += "${ll(url)}cat=$cat";
|
||||
}
|
||||
} else if (filter.type == "BeginsWithFilter") {
|
||||
if (filter.state != 0) {
|
||||
final a = filter.values[filter.state].value;
|
||||
url += "${ll(url)}alpha=$a";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final data = {"url": url, "sourceId": source.id};
|
||||
final res = await http('GET', json.encode(data));
|
||||
|
||||
List<MManga> mangaList = [];
|
||||
final jsonList = json.decode(res)["suggestions"];
|
||||
|
||||
List<String> urls = [];
|
||||
List<String> names = [];
|
||||
List<String> images = [];
|
||||
for (var da in jsonList) {
|
||||
String value = da["value"];
|
||||
String data = da["data"];
|
||||
if (source.name == 'Scan VF') {
|
||||
urls.add('${source.baseUrl}/$data');
|
||||
} else if (source.name == 'Manga-FR') {
|
||||
urls.add('${source.baseUrl}/lecture-en-ligne/$data');
|
||||
} else {
|
||||
urls.add('${source.baseUrl}/manga/$data');
|
||||
|
||||
if (query.isNotEmpty) {
|
||||
final jsonList = json.decode(res)["suggestions"];
|
||||
for (var da in jsonList) {
|
||||
String value = da["value"];
|
||||
String data = da["data"];
|
||||
if (source.name == 'Scan VF') {
|
||||
urls.add('${source.baseUrl}/$data');
|
||||
} else if (source.name == 'Manga-FR') {
|
||||
urls.add('${source.baseUrl}/lecture-en-ligne/$data');
|
||||
} else {
|
||||
urls.add('${source.baseUrl}/manga/$data');
|
||||
}
|
||||
names.add(value);
|
||||
if (source.name == "Manga-FR") {
|
||||
images.add("${source.baseUrl}/uploads/manga/$data.jpg");
|
||||
} else {
|
||||
images.add(
|
||||
"${source.baseUrl}/uploads/manga/$data/cover/cover_250x350.jpg");
|
||||
}
|
||||
}
|
||||
names.add(value);
|
||||
if (source.name == "Manga-FR") {
|
||||
images.add("${source.baseUrl}/uploads/manga/$data.jpg");
|
||||
} else {
|
||||
images.add(
|
||||
"${source.baseUrl}/uploads/manga/$data/cover/cover_250x350.jpg");
|
||||
} else {
|
||||
urls = xpath(res, '//div/div/div/a/@href');
|
||||
names = xpath(res, '//div/div/div/a/text()');
|
||||
for (var url in urls) {
|
||||
String slug = substringAfterLast(url, '/');
|
||||
if (source.name == "Manga-FR") {
|
||||
images.add("${source.baseUrl}/uploads/manga/${slug}.jpg");
|
||||
} else {
|
||||
images.add(
|
||||
"${source.baseUrl}/uploads/manga/${slug}/cover/cover_250x350.jpg");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,6 +231,91 @@ class MMRCMS extends MProvider {
|
||||
|
||||
return pagesUrl;
|
||||
}
|
||||
|
||||
List<dynamic> getFilterList() {
|
||||
return [
|
||||
HeaderFilter("NOTE: Ignored if using text search!"),
|
||||
SeparatorFilter(),
|
||||
TextFilter("AuthorFilter", "Author"),
|
||||
SelectFilter("CategoryFilter", "Category", 0, [
|
||||
SelectFilterOption("Any", ""),
|
||||
SelectFilterOption("Action", "Action"),
|
||||
SelectFilterOption("Adventure", "Adventure"),
|
||||
SelectFilterOption("Comedy", "Comedy"),
|
||||
SelectFilterOption("Doujinshi", "Doujinshi"),
|
||||
SelectFilterOption("Drama", "Drama"),
|
||||
SelectFilterOption("Ecchi", "Ecchi"),
|
||||
SelectFilterOption("Fantasy", "Fantasy"),
|
||||
SelectFilterOption("Gender Bender", "Gender Bender"),
|
||||
SelectFilterOption("Harem", "Harem"),
|
||||
SelectFilterOption("Historical", "Historical"),
|
||||
SelectFilterOption("Horror", "Horror"),
|
||||
SelectFilterOption("Josei", "Josei"),
|
||||
SelectFilterOption("Martial Arts", "Martial Arts"),
|
||||
SelectFilterOption("Mature", "Mature"),
|
||||
SelectFilterOption("Mecha", "Mecha"),
|
||||
SelectFilterOption("Mystery", "Mystery"),
|
||||
SelectFilterOption("One Shot", "One Shot"),
|
||||
SelectFilterOption("Psychological", "Psychological"),
|
||||
SelectFilterOption("Romance", "Romance"),
|
||||
SelectFilterOption("School Life", "School Life"),
|
||||
SelectFilterOption("Sci-fi", "Sci-fi"),
|
||||
SelectFilterOption("Seinen", "Seinen"),
|
||||
SelectFilterOption("Shoujo", "Shoujo"),
|
||||
SelectFilterOption("Shoujo Ai", "Shoujo Ai"),
|
||||
SelectFilterOption("Shounen", "Shounen"),
|
||||
SelectFilterOption("Shounen Ai", "Shounen Ai"),
|
||||
SelectFilterOption("Slice of Life", "Slice of Life"),
|
||||
SelectFilterOption("Sports", "Sports"),
|
||||
SelectFilterOption("Supernatural", "Supernatural"),
|
||||
SelectFilterOption("Tragedy", "Tragedy"),
|
||||
SelectFilterOption("Yaoi", "Yaoi"),
|
||||
SelectFilterOption("Yuri", "Yuri"),
|
||||
]),
|
||||
SelectFilter("BeginsWithFilter", "Begins with", 0, [
|
||||
SelectFilterOption("Any", ""),
|
||||
SelectFilterOption("#", "#"),
|
||||
SelectFilterOption("A", "A"),
|
||||
SelectFilterOption("B", "B"),
|
||||
SelectFilterOption("C", "C"),
|
||||
SelectFilterOption("D", "D"),
|
||||
SelectFilterOption("E", "E"),
|
||||
SelectFilterOption("F", "F"),
|
||||
SelectFilterOption("G", "G"),
|
||||
SelectFilterOption("H", "H"),
|
||||
SelectFilterOption("I", "I"),
|
||||
SelectFilterOption("J", "J"),
|
||||
SelectFilterOption("K", "K"),
|
||||
SelectFilterOption("L", "L"),
|
||||
SelectFilterOption("M", "M"),
|
||||
SelectFilterOption("N", "N"),
|
||||
SelectFilterOption("O", "O"),
|
||||
SelectFilterOption("P", "P"),
|
||||
SelectFilterOption("Q", "Q"),
|
||||
SelectFilterOption("R", "R"),
|
||||
SelectFilterOption("S", "S"),
|
||||
SelectFilterOption("T", "T"),
|
||||
SelectFilterOption("U", "U"),
|
||||
SelectFilterOption("V", "V"),
|
||||
SelectFilterOption("W", "W"),
|
||||
SelectFilterOption("X", "X"),
|
||||
SelectFilterOption("Y", "Y"),
|
||||
SelectFilterOption("Z", "Z"),
|
||||
]),
|
||||
SortFilter("SortFilter", "Sort", SortState(0, true), [
|
||||
SelectFilterOption("Name", "name"),
|
||||
SelectFilterOption("Popularity", "views"),
|
||||
SelectFilterOption("Last update", "last_release"),
|
||||
])
|
||||
];
|
||||
}
|
||||
|
||||
String ll(String url) {
|
||||
if (url.contains("?")) {
|
||||
return "&";
|
||||
}
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
MMRCMS main() {
|
||||
@@ -1,7 +1,7 @@
|
||||
import '../../../model/source.dart';
|
||||
import '../../../utils/utils.dart';
|
||||
|
||||
const mmrcmsVersion = "0.0.35";
|
||||
const mmrcmsVersion = "0.0.4";
|
||||
const mmrcmsSourceCodeUrl =
|
||||
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/main/manga/multisrc/mmrcms/mmrcms-v$mmrcmsVersion.dart";
|
||||
const defaultDateFormat = "d MMM. yyyy";
|
||||
|
||||
Reference in New Issue
Block a user