Skip to content

Commit 3a0cd7b

Browse files
Again fix login issue
1 parent 9821ccf commit 3a0cd7b

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

pyinstalive/helpers.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import shlex
77
import shutil
88
import requests
9+
from bs4 import BeautifulSoup
910

1011
from urllib.parse import urlparse
1112

@@ -86,13 +87,23 @@ def get_shared_data(data):
8687
match_str = match.group(1)
8788
return json.loads(match_str).get("config")
8889
else:
89-
match = re.search(r"\"raw\":\"({[^\n]*\\\"})", data)
90-
if match:
91-
match_str = string_escape(match.group(1))
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
90+
response = {}
91+
soup = BeautifulSoup(data, 'html.parser')
92+
all_scripts = soup.find_all('script', {"data-content-len":True, "src": False})
93+
chnk_len = 100
94+
for script in all_scripts:
95+
if int(script["data-content-len"]) > 30000:
96+
lines = script.text
97+
for idx in range(0, len(lines), chnk_len):
98+
csrf_token_match = re.findall(r"csrf_token", lines[idx : idx + chnk_len])
99+
if csrf_token_match:
100+
matches = re.findall(r'\{([^}]+)\}', lines[idx : idx + chnk_len])
101+
if len(matches)>0:
102+
dict_value = "{" + matches[0] + "}"
103+
response = json.loads(dict_value)
104+
break
105+
return response
106+
96107

97108
def lock_exists():
98109
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,3 +1,4 @@
11
argparse>=1.4.0
22
configparser>=4.0.2
3-
requests==2.30.0
3+
requests==2.30.0
4+
beautifulsoup4==4.12.2

0 commit comments

Comments
 (0)