New source: Nyaa (ALL)

This commit is contained in:
kodjomoustapha
2024-01-29 10:25:49 +01:00
parent fce32ee83c
commit 68399a43e5
4 changed files with 149 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ import 'multisrc/datalifeengine/sources.dart';
import 'multisrc/dopeflix/sources.dart';
import 'multisrc/zorotheme/sources.dart';
import 'src/all/animeworldindia/sources.dart';
import 'src/all/nyaa/source.dart';
import 'src/ar/okanime/source.dart';
import 'src/de/aniflix/source.dart';
import 'src/en/aniwave/source.dart';
@@ -48,7 +49,8 @@ void main() {
animesamaSource,
nineanimetv,
aniflix,
...animeworldindiaSourcesList
...animeworldindiaSourcesList,
nyaaSource
];
final List<Map<String, dynamic>> jsonList =
_sourcesList.map((source) => source.toJson()).toList();

BIN
anime/src/all/nyaa/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -0,0 +1,126 @@
import 'package:mangayomi/bridge_lib.dart';
class Nyaa extends MProvider {
Nyaa();
final Client client = Client();
@override
Future<MPages> getPopular(MSource source, int page) async {
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")))
.body;
return parseAnimeList(res, source.baseUrl);
}
@override
Future<MPages> getLatestUpdates(MSource source, int page) async {
final res = (await client.get(Uri.parse(
"${source.baseUrl}/?f=0&c=${getPreferenceValue(source.id, "preferred_categorie_page")}&q=$page")))
.body;
return parseAnimeList(res, source.baseUrl);
}
@override
Future<MPages> search(
MSource source, String query, int page, FilterList filterList) async {
final filters = filterList.filters;
String url = "";
url =
"${source.baseUrl}/?f=0&c=${getPreferenceValue(source.id, "preferred_categorie_page")}&q=${query.replaceAll(" ", "+")}&p=$page";
for (var filter in filters) {
if (filter.type == "SortFilter") {
url += "${ll(url)}s=${filter.values[filter.state.index].value}";
final asc = filter.state.ascending ? "&o=asc" : "&o=desc";
url += "${ll(url)}$asc";
}
}
final res = (await client.get(Uri.parse(url))).body;
return parseAnimeList(res, source.baseUrl);
}
@override
Future<MManga> getDetail(MSource source, String url) async {
MManga anime = MManga();
final res = (await client.get(Uri.parse(url))).body;
final document = parseHtml(res);
String description =
(document.xpathFirst('//div[@class="panel-body"]/text()') ?? "")
.replaceAll("\n", "");
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];
return anime;
}
@override
List<dynamic> getFilterList(MSource source) {
return [
SortFilter("SortFilter", "Sort by", SortState(0, true), [
SelectFilterOption("None", ""),
SelectFilterOption("Size", "size"),
SelectFilterOption("Date", "id"),
SelectFilterOption("Seeders", "seeders"),
SelectFilterOption("Leechers", "leechers"),
SelectFilterOption("Download", "downloads")
])
];
}
@override
List<dynamic> getSourcePreferences(MSource source) {
return [
ListPreference(
key: "preferred_categorie_page",
title: "Preferred categorie page",
summary: "",
valueIndex: 0,
entries: ["Anime", "Live Action"],
entryValues: ["1_0", "4_0"]),
];
}
MPages parseAnimeList(String res, String baseUrl) {
List<MManga> animeList = [];
final document = parseHtml(res);
final values = document
.select("body > div > div.table-responsive > table > tbody > tr");
for (var value in values) {
MManga anime = MManga();
anime.imageUrl =
"$baseUrl${getUrlWithoutDomain(value.selectFirst("td:nth-child(1) > a > img").getSrc)}";
MElement firstElement = value
.select("td > a")
.where((MElement e) =>
e.outerHtml.contains("/view/") &&
!e.outerHtml.contains("#comments"))
.toList()
.first;
anime.link = "$baseUrl${getUrlWithoutDomain(firstElement.getHref)}";
anime.name = firstElement.attr("title");
animeList.add(anime);
}
final hasNextPage =
xpath(res, '//ul[@class="pagination"]/li[contains(text(),"»")]/a/@href')
.isNotEmpty;
return MPages(animeList, hasNextPage);
}
String ll(String url) {
if (url.contains("?")) {
return "&";
}
return "?";
}
}
Nyaa main() {
return Nyaa();
}

View File

@@ -0,0 +1,20 @@
import '../../../../model/source.dart';
const _nyaaVersion = "0.0.1";
const _nyaaSourceCodeUrl =
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/$branchName/anime/src/all/nyaa/nyaa.dart";
String _iconUrl =
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/$branchName/anime/src/all/nyaa/icon.png";
Source get nyaaSource => _nyaaSource;
Source _nyaaSource = Source(
name: 'Nyaa',
baseUrl: "https://nyaa.si",
lang: "all",
typeSource: "torrent",
iconUrl: _iconUrl,
version: _nyaaVersion,
isManga: false,
appMinVerReq: "0.1.65",
sourceCodeUrl: _nyaaSourceCodeUrl);