mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 02:41:39 +00:00
AnimePahe: add cookie to headers
This commit is contained in:
@@ -12,6 +12,9 @@ class AnimePahe extends MProvider {
|
|||||||
@override
|
@override
|
||||||
String get baseUrl => getPreferenceValue(source.id, "preferred_domain");
|
String get baseUrl => getPreferenceValue(source.id, "preferred_domain");
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, String> get headers => {'cookie': '__ddg1_=;__ddg2_=;'};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<MPages> getPopular(int page) async {
|
Future<MPages> getPopular(int page) async {
|
||||||
return await getLatestUpdates(page);
|
return await getLatestUpdates(page);
|
||||||
@@ -19,8 +22,9 @@ 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(Uri.parse("$baseUrl/api?m=airing&page=$page"),
|
||||||
(await client.get(Uri.parse("$baseUrl/api?m=airing&page=$page"))).body;
|
headers: headers))
|
||||||
|
.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 = [];
|
||||||
@@ -37,9 +41,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"),
|
||||||
.body;
|
headers: headers))
|
||||||
|
.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"]) {
|
||||||
@@ -61,9 +66,10 @@ class AnimePahe extends MProvider {
|
|||||||
final id = substringBefore(substringAfterLast(url, "?anime_id="), "&name=");
|
final id = substringBefore(substringAfterLast(url, "?anime_id="), "&name=");
|
||||||
final name = substringAfterLast(url, "&name=");
|
final name = substringAfterLast(url, "&name=");
|
||||||
final session = await getSession(name, id);
|
final session = await getSession(name, id);
|
||||||
final res =
|
final res = (await client.get(
|
||||||
(await client.get(Uri.parse("$baseUrl/anime/$session?anime_id=$id")))
|
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()') ??
|
||||||
@@ -91,7 +97,7 @@ class AnimePahe extends MProvider {
|
|||||||
anime.description += "\n\n$synonyms";
|
anime.description += "\n\n$synonyms";
|
||||||
}
|
}
|
||||||
final epUrl = "$baseUrl/api?m=release&id=$session&sort=episode_desc&page=1";
|
final epUrl = "$baseUrl/api?m=release&id=$session&sort=episode_desc&page=1";
|
||||||
final resEp = (await client.get(Uri.parse(epUrl))).body;
|
final resEp = (await client.get(Uri.parse(epUrl), headers: headers)).body;
|
||||||
final episodes = await recursivePages(epUrl, resEp, session);
|
final episodes = await recursivePages(epUrl, resEp, session);
|
||||||
|
|
||||||
anime.chapters = episodes;
|
anime.chapters = episodes;
|
||||||
@@ -114,15 +120,17 @@ class AnimePahe extends MProvider {
|
|||||||
}
|
}
|
||||||
if (hasNextPage) {
|
if (hasNextPage) {
|
||||||
final newUrl = "${substringBeforeLast(url, "&page=")}&page=${page + 1}";
|
final newUrl = "${substringBeforeLast(url, "&page=")}&page=${page + 1}";
|
||||||
final newRes = (await client.get(Uri.parse(newUrl))).body;
|
final newRes =
|
||||||
|
(await client.get(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 title, String animeId) async {
|
||||||
final res =
|
final res = (await client.get(Uri.parse("$baseUrl/api?m=search&q=$title"),
|
||||||
(await client.get(Uri.parse("$baseUrl/api?m=search&q=$title"))).body;
|
headers: headers))
|
||||||
|
.body;
|
||||||
return substringBefore(
|
return substringBefore(
|
||||||
substringAfter(
|
substringAfter(
|
||||||
substringAfter(res, "\"id\":$animeId"), "\"session\":\""),
|
substringAfter(res, "\"id\":$animeId"), "\"session\":\""),
|
||||||
@@ -134,7 +142,7 @@ class AnimePahe extends MProvider {
|
|||||||
//by default we use rhttp package but it does not support `followRedirects`
|
//by default we use rhttp package but it does not support `followRedirects`
|
||||||
//so setting `useDartHttpClient` to true allows us to use a Dart http package that supports `followRedirects`
|
//so setting `useDartHttpClient` to true allows us to use a Dart http package that supports `followRedirects`
|
||||||
final client = Client(source, json.encode({"useDartHttpClient": true}));
|
final client = Client(source, json.encode({"useDartHttpClient": true}));
|
||||||
final res = (await client.get(Uri.parse("$baseUrl$url")));
|
final res = (await client.get(Uri.parse("$baseUrl$url"), headers: headers));
|
||||||
final document = parseHtml(res.body);
|
final document = parseHtml(res.body);
|
||||||
final downloadLinks = document.select("div#pickDownload > a");
|
final downloadLinks = document.select("div#pickDownload > a");
|
||||||
final buttons = document.select("div#resolutionMenu > button");
|
final buttons = document.select("div#resolutionMenu > button");
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import '../../../../../model/source.dart';
|
import '../../../../../model/source.dart';
|
||||||
|
|
||||||
Source get animepaheSource => _animepaheSource;
|
Source get animepaheSource => _animepaheSource;
|
||||||
const _animepaheVersion = "0.0.4";
|
const _animepaheVersion = "0.0.45";
|
||||||
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(
|
||||||
|
|||||||
Reference in New Issue
Block a user