From be67f4e42de13f61577efe9c81c61740a456da72 Mon Sep 17 00:00:00 2001 From: Jeremie Jarosh Date: Sun, 16 Apr 2023 05:33:34 -0500 Subject: [PATCH] Use the `json()` method of the `requests` library (#85) --- itchiodl/library.py | 7 +++---- itchiodl/login.py | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/itchiodl/library.py b/itchiodl/library.py index 1132735..d6b1c3a 100644 --- a/itchiodl/library.py +++ b/itchiodl/library.py @@ -1,4 +1,3 @@ -import json from concurrent.futures import ThreadPoolExecutor import functools import threading @@ -24,7 +23,7 @@ class Library: f"https://api.itch.io/profile/owned-keys?page={page}", headers={"Authorization": self.login}, ) - j = json.loads(r.text) + j = r.json() for s in j["owned_keys"]: self.games.append(Game(s)) @@ -46,7 +45,7 @@ class Library: f"https://{publisher}.itch.io/{title}/data.json", headers={"Authorization": self.login}, ) - j = json.loads(rsp.text) + j = rsp.json() game_id = j["id"] gsp = requests.get( f"https://api.itch.io/games/{game_id}/uploads", @@ -84,7 +83,7 @@ class Library: f"https://api.itch.io/games/{game_id}", headers={"Authorization": self.login}, ) - k = json.loads(gsp.text) + k = gsp.json() self.games.append(Game(k)) def download_library(self, platform=None): diff --git a/itchiodl/login.py b/itchiodl/login.py index 0c05854..0d88ed7 100644 --- a/itchiodl/login.py +++ b/itchiodl/login.py @@ -1,4 +1,3 @@ -import json from bs4 import BeautifulSoup as soup import requests @@ -41,7 +40,7 @@ def LoginAPI(user, password): print(warning) print(r.text) raise RuntimeError - t = json.loads(r.text) + t = r.json() if not t["success"]: print("Error: success key is not true")