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:
Victor Westerlund 2020-11-22 20:29:52 +01:00
parent a8db13cbf6
commit 64202e7699
2 changed files with 67 additions and 1 deletions

3
.gitignore vendored
View file

@ -1 +1,2 @@
*__pycache__ *__pycache__
dev*

View file

@ -92,6 +92,71 @@ class Texture:
data = self.body 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))
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 # Raise exception if request fails
# 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"):