[inkbunny] retry API calls with a loop instead of recursion
This commit is contained in:
@@ -330,15 +330,18 @@ class InkbunnyAPI():
|
|||||||
def _call(self, endpoint, params):
|
def _call(self, endpoint, params):
|
||||||
url = "https://inkbunny.net/api_" + endpoint + ".php"
|
url = "https://inkbunny.net/api_" + endpoint + ".php"
|
||||||
params["sid"] = self.session_id
|
params["sid"] = self.session_id
|
||||||
data = self.extractor.request(url, params=params).json()
|
|
||||||
|
|
||||||
if "error_code" in data:
|
while True:
|
||||||
|
data = self.extractor.request(url, params=params).json()
|
||||||
|
|
||||||
|
if "error_code" not in data:
|
||||||
|
return data
|
||||||
|
|
||||||
if str(data["error_code"]) == "2":
|
if str(data["error_code"]) == "2":
|
||||||
self.authenticate(invalidate=True)
|
self.authenticate(invalidate=True)
|
||||||
return self._call(endpoint, params)
|
continue
|
||||||
raise exception.StopExtraction(data.get("error_message"))
|
|
||||||
|
|
||||||
return data
|
raise exception.StopExtraction(data.get("error_message"))
|
||||||
|
|
||||||
def _pagination_search(self, params):
|
def _pagination_search(self, params):
|
||||||
params["page"] = 1
|
params["page"] = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user