fix(nyaa): ensure chapters is List<MChapter> to avoid type cast error

This commit is contained in:
xMohnad
2025-06-25 18:56:50 +00:00
parent af9a36a94e
commit 1b6e122a8c

View File

@@ -9,8 +9,7 @@ class Nyaa extends MProvider {
@override
Future<MPages> getPopular(int page) async {
final res =
(await client.get(
final res = (await client.get(
Uri.parse(
"${source.baseUrl}/?f=0&c=${getPreferenceValue(source.id, "preferred_categorie_page")}&q=&s=downloads&o=desc&p=$page",
),
@@ -20,8 +19,7 @@ class Nyaa extends MProvider {
@override
Future<MPages> getLatestUpdates(int page) async {
final res =
(await client.get(
final res = (await client.get(
Uri.parse(
"${source.baseUrl}/?f=0&c=${getPreferenceValue(source.id, "preferred_categorie_page")}&q=$page",
),
@@ -57,11 +55,17 @@ class Nyaa extends MProvider {
description +=
"\n\n${(document.xpathFirst('//div[@class="panel panel-default"]/text()') ?? "").trim().replaceAll("\n", "")}";
anime.description = description;
MChapter ep = MChapter();
ep.name = "Torrent";
ep.url =
"${source.baseUrl}/download/${substringAfterLast(url, '/')}.torrent";
anime.chapters = [ep];
List<MChapter> chapters = [];
chapters.add(
MChapter(
name: "Torrent",
url:
"${source.baseUrl}/download/${substringAfterLast(url, '/')}.torrent",
),
);
anime.chapters = chapters;
return anime;
}
@@ -114,8 +118,7 @@ class Nyaa extends MProvider {
MManga anime = MManga();
anime.imageUrl =
"${source.baseUrl}${getUrlWithoutDomain(value.selectFirst("td:nth-child(1) > a > img").getSrc)}";
MElement firstElement =
value
MElement firstElement = value
.select("td > a")
.where(
(MElement e) =>
@@ -130,8 +133,7 @@ class Nyaa extends MProvider {
animeList.add(anime);
}
final hasNextPage =
xpath(
final hasNextPage = xpath(
res,
'//ul[@class="pagination"]/li[contains(text(),"»")]/a/@href',
).isNotEmpty;