abhinavk99 / jikanpy

Python wrapper for the Jikan API
MIT License
217 stars 29 forks source link

selected_base not working #76

Closed thesammy2010 closed 4 years ago

thesammy2010 commented 4 years ago

Locally hosting via this

import jikanpy
api = jikanpy.Jikan(selected_base="http://localhost:9000/public/v3")
api.user(username="TheSammy2010")
403 403 on https://myanimelist.net/animelist/thesammy2010/load.json?offset=0&status=7: error for username=thesammy2010, request=animelist

throws exception because it's hitting api.jikan.moe instead of localhost. Also confirmed from the docker-compose logs that no requests are made to it. Running

import requests
r = requests.get("http://localhost:9000/public/v3/user/TheSammy2010/animelist")

works fine and returns results

purarue commented 4 years ago

Seems to work fine for me.

>>> import jikanpy
>>> api = jikanpy.Jikan(selected_base="http://localhost:8000/v3")
>>> api.user(username="TheSammy2010").keys()
dict_keys(['user_id', 'username', 'url', 'image_url', 'last_online', 'gender', 'birthday', 'location', 'joined', 'anime_stats', 'manga_stats', 'favorites', 'about', 'jikan_url', 'headers'])

I expect this you're not on the latest version of jikanpy, since this was a bug in 4.0

Make sure youre on v4.1

pip3 install -U jikanpy

thesammy2010 commented 4 years ago

Sorry my bad. I was on 4.0

It works but now I get

import jikanpy
api.user("thesammy2010")
APIException: 500 Return value of Jikan\Parser\User\Profile\AnimeStatsParser::getMeanScore() must be of the type float or null, string returned: error for username=thesammy2010, request=None

but this is an issue with Jikan which I raised here Still a little confused why we didn't get the same error though. Guess you're running a different version of Jikan

abhinavk99 commented 4 years ago

Jikanpy just makes HTTP requests to the Jikan REST API, so it depends on the version locally or the version on the servers, depending on whether you're locally hosting or not respectively.