mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 10:51:17 +00:00
Merge pull request #37 from resolritter/36
Fix indexing error for madara sources
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -77,6 +77,38 @@ class Madara extends MProvider {
|
|||||||
return mangaFromElements(document.select("div.c-tabs-item__content"));
|
return mangaFromElements(document.select("div.c-tabs-item__content"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<MChapter> getChapters(MDocument chapDoc) {
|
||||||
|
List<MChapter> chapters = [];
|
||||||
|
for (MElement element in chapDoc.select("li.wp-manga-chapter") ?? []) {
|
||||||
|
var ch = element.selectFirst("a");
|
||||||
|
if (ch != null) {
|
||||||
|
var url = ch.attr("href");
|
||||||
|
if (url != null && url.isNotEmpty) {
|
||||||
|
url = substringBefore(url, "?style=paged");
|
||||||
|
if (url.endsWith("?style=paged")) {
|
||||||
|
url = url + "?style=paged";
|
||||||
|
}
|
||||||
|
var chapter = MChapter();
|
||||||
|
chapter.url = url;
|
||||||
|
chapter.name = ch.text;
|
||||||
|
if (source.dateFormat.isNotEmpty) {
|
||||||
|
var chd = element.selectFirst("span.chapter-release-date");
|
||||||
|
if (chd != null && chd.text.isNotEmpty) {
|
||||||
|
var dates = parseDates(
|
||||||
|
[chd.text], source.dateFormat, source.dateFormatLocale);
|
||||||
|
chapter.dateUpload = dates[0];
|
||||||
|
} else {
|
||||||
|
chapter.dateUpload =
|
||||||
|
DateTime.now().millisecondsSinceEpoch.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chapters.add(chapter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return chapters;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<MManga> getDetail(String url) async {
|
Future<MManga> getDetail(String url) async {
|
||||||
final statusList = [
|
final statusList = [
|
||||||
@@ -180,71 +212,17 @@ class Madara extends MProvider {
|
|||||||
} else {
|
} else {
|
||||||
res = oldXhrChaptersRequest.body;
|
res = oldXhrChaptersRequest.body;
|
||||||
}
|
}
|
||||||
|
|
||||||
MDocument chapDoc = parseHtml(res);
|
MDocument chapDoc = parseHtml(res);
|
||||||
List<String> chapUrls = [];
|
manga.chapters = getChapters(chapDoc);
|
||||||
List<String> chaptersNames = [];
|
if (manga.chapters.isEmpty) {
|
||||||
List<String> chapDates = [];
|
|
||||||
for (MElement element in chapDoc.select("li.wp-manga-chapter") ?? []) {
|
|
||||||
final ch = element.selectFirst("a");
|
|
||||||
if (ch != null) {
|
|
||||||
chapUrls.add(ch.attr("href"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (chapUrls.isEmpty) {
|
|
||||||
res = (await client.post(Uri.parse("${url}ajax/chapters"),
|
res = (await client.post(Uri.parse("${url}ajax/chapters"),
|
||||||
headers: headers))
|
headers: headers))
|
||||||
.body;
|
.body;
|
||||||
chapDoc = parseHtml(res);
|
chapDoc = parseHtml(res);
|
||||||
for (MElement element in chapDoc.select("li.wp-manga-chapter") ?? []) {
|
manga.chapters = getChapters(chapDoc);
|
||||||
final ch = element.selectFirst("a");
|
|
||||||
if (ch != null) {
|
|
||||||
chapUrls.add(ch.attr("href"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (MElement element in chapDoc.select("li.wp-manga-chapter") ?? []) {
|
|
||||||
final ch = element.selectFirst("a");
|
|
||||||
final chd = element.selectFirst("span.chapter-release-date");
|
|
||||||
if (ch != null) {
|
|
||||||
chaptersNames.add(ch.text);
|
|
||||||
}
|
|
||||||
if (chd != null) {
|
|
||||||
chapDates.add(chd.text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<String> dateUploads = [];
|
|
||||||
if (source.dateFormat.isNotEmpty) {
|
|
||||||
List<String> chaptersDate = [];
|
|
||||||
dateUploads =
|
|
||||||
parseDates(chapDates, source.dateFormat, source.dateFormatLocale);
|
|
||||||
if (chapDates.length < chaptersNames.length) {
|
|
||||||
final length = chaptersNames.length - chapDates.length;
|
|
||||||
for (var i = 0; i < length; i++) {
|
|
||||||
chaptersDate.add("${DateTime.now().millisecondsSinceEpoch}");
|
|
||||||
}
|
|
||||||
final parsedDates =
|
|
||||||
parseDates(chapDates, source.dateFormat, source.dateFormatLocale);
|
|
||||||
for (var date in parsedDates) {
|
|
||||||
chaptersDate.add(date);
|
|
||||||
}
|
|
||||||
dateUploads = chaptersDate;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MChapter>? chaptersList = [];
|
|
||||||
for (var i = 0; i < chaptersNames.length; i++) {
|
|
||||||
String url = substringBefore(chapUrls[i], "?style=paged");
|
|
||||||
if (!chapUrls[i].endsWith("?style=paged")) {
|
|
||||||
url = url + "?style=paged";
|
|
||||||
}
|
|
||||||
MChapter chapter = MChapter();
|
|
||||||
chapter.name = chaptersNames[i];
|
|
||||||
chapter.url = chapUrls[i];
|
|
||||||
if (source.dateFormat.isNotEmpty) chapter.dateUpload = dateUploads[i];
|
|
||||||
chaptersList.add(chapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
manga.chapters = chaptersList;
|
|
||||||
return manga;
|
return manga;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ import 'src/comicarab/comicarab.dart';
|
|||||||
import 'src/manga3asq/manga3asq.dart';
|
import 'src/manga3asq/manga3asq.dart';
|
||||||
import 'src/bakamh/bakamh.dart';
|
import 'src/bakamh/bakamh.dart';
|
||||||
|
|
||||||
const madaraVersion = "0.0.85";
|
const madaraVersion = "0.0.86";
|
||||||
const madaraSourceCodeUrl =
|
const madaraSourceCodeUrl =
|
||||||
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/$branchName/manga/multisrc/madara/madara.dart";
|
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/$branchName/manga/multisrc/madara/madara.dart";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user