This commit is contained in:
Moustapha Kodjo Amadou
2025-05-22 15:30:19 +01:00
parent fa3c0d1dba
commit 5946b2a698
2 changed files with 58 additions and 48 deletions

View File

@@ -22,11 +22,10 @@ class AnimePahe 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("$baseUrl/api?m=airing&page=$page"),
Uri.parse("$baseUrl/api?m=airing&page=$page"), headers: headers,
headers: headers, )).body;
)).body;
final jsonResult = json.decode(res); final jsonResult = json.decode(res);
final hasNextPage = jsonResult["current_page"] < jsonResult["last_page"]; final hasNextPage = jsonResult["current_page"] < jsonResult["last_page"];
List<MManga> animeList = []; List<MManga> animeList = [];
@@ -43,11 +42,10 @@ class AnimePahe extends MProvider {
@override @override
Future<MPages> search(String query, int page, FilterList filterList) async { Future<MPages> search(String query, int page, FilterList filterList) async {
final res = final res = (await client.get(
(await client.get( Uri.parse("$baseUrl/api?m=search&l=8&q=$query"),
Uri.parse("$baseUrl/api?m=search&l=8&q=$query"), headers: headers,
headers: headers, )).body;
)).body;
final jsonResult = json.decode(res); final jsonResult = json.decode(res);
List<MManga> animeList = []; List<MManga> animeList = [];
for (var item in jsonResult["data"]) { for (var item in jsonResult["data"]) {
@@ -67,13 +65,11 @@ class AnimePahe extends MProvider {
]; ];
MManga anime = MManga(); MManga anime = MManga();
final id = substringBefore(substringAfterLast(url, "?anime_id="), "&name="); final id = substringBefore(substringAfterLast(url, "?anime_id="), "&name=");
final name = substringAfterLast(url, "&name="); final session = await getSession(id);
final session = await getSession(name, id); final res = (await client.get(
final res = Uri.parse("$baseUrl/anime/$session?anime_id=$id"),
(await client.get( headers: headers,
Uri.parse("$baseUrl/anime/$session?anime_id=$id"), )).body;
headers: headers,
)).body;
final document = parseHtml(res); final document = parseHtml(res);
final status = final status =
(document.xpathFirst('//div/p[contains(text(),"Status:")]/text()') ?? (document.xpathFirst('//div/p[contains(text(),"Status:")]/text()') ??
@@ -123,29 +119,38 @@ class AnimePahe extends MProvider {
MChapter episode = MChapter(); MChapter episode = MChapter();
episode.name = "Episode ${item["episode"]}"; episode.name = "Episode ${item["episode"]}";
episode.url = "/play/$session/${item["session"]}"; episode.url = "/play/$session/${item["session"]}";
episode.dateUpload = episode.dateUpload = parseDates(
parseDates([item["created_at"]], "yyyy-MM-dd HH:mm:ss", "en")[0]; [item["created_at"]],
"yyyy-MM-dd HH:mm:ss",
"en",
)[0];
animeList.add(episode); animeList.add(episode);
} }
if (hasNextPage) { if (hasNextPage) {
final newUrl = "${substringBeforeLast(url, "&page=")}&page=${page + 1}"; final newUrl = "${substringBeforeLast(url, "&page=")}&page=${page + 1}";
final newRes = final newRes = (await client.get(
(await client.get(Uri.parse(newUrl), headers: headers)).body; Uri.parse(newUrl),
headers: headers,
)).body;
animeList.addAll(await recursivePages(newUrl, newRes, session)); animeList.addAll(await recursivePages(newUrl, newRes, session));
} }
return animeList; return animeList;
} }
Future<String> getSession(String title, String animeId) async { Future<String> getSession(String animeId) async {
final res = final noRedirect = Client(
(await client.get( source,
Uri.parse("$baseUrl/api?m=search&q=$title"), json.encode({"followRedirects": false, "useDartHttpClient": true}),
headers: headers,
)).body;
return substringBefore(
substringAfter(substringAfter(res, "\"id\":$animeId"), "\"session\":\""),
"\"",
); );
final res = await noRedirect.get(
Uri.parse("$baseUrl/a/$animeId"),
headers: headers,
);
final location =
"https://${substringAfterLast(res.headers["location"], "https://")}";
final uri = Uri.parse(location);
return uri.pathSegments.last;
} }
@override @override
@@ -173,8 +178,9 @@ class AnimePahe extends MProvider {
source, source,
json.encode({"followRedirects": false, "useDartHttpClient": true}), json.encode({"followRedirects": false, "useDartHttpClient": true}),
); );
final kwikHeaders = final kwikHeaders = (await noRedirectClient.get(
(await noRedirectClient.get(Uri.parse("${paheWinLink}/i"))).headers; Uri.parse("${paheWinLink}/i"),
)).headers;
final kwikUrl = final kwikUrl =
"https://${substringAfterLast(getMapValue(json.encode(kwikHeaders), "location"), "https://")}"; "https://${substringAfterLast(getMapValue(json.encode(kwikHeaders), "location"), "https://")}";
final reskwik = (await client.get( final reskwik = (await client.get(
@@ -203,21 +209,25 @@ class AnimePahe extends MProvider {
); );
cookie += cookie +=
"; ${getMapValue(json.encode(reskwik.headers), "set-cookie").replaceAll("path=/;", "")}"; "; ${getMapValue(json.encode(reskwik.headers), "set-cookie").replaceAll("path=/;", "")}";
final resNo = await Client( final resNo =
source, await Client(
json.encode({"followRedirects": false, "useDartHttpClient": true}), source,
).post( json.encode({
Uri.parse(url), "followRedirects": false,
headers: { "useDartHttpClient": true,
"referer": reskwik.request.url.toString(), }),
"cookie": cookie, ).post(
"user-agent": getMapValue( Uri.parse(url),
json.encode(res.request.headers), headers: {
"user-agent", "referer": reskwik.request.url.toString(),
), "cookie": cookie,
}, "user-agent": getMapValue(
body: {"_token": tok}, json.encode(res.request.headers),
); "user-agent",
),
},
body: {"_token": tok},
);
code = resNo.statusCode; code = resNo.statusCode;
tries++; tries++;
location = getMapValue(json.encode(resNo.headers), "location"); location = getMapValue(json.encode(resNo.headers), "location");

View File

@@ -1,7 +1,7 @@
import '../../../../../model/source.dart'; import '../../../../../model/source.dart';
Source get animepaheSource => _animepaheSource; Source get animepaheSource => _animepaheSource;
const _animepaheVersion = "0.0.55"; const _animepaheVersion = "0.0.6";
const _animepaheSourceCodeUrl = const _animepaheSourceCodeUrl =
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/$branchName/dart/anime/src/en/animepahe/animepahe.dart"; "https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/$branchName/dart/anime/src/en/animepahe/animepahe.dart";
Source _animepaheSource = Source( Source _animepaheSource = Source(