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