mirror of
https://codeberg.org/vlw/labylib.git
synced 2025-09-13 17:43:41 +02:00
Draft: Visibility
Work in progress; Change visibility of cosmetics with 'Visibility()' Currently not working. Getting HTTP Conflict response from endpoint. Needs further investigation
This commit is contained in:
parent
a8db13cbf6
commit
64202e7699
2 changed files with 67 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
*__pycache__
|
*__pycache__
|
||||||
|
dev*
|
|
@ -96,3 +96,68 @@ class Texture:
|
||||||
# Use [3:5] to clean up junk chars from reponse body
|
# Use [3:5] to clean up junk chars from reponse body
|
||||||
if(str(request.text)[3:5] != "OK"):
|
if(str(request.text)[3:5] != "OK"):
|
||||||
raise RequestError(str(request.text))
|
raise RequestError(str(request.text))
|
||||||
|
|
||||||
|
class Visibility:
|
||||||
|
|
||||||
|
endpoint = "https://www.labymod.net/api/change"
|
||||||
|
|
||||||
|
def __init__(self,cookie,value):
|
||||||
|
self.validate(cookie,value)
|
||||||
|
|
||||||
|
self.cookies = dict(PHPSESSID = cookie)
|
||||||
|
|
||||||
|
self.headers = {
|
||||||
|
"accept": "*/*",
|
||||||
|
"accept-encoding": "gzip, deflate, br",
|
||||||
|
"accept-language": "en-US,en;q=0.9,sv;q=0.8",
|
||||||
|
"cache-control": "no-cache",
|
||||||
|
"dnt": "1",
|
||||||
|
"user-agent": "Mozilla/5.0 (Windows NT 5.1; rv:33.0) Gecko/20100101 Firefox/33.0",
|
||||||
|
"origin": "https://www.labymod.net",
|
||||||
|
"pragma": "no-cache",
|
||||||
|
"referer": "https://www.labymod.net/dashboard",
|
||||||
|
"sec-fetch-dest": "empty",
|
||||||
|
"sec-fetch-mode": "cors",
|
||||||
|
"sec-fetch-site": "same-origin",
|
||||||
|
"x-requested-with": "XMLHttpRequest",
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||||
|
}
|
||||||
|
|
||||||
|
self.body = ""
|
||||||
|
|
||||||
|
# Payload
|
||||||
|
self.addEncodedFormData("type","switch")
|
||||||
|
self.addEncodedFormData("value",value)
|
||||||
|
self.addEncodedFormData("item",459595)
|
||||||
|
self.addEncodedFormData("site","control")
|
||||||
|
|
||||||
|
# -----------------------------------
|
||||||
|
|
||||||
|
def validate(self,cookie,file):
|
||||||
|
return True
|
||||||
|
|
||||||
|
# Add URLEncoded form data (x-www-form-urlencoded)
|
||||||
|
def addEncodedFormData(self,key,value):
|
||||||
|
body = "&"
|
||||||
|
|
||||||
|
# Remove '&' delimiter for first item
|
||||||
|
if(self.body == ""):
|
||||||
|
body = ""
|
||||||
|
|
||||||
|
body += f"{key}={value}"
|
||||||
|
|
||||||
|
self.body += body
|
||||||
|
|
||||||
|
# -----------------------------------
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
request = requests.post(Texture.endpoint,
|
||||||
|
headers = self.headers,
|
||||||
|
cookies = self.cookies,
|
||||||
|
data = self.body
|
||||||
|
)
|
||||||
|
|
||||||
|
# Raise exception if request fails
|
||||||
|
# Use [3:5] to clean up junk chars from reponse body
|
||||||
|
if(str(request.text)[3:5] != "OK"):
|
||||||
|
raise RequestError(str(request.text))
|
Loading…
Add table
Reference in a new issue