From 9164df49fafb61db4a3237196b1a40b6e8ccb22c Mon Sep 17 00:00:00 2001 From: ef1500 <45581646+ef1500@users.noreply.github.com> Date: Thu, 31 Aug 2023 13:22:39 -0500 Subject: [PATCH] Revert "Automatically extracts salt" --- requirements.txt | 3 --- twitcasting/TwitcastAPI.py | 43 +------------------------------------- 2 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e6d95ca..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -requests -websockets -javascript \ No newline at end of file diff --git a/twitcasting/TwitcastAPI.py b/twitcasting/TwitcastAPI.py index 85e630f..aab6b36 100644 --- a/twitcasting/TwitcastAPI.py +++ b/twitcasting/TwitcastAPI.py @@ -5,7 +5,6 @@ import time from typing import Optional -import javascript import requests from utils.CookiesHandler import CookiesHandler @@ -28,52 +27,12 @@ def GetAuthSessionID(self, user_page) -> Optional[str]: return None return auth_session_id.group(1) - - def GenerateJsRegex(self, js: str) -> str: - js = re.escape(js) - js = re.sub(r"\\\[.*?\]", r"(\[.*?\])", js) # list - js = re.sub(r"[0-9]+", r"([0-9]+)", js) # number - js = re.sub(r"[a-zA-Z_][a-zA-Z0-9_]*", r"([a-zA-Z_][a-zA-Z0-9_]*)", js) # field - js = re.sub(r"'.*?'|\".*?\"|`.*?`", r"('.*?'|\".*?\"|`.*?`)", js) # string - return js - - def GetSalt(self): - code = requests.get( - f"https://twitcasting.tv/js/v1/PlayerPage2.js?{int(time.time())}" - ).text - - crypt_func = """function t(e,i){const s=n();return t=function(n,i){let r=s[n-=269];void 0===t.MXfUDE&&(t.PoYvHX=function(e){let t="",n="";for(let n,i,s=0,r=0;i=e.charAt(r++);~i&&(n=s%4?64*n+i:i,s++%4)?t+=String.fromCharCode(255&n>>(-2*s&6)):0)i="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=".indexOf(i);for(let e=0,i=t.length;e dict: if sessionID is None: print(f"Unable to generate authorization headers for {path}: no session id provided") return {} - seed = self.GetSalt() + seed = "gu9mi5r5kk603pfc" timestamp = int(time.time()) text = f"{seed}{timestamp}{method}{path}{sessionID}" h = hashlib.sha256()