From efb20de6e3d236f8906efd56ecb8518af97b0444 Mon Sep 17 00:00:00 2001 From: Moustapha Kodjo Amadou <107993382+kodjodevf@users.noreply.github.com> Date: Sun, 11 May 2025 13:27:05 +0100 Subject: [PATCH] - --- dart/anime/src/fr/anizone/anizone.dart | 106 ++++++++++++------------- dart/anime/src/fr/anizone/source.dart | 2 +- 2 files changed, 52 insertions(+), 56 deletions(-) diff --git a/dart/anime/src/fr/anizone/anizone.dart b/dart/anime/src/fr/anizone/anizone.dart index e76112cb..cfa24942 100644 --- a/dart/anime/src/fr/anizone/anizone.dart +++ b/dart/anime/src/fr/anizone/anizone.dart @@ -92,66 +92,62 @@ class AniZone extends MProvider { Future getDetail(String url) async { MManga anime = MManga(); - try { - final doc = (await client.get(Uri.parse(url))).body; - final description = xpath(doc, '//p[contains(@class,"short")]/text()'); - anime.description = description.isNotEmpty ? description.first : ""; + final doc = (await client.get(Uri.parse(url))).body; + final description = xpath(doc, '//p[contains(@class,"short")]/text()'); + anime.description = description.isNotEmpty ? description.first : ""; - final statusList = xpath( - doc, - '//div[contains(@class,"col2")]//div[contains(@class,"item")]//div[contains(@class,"item-content")]/text()', - ); - if (statusList.isNotEmpty) { - if (statusList[0] == "Terminer") { - anime.status = MStatus.completed; - } else if (statusList[0] == "En cours") { - anime.status = MStatus.ongoing; - } else { - anime.status = MStatus.unknown; - } + final statusList = xpath( + doc, + '//div[contains(@class,"col2")]//div[contains(@class,"item")]//div[contains(@class,"item-content")]/text()', + ); + if (statusList.isNotEmpty) { + if (statusList[0] == "Terminer") { + anime.status = MStatus.completed; + } else if (statusList[0] == "En cours") { + anime.status = MStatus.ongoing; } else { anime.status = MStatus.unknown; } - - 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 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'); + } else { + anime.status = MStatus.unknown; } + + 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 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 diff --git a/dart/anime/src/fr/anizone/source.dart b/dart/anime/src/fr/anizone/source.dart index 941d05ca..59c2936d 100644 --- a/dart/anime/src/fr/anizone/source.dart +++ b/dart/anime/src/fr/anizone/source.dart @@ -1,7 +1,7 @@ import '../../../../../model/source.dart'; Source get aniZoneSource => _aniZoneSource; -const _aniZoneVersion = "0.0.3"; +const _aniZoneVersion = "0.0.35"; const _aniZoneSourceCodeUrl = "https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/$branchName/dart/anime/src/fr/anizone/anizone.dart"; Source _aniZoneSource = Source(