Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[animepahe site error] httpx client failed to get an api responses from animepahe #291

Open
Type-Delta opened this issue Nov 7, 2023 · 0 comments

Comments

@Type-Delta
Copy link

Hello,
I tried to stream some animes with animepahe as provider and got the following error.

C:\Python39\lib\json\decoder.py:355 in raw_decode                                      
│                                                                                        
│   352 │      try:                                                                     
│   353 │          obj, end = self.scan_once(s, idx)                                    
│   354 │      except StopIteration as err:                                             
│ ❱ 355 │          raise JSONDecodeError("Expecting value", s, err.value) from None     
│   356 │      return obj, end                                                          
│   357
JSONDecodeError: Expecting value: line 1 column 1 (char 0)

so I did some digging and found out that:

in searcher.py line 64 for some reasons session.get() returns html respond instead of expected JSON respond.

def search_animepahe(session, query):
    animepahe_results = session.get( # <- here
        ANIMEPAHE + "api",
        params={"q": query, "m": "search"},
    )
    content = animepahe_results.json()

    for results in content.get("data", []):
        yield {
            "anime_url": ANIMEPAHE + "anime/" + results.get("session"),
            "name": results.get("title"),
        }

and since the respond is in html format, animepahe_results.json() would throw an error because it can't parse html to
Python object (dictionary).

what I did to fix this issue is attach header indicates the response type

animepahe_results = session.get( 
     ANIMEPAHE + "api",
     params={"q": query, "m": "search"},
     headers={'accept': 'application/json'} # <- here
)

this fix the problem for me.

I don't know if others has the same problem or not but here is how to fix it.
if you're someone who is working on this project please apply this fix to the codebase.

hoped this is useful >.<

PS: It's probably not the best way to fix this problem, if someone got a better idea you can point it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant