Merge pull request #200 from Wraient/master

Fix: Allanime Latest Breaking Changes
This commit is contained in:
Type-Delta
2026-04-06 11:33:23 +07:00
committed by GitHub
3 changed files with 15 additions and 6 deletions

View File

@@ -40,9 +40,9 @@ def execute_graphql_query_with_get_request(
def execute_graphql(
url: str, httpx_client: Client, graphql_file: Path, variables: dict
url: str, httpx_client: Client, graphql_file: Path, variables: dict, headers: dict | None = None
) -> Response:
query = load_graphql_from_file(graphql_file)
json_body = {"query": query, "variables": variables}
response = httpx_client.post(url, json=json_body, timeout=TIMEOUT)
response = httpx_client.post(url, json=json_body, headers=headers, timeout=TIMEOUT)
return response

View File

@@ -14,6 +14,11 @@ SERVERS_AVAILABLE = [
API_BASE_URL = "allanime.day"
API_GRAPHQL_REFERER = "https://allanime.to/"
API_GRAPHQL_ENDPOINT = f"https://api.{API_BASE_URL}/api/"
API_GRAPHQL_HEADERS= {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"Content-Type": "application/json",
"Origin": f"{API_GRAPHQL_REFERER}",
}
# search constants
DEFAULT_COUNTRY_OF_ORIGIN = "all"

View File

@@ -1,12 +1,13 @@
import logging
from typing import TYPE_CHECKING
from .....core.utils.graphql import execute_graphql_query_with_get_request
from .....core.utils.graphql import execute_graphql
from ..base import BaseAnimeProvider
from ..utils.debug import debug_provider
from .constants import (
ANIME_GQL,
API_GRAPHQL_ENDPOINT,
API_GRAPHQL_HEADERS,
API_GRAPHQL_REFERER,
EPISODE_GQL,
SEARCH_GQL,
@@ -26,7 +27,7 @@ class AllAnime(BaseAnimeProvider):
@debug_provider
def search(self, params):
response = execute_graphql_query_with_get_request(
response = execute_graphql(
API_GRAPHQL_ENDPOINT,
self.client,
SEARCH_GQL,
@@ -41,16 +42,18 @@ class AllAnime(BaseAnimeProvider):
"translationtype": params.translation_type,
"countryorigin": params.country_of_origin,
},
headers=API_GRAPHQL_HEADERS
)
return map_to_search_results(response)
@debug_provider
def get(self, params):
response = execute_graphql_query_with_get_request(
response = execute_graphql(
API_GRAPHQL_ENDPOINT,
self.client,
ANIME_GQL,
variables={"showId": params.id},
headers=API_GRAPHQL_HEADERS
)
return map_to_anime_result(response)
@@ -58,7 +61,7 @@ class AllAnime(BaseAnimeProvider):
def episode_streams(self, params):
from .extractors import extract_server
episode_response = execute_graphql_query_with_get_request(
episode_response = execute_graphql(
API_GRAPHQL_ENDPOINT,
self.client,
EPISODE_GQL,
@@ -67,6 +70,7 @@ class AllAnime(BaseAnimeProvider):
"translationType": params.translation_type,
"episodeString": params.episode,
},
headers=API_GRAPHQL_HEADERS
)
episode: AllAnimeEpisode = episode_response.json()["data"]["episode"]
for source in episode["sourceUrls"]: