Skip to content
This repository was archived by the owner on May 2, 2026. It is now read-only.

Commit da0e7ae

Browse files
authored
Merge pull request #200 from Wraient/master
Fix: Allanime Latest Breaking Changes
2 parents bb7a3d4 + a0a8052 commit da0e7ae

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

viu_media/core/utils/graphql.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ def execute_graphql_query_with_get_request(
4040

4141

4242
def execute_graphql(
43-
url: str, httpx_client: Client, graphql_file: Path, variables: dict
43+
url: str, httpx_client: Client, graphql_file: Path, variables: dict, headers: dict | None = None
4444
) -> Response:
4545
query = load_graphql_from_file(graphql_file)
4646
json_body = {"query": query, "variables": variables}
47-
response = httpx_client.post(url, json=json_body, timeout=TIMEOUT)
47+
response = httpx_client.post(url, json=json_body, headers=headers, timeout=TIMEOUT)
4848
return response

viu_media/libs/provider/anime/allanime/constants.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
API_BASE_URL = "allanime.day"
1515
API_GRAPHQL_REFERER = "https://allanime.to/"
1616
API_GRAPHQL_ENDPOINT = f"https://api.{API_BASE_URL}/api/"
17+
API_GRAPHQL_HEADERS= {
18+
"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",
19+
"Content-Type": "application/json",
20+
"Origin": f"{API_GRAPHQL_REFERER}",
21+
}
1722

1823
# search constants
1924
DEFAULT_COUNTRY_OF_ORIGIN = "all"

viu_media/libs/provider/anime/allanime/provider.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import logging
22
from typing import TYPE_CHECKING
33

4-
from .....core.utils.graphql import execute_graphql_query_with_get_request
4+
from .....core.utils.graphql import execute_graphql
55
from ..base import BaseAnimeProvider
66
from ..utils.debug import debug_provider
77
from .constants import (
88
ANIME_GQL,
99
API_GRAPHQL_ENDPOINT,
10+
API_GRAPHQL_HEADERS,
1011
API_GRAPHQL_REFERER,
1112
EPISODE_GQL,
1213
SEARCH_GQL,
@@ -26,7 +27,7 @@ class AllAnime(BaseAnimeProvider):
2627

2728
@debug_provider
2829
def search(self, params):
29-
response = execute_graphql_query_with_get_request(
30+
response = execute_graphql(
3031
API_GRAPHQL_ENDPOINT,
3132
self.client,
3233
SEARCH_GQL,
@@ -41,24 +42,26 @@ def search(self, params):
4142
"translationtype": params.translation_type,
4243
"countryorigin": params.country_of_origin,
4344
},
45+
headers=API_GRAPHQL_HEADERS
4446
)
4547
return map_to_search_results(response)
4648

4749
@debug_provider
4850
def get(self, params):
49-
response = execute_graphql_query_with_get_request(
51+
response = execute_graphql(
5052
API_GRAPHQL_ENDPOINT,
5153
self.client,
5254
ANIME_GQL,
5355
variables={"showId": params.id},
56+
headers=API_GRAPHQL_HEADERS
5457
)
5558
return map_to_anime_result(response)
5659

5760
@debug_provider
5861
def episode_streams(self, params):
5962
from .extractors import extract_server
6063

61-
episode_response = execute_graphql_query_with_get_request(
64+
episode_response = execute_graphql(
6265
API_GRAPHQL_ENDPOINT,
6366
self.client,
6467
EPISODE_GQL,
@@ -67,6 +70,7 @@ def episode_streams(self, params):
6770
"translationType": params.translation_type,
6871
"episodeString": params.episode,
6972
},
73+
headers=API_GRAPHQL_HEADERS
7074
)
7175
episode: AllAnimeEpisode = episode_response.json()["data"]["episode"]
7276
for source in episode["sourceUrls"]:

0 commit comments

Comments
 (0)