Skip to content

Commit 9821ccf

Browse files
Fix get csrf_token issue
1 parent 539ec3c commit 9821ccf

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

pyinstalive/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
def get_csrf_token():
99
response = globals.session.session.get(Constants.LOGIN_PAGE)
10-
return helpers.get_shared_data(response.text).get("csrf_token", None)
10+
helper_res = helpers.get_shared_data(response.text)
11+
return helper_res.get("csrf_token", None)
1112

1213
def do_login():
1314
now_epoch = int(datetime.now().timestamp())

pyinstalive/helpers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ def get_shared_data(data):
8989
match = re.search(r"\"raw\":\"({[^\n]*\\\"})", data)
9090
if match:
9191
match_str = string_escape(match.group(1))
92-
return json.loads(match_str)
92+
csrf_token = re.search(r'"csrf_token":\s*"([^"]+)"', match_str)
93+
csrf_token_value = csrf_token.group(1)
94+
response = {"csrf_token": csrf_token_value}
95+
return response
9396

9497
def lock_exists():
9598
return os.path.isfile(os.path.join(globals.config.download_path, globals.download.download_user + '.lock'))

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
argparse>=1.4.0
2-
configparser>=4.0.2
2+
configparser>=4.0.2
3+
requests==2.30.0

0 commit comments

Comments
 (0)