This commit is contained in:
Moustapha Kodjo Amadou
2025-05-11 13:27:05 +01:00
parent 6fc11c8a31
commit efb20de6e3
2 changed files with 52 additions and 56 deletions

View File

@@ -92,66 +92,62 @@ class AniZone extends MProvider {
Future<MManga> getDetail(String url) async { Future<MManga> getDetail(String url) async {
MManga anime = MManga(); MManga anime = MManga();
try { final doc = (await client.get(Uri.parse(url))).body;
final doc = (await client.get(Uri.parse(url))).body; final description = xpath(doc, '//p[contains(@class,"short")]/text()');
final description = xpath(doc, '//p[contains(@class,"short")]/text()'); anime.description = description.isNotEmpty ? description.first : "";
anime.description = description.isNotEmpty ? description.first : "";
final statusList = xpath( final statusList = xpath(
doc, doc,
'//div[contains(@class,"col2")]//div[contains(@class,"item")]//div[contains(@class,"item-content")]/text()', '//div[contains(@class,"col2")]//div[contains(@class,"item")]//div[contains(@class,"item-content")]/text()',
); );
if (statusList.isNotEmpty) { if (statusList.isNotEmpty) {
if (statusList[0] == "Terminer") { if (statusList[0] == "Terminer") {
anime.status = MStatus.completed; anime.status = MStatus.completed;
} else if (statusList[0] == "En cours") { } else if (statusList[0] == "En cours") {
anime.status = MStatus.ongoing; anime.status = MStatus.ongoing;
} else {
anime.status = MStatus.unknown;
}
} else { } else {
anime.status = MStatus.unknown; anime.status = MStatus.unknown;
} }
} else {
anime.genre = xpath( anime.status = MStatus.unknown;
doc,
'//div[contains(@class,"item")]//div[contains(@class,"item-content")]//a[contains(@href,"genre")]/text()',
);
final regex = RegExp(r'(\d+)$');
final match = regex.firstMatch(url);
if (match == null) {
throw Exception('Numéro de l\'épisode non trouvé dans l\'URL.');
}
final res =
(await client.get(
Uri.parse("${source.baseUrl}/ajax/episode/list/${match.group(1)}"),
)).body;
List<MChapter> episodesList = [];
final episodeElements = parseHtml(
json.decode(res)["html"],
).select(".ep-item");
// Associer chaque titre à son URL et récupérer les vidéos
for (var element in episodeElements) {
MChapter episode = MChapter();
episode.name = element.attr("title");
String id = substringAfterLast(element.attr("href"), "=");
episode.url = "${source.baseUrl}/ajax/episode/servers?episodeId=$id";
episodesList.add(episode);
}
anime.chapters = episodesList.reversed.toList();
return anime;
} catch (e) {
throw Exception('Erreur lors de la récupération des détails: $e');
} }
anime.genre = xpath(
doc,
'//div[contains(@class,"item")]//div[contains(@class,"item-content")]//a[contains(@href,"genre")]/text()',
);
final regex = RegExp(r'(\d+)$');
final match = regex.firstMatch(url);
if (match == null) {
throw Exception('Numéro de l\'épisode non trouvé dans l\'URL.');
}
final res =
(await client.get(
Uri.parse("${source.baseUrl}/ajax/episode/list/${match.group(1)}"),
)).body;
List<MChapter> episodesList = [];
final episodeElements = parseHtml(
json.decode(res)["html"],
).select(".ep-item");
// Associer chaque titre à son URL et récupérer les vidéos
for (var element in episodeElements) {
MChapter episode = MChapter();
episode.name = element.attr("title");
String id = substringAfterLast(element.attr("href"), "=");
episode.url = "${source.baseUrl}/ajax/episode/servers?episodeId=$id";
episodesList.add(episode);
}
anime.chapters = episodesList.reversed.toList();
return anime;
} }
@override @override

View File

@@ -1,7 +1,7 @@
import '../../../../../model/source.dart'; import '../../../../../model/source.dart';
Source get aniZoneSource => _aniZoneSource; Source get aniZoneSource => _aniZoneSource;
const _aniZoneVersion = "0.0.3"; const _aniZoneVersion = "0.0.35";
const _aniZoneSourceCodeUrl = const _aniZoneSourceCodeUrl =
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/$branchName/dart/anime/src/fr/anizone/anizone.dart"; "https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/$branchName/dart/anime/src/fr/anizone/anizone.dart";
Source _aniZoneSource = Source( Source _aniZoneSource = Source(