Skip to content

Commit c5177c9

Browse files
committed
fix: improve token retrieval by reading files in binary mode and handling null bytes
1 parent 876c250 commit c5177c9

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

StreamLabsTikTokStreamKeyGenerator.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,14 @@ def load_local_token(self):
385385
# Loop through files and search for the token pattern
386386
for file in files:
387387
try:
388-
with open(file, 'r', encoding='utf-8', errors='ignore') as f:
389-
content = f.read()
390-
matches = token_pattern.findall(content)
391-
if matches:
392-
# Get the last occurrence of the token
393-
token = matches[-1]
394-
break
388+
with open(file, 'rb') as f:
389+
content = f.read().decode('utf-8', errors='ignore')
390+
content = re.sub(r'[\x00]', '', content)
391+
matches = token_pattern.findall(content)
392+
if matches:
393+
# Get the last occurrence of the token
394+
token = matches[-1]
395+
break
395396
except Exception as e:
396397
QMessageBox.critical("Error", f"Error reading file {file}: {e}")
397398
if token:

0 commit comments

Comments
 (0)