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,8 +22,7 @@ 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;
@@ -43,8 +42,7 @@ 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;
@@ -67,10 +65,8 @@ 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 =
(await client.get(
Uri.parse("$baseUrl/anime/$session?anime_id=$id"), Uri.parse("$baseUrl/anime/$session?anime_id=$id"),
headers: headers, headers: headers,
)).body; )).body;
@@ -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,9 +209,13 @@ 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 =
await Client(
source, source,
json.encode({"followRedirects": false, "useDartHttpClient": true}), json.encode({
"followRedirects": false,
"useDartHttpClient": true,
}),
).post( ).post(
Uri.parse(url), Uri.parse(url),
headers: { headers: {

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(