Compare commits

...

15 commits

Author SHA1 Message Date
5ea6e6314c
Update README.md 2021-01-23 03:23:26 +01:00
8d1eb7181f
Update README.md 2021-01-23 03:10:44 +01:00
f64206f022
Merge pull request #7 from VictorWesterlund/feature/cosmetics
Merging anyways and closing maintenance for this repo. `Multi` Support for cosmetics using the old endpoint might be added in the future.
2021-01-23 03:09:03 +01:00
f1505c67ad Added new cosmetic "Cap" 2020-12-27 12:57:51 +01:00
69f46ec52b Added new cosmetic "Moose Hat" 2020-12-15 13:03:17 +01:00
c8fe34620d Added new cosmetic "Mask"
Cosmetics with values of type="multi" now have a single class "Multi" where each value is set by calling a function. LabyMod expects all mutli values to be set in order to update the cosmetic. Labylib does not pull current values as of yet.

Added "Mask" cosmetic.
2020-12-11 14:02:56 +01:00
4a5cd81eef Added "Backpack" and "XMAS" cosmetics 2020-12-07 08:43:54 +01:00
Victor Westerlund
939a306c6f
Update README.md 2020-11-30 04:07:50 +01:00
Victor Westerlund
2be9c26252
Update README.md 2020-11-30 03:45:37 +01:00
Victor Westerlund
324e26a1f3
Merge pull request #6 from VictorWesterlund/feature/cosmetics
Feature/cosmetics
2020-11-30 01:24:33 +01:00
18b6ef34e4 Added new cosmetic 'Hat' and finished 'Cape'
All customizable elements of 'Hat' and 'Cape' are now implemented.

Values are now submitted directly from the 'update()' which means you can easily chain actions without having to create a new instance.

Removed 'validate()' for now.

Removed '__init__.py' from repo root as labylib should be installed as a Python package.
2020-11-30 01:18:45 +01:00
Victor Westerlund
2cae57b3e9
Update README
Added: PNG-logo, shields.io badges
Removed: PHPSESSID guide (moved to Wiki), Reference sheet (moved to Wiki)

Wording and some syntax changes
2020-11-22 21:35:16 +01:00
64202e7699 Draft: Visibility
Work in progress;

Change visibility of cosmetics with 'Visibility()'

Currently not working. Getting HTTP Conflict response from endpoint. Needs further investigation
2020-11-22 20:29:52 +01:00
a8db13cbf6 Merge branch 'feature/labylib-core' 2020-11-15 15:59:40 +01:00
f3ac6b1f5d Create __init__.py
Created __init__.py to handle git submodule references.

I expect this file, along with all the others to change a lot over time
2020-11-15 15:58:17 +01:00
9 changed files with 949 additions and 96 deletions

1
.gitignore vendored
View file

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

150
README.md
View file

@ -1,105 +1,91 @@
# labylib
![Labylib](https://storage.googleapis.com/public.victorwesterlund.com/github/VictorWesterlund/labylib/labylib.png)
### Cosmetics API for Labymod
Set and update Labymod cosmetics programmatically.
![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/VictorWesterlund/labylib?include_prereleases)
![GitHub last commit](https://img.shields.io/github/last-commit/VictorWesterlund/labylib)
![Maintenance](https://img.shields.io/maintenance/no/2021)
|![VicW](https://crafatar.com/renders/body/53c40674-f0a2-4f95-9ce1-479bdd1d8b67?scale=2) | Created by VicW |
|--|--|
Modify LabyMod cosmetics programmatically with Python.
### [Supported cosmetics](https://github.com/VictorWesterlund/labylib/wiki/labylib-Modules)
_labylib is in no way sponsored by or affiliated with LabyMod or LabyMedia GmbH._<br>
_This program is offered as-is and might stop working at any time._
## Installation
1. Download and install [Python 3.x.x](https://www.python.org/downloads/) for your computer's architecture
2. Clone this repo to your machine, or [download a zip](/VictorWesterlund/labylib/archive/master.zip) if you don't speak git
1. Download and install [Python 3](https://www.python.org/downloads/).
2. Install the latest version of labylib with [`pip`](https://pypi.org/project/labylib/)
![PyPI](https://img.shields.io/pypi/v/labylib)
![PyPI - Wheel](https://img.shields.io/pypi/wheel/labylib)
```bash
$ git clone https://github.com/VictorWesterlund/labylib/
$ gh repo clone VictorWesterlund/labylib
$ python3 -m pip install labylib
```
3. Extract/copy the `labylib` folder into your project (or make it a dependancy)
## Quickstart
_**NOTE:**_ _labylib relies on a supplied `PHPSESSID`-cookie from 'labymod.net' to execute its requests. Follow this [this step-by-step guide](#find-your-phpsessid-cookie) to find your `PHPSESSID`_
**1. Start by importing a module from `labylib/<cosmetic>`. All [supported cosmetics](#supported-cosmetics) are self-contained modules.**
```python
from labylib import Cape
1. Import a labylib Module from the [list of available modules](https://github.com/VictorWesterlund/labylib/wiki/labylib-Modules).
```python3
from labylib import <MODULE>
```
**2. Initialize the `Texture()` class.**
All modules take a required `PHPSESSID` as their first argument. The second argument varies depending on the cosmetic.
_Example with `Cape` where a file-path is expected:_
```python
texture = Cape.Texture("<String PHPSESSID>","<String PATH_TO_PNG>") # labylib = Cape.Texture("772nnas663jkc8ahbb2","/home/VicW/coolCape-2.png")
2. Each Module comes with a set of classes available to each cosmetic. Pick a class for your Module. (`Visibility`,`Texture` etc.)
3. Initialize the class by passing it a `PHPSESSID`<br>
[**Here's what it is and where to find it**](https://github.com/VictorWesterlund/labylib/wiki/Find-your-PHPSESSID)
```python3
# Example
cape_vis = Cape.Visibility(PHPSESSID)
```
4. Call `update()` with a value expected by the class. Just like Modules, the value expected depends on the class.
```python3
# Example
cape_vis.update("show")
```
**3. Submit a cosmetic update**
```python
texture.update()
```
Normal Python "Built-in"-exceptions are rasied for missing texture files (`FileNotFoundError`) etc. If a request was sucuessfully sent to the Labymod endpoint, but it returned something falsey (not `OK`). A custom-defined `RequestError` exception will be raised. It contains the message received from the endpoint server.
```python
try:
texture.update()
except RequestError as error:
print("Caugh RequestError exception:" + error)
# "Caugh RequestError exception: Session expired"
# Advanced Usage
### Request headers and cookies:
Each class instance can be modified before `update()` is called to make changes to the request headers, cookies etc. You can even add additional encoded form data to the request body if necessary.
labylib uses [`Requests`](https://requests.readthedocs.io/en/master/) under the hood and request parameters like headers and cookies can be modified in accordance with `Request`'s conventions.
```python3
# This will send add a "foo=bar" cookie and header with the request
cape_vis.cookies["foo"] = "bar"
cape_vis.headers["foo"] = "bar"
cape_vis.update("show")
```
## Advanced usage
### HTTP POST Headers
Request header and cookie dictionaries can be accessed and modified pre-submission by referencing `this.headers` and `this.cookies` respectivly.
```python
texture = Cape.Texture("<String PHPSESSID>","<String PATH_TO_PNG>")
### Append form data to the request body of an instance:
texture.headers["Origin"] = "https://example.com/"
texture.cookies["Foo"] = "Bar"
labylib.update()
```
### HTTP POST Body
Binary form-data can be added by calling `self.appendBinaryFormData(name,payload)`. Attach `Content-Type`-less form data by supplying a 'name' and 'payload'. Setting 'name' to "file" allows you to upload a `image/png` as BLOB. "payload" excpects a file-path in this case
```python
texture = Cape.Texture("<String PHPSESSID>","<String PATH_TO_PNG>")
texture.appendBinaryFormData(b"foo",b"bar")
texture.appendBinaryFormData(b"file","/home/VicW/home/VicW/coolCape-2.png") # Note that 'payload' is a String in this case (as opposed to Binary)
**For `x-www-form-urlencoded` requests:** Append form data with the `addEncodedFormData(key,value)` method:
```python3
# This will add "foo=bar" to the URL encoded payload
cape_vis.addEncodedFormData("foo","bar")
cape_vis.update("show")
```
# Additional information:
**For `multipart/form-data` requests:** Append binary form data with the `addBinaryFormData(key,payload)` method:
```python3
# This will create a new payload boundary containing "foo=bar"
cape_texture.addBinaryFormData(b"foor",b"bar")
cape_texture.update("show")
```
You can also append `image/png` files by passing "file" as the `key` argument. You can either pass binary data directly as a BLOB to `payload` or use `bOpen(<Path_to_PNG>)` to load an image from disk:
```python3
# This will create a new payload boundary with a "Content-Type: image/png" header and BLOB body
cape_texture.addBinaryFormData(b"file",cape_vis.bOpen("~/someImage.png"))
cape_texture.update("~/myAwesomeTexture.png")
```
## Find your `PHPSESSID`-cookie
Instructions for your browser:
* [Chrome](#chrome)
* [Firefox](#firefox)
* [Safari](#safari)
## Contribute
### Chrome
1. Open [labymod.net](https://www.labymod.net/) and log in with your Labymod account
2. Press <kbd>F12</kbd> on your keyboard (or <kbd>Ctrl</kbd>+<kbd>⇧ Shift</kbd>+<kbd>I</kbd>) to open DevTools
4. Click on the `Application` tab.
5. Expand `Cookies` under the `Storage` cateogry in the sidebar and select `https://www.labymod.net/`
6. Type `PHPSESSID` into the search box called 'Filter'
7. Copy `Value`(PHPSESSID) from the filtered table. If nothing comes up; try navigating to another page on labymod.net
8. Close DevTools
If you find any bugs with- or would like to suggest features to labylib, please submit them under [Issues](https://github.com/VictorWesterlund/labylib/issues)
### Firefox
1. Open [labymod.net](https://www.labymod.net/) and log in with your Labymod account
2. Press <kbd>F12</kbd> on your keyboard (or Right-click the page and select "Inspect Element") to open Developer Tools
4. Click on the `Storage` tab.
5. `Cookies` should already be expanded and selected, but if it isn't; expand it and select `https://www.labymod.net`
6. Using the search bar called 'Filter items', type: `PHPSESSID`
7. Copy `Value`(PHPSESSID) from the filtered table. If nothing comes up; try navigating to another page on labymod.net
8. Close Developer Tools
## License
### Safari
1. Open [labymod.net](https://www.labymod.net/) and log in with your Labymod account
2. Right-click the page and select "Inspect Element" (or <kbd>⌥ Option</kbd>+<kbd>⌘ Command</kbd>+<kbd>I</kbd>) to open Web Inspector
4. Click on the `Storage` tab.
5. Expand `Cookies` in the sidebar and select `labymod.net`
6. Find `PHPSESSID` in the table under the 'Name' column
7. Copy `Value`(PHPSESSID) from the filtered table. If nothing comes up; try navigating to another page on labymod.net
8. Close Web Inspector
[GNU General Public License v3.0](https://github.com/VictorWesterlund/labylib/blob/master/LICENSE)
### Supported cosmetics
| Labymod cosmetic | labylib module name |
----
|![VicW](https://i.imgur.com/XHwOKuS.png) | Created by VicW |
|--|--|
| Cloak | Cape |

138
labylib/Backpack.py Normal file
View file

@ -0,0 +1,138 @@
import requests
class Visibility:
endpoint = "https://www.labymod.net/api/change"
def __init__(self,cookie):
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("item",525800)
self.addEncodedFormData("site","control")
# -----------------------------------
# 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,value):
# Interpret strings
if(type(value) != int):
if(value == "show"):
value = 1
else:
value = 0
self.addEncodedFormData("value",value)
request = requests.post(Visibility.endpoint,
headers = self.headers,
cookies = self.cookies,
data = self.body
)
# Raise exception if request fails
request.raise_for_status()
class Multi:
endpoint = "https://www.labymod.net/api/change"
def __init__(self,cookie):
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 = ""
self.values = (000000,000000)
# Payload
self.addEncodedFormData("type","multi")
self.addEncodedFormData("item",525800)
self.addEncodedFormData("site","control")
# -----------------------------------
def color(color,color2 = None):
if(color2):
self.values[0] = color
self.values[1] = color2
return
self.values[0] = color[0]
self.values[1] = color[1]
# -----------------------------------
# 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,value):
value = ",".join(self.values)
self.addEncodedFormData("value",value)
request = requests.post(Visibility.endpoint,
headers = self.headers,
cookies = self.cookies,
data = self.body
)
# Raise exception if request fails
request.raise_for_status()

152
labylib/Cap.py Normal file
View file

@ -0,0 +1,152 @@
import requests
class Visibility:
endpoint = "https://www.labymod.net/api/change"
def __init__(self,cookie):
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("item",630683)
self.addEncodedFormData("site","control")
# -----------------------------------
# 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,value):
# Interpret strings
if(type(value) != int):
if(value == "show"):
value = 1
else:
value = 0
self.addEncodedFormData("value",value)
request = requests.post(Visibility.endpoint,
headers = self.headers,
cookies = self.cookies,
data = self.body
)
# Raise exception if request fails
request.raise_for_status()
class Multi:
endpoint = "https://www.labymod.net/api/change"
def __init__(self,cookie):
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 = ""
self.values = (0,"",000000,0) # Direction,texture,color,unknown
# Payload
self.addEncodedFormData("type","multi")
self.addEncodedFormData("item",630683)
self.addEncodedFormData("site","control")
# -----------------------------------
def direction(value):
if(value == 1 or value == "front"):
self.values[0] = 1
return
self.values[0] = 0
def template(name == "default"):
templates = [
"default": "7a9c8635-d64f-47ee-a373-5faceffc1915",
"2021": "7ec142d2-fc29-42f5-9659-0d84b104d4c6"
]
if(name not in dictionary):
name = dictionary[0]
self.values[1] = name
def color(color = "ffffff"):
self.values[2] = color
# -----------------------------------
# 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,value):
value = ",".join(self.values)
self.addEncodedFormData("value",value)
request = requests.post(Visibility.endpoint,
headers = self.headers,
cookies = self.cookies,
data = self.body
)
# Raise exception if request fails
request.raise_for_status()

View file

@ -2,15 +2,11 @@ import requests
import hashlib
import time
class RequestError(Exception): pass
class Texture:
endpoint = "https://www.labymod.net/page/php/cape.php"
def __init__(self,cookie,img):
self.validate(cookie,img)
def __init__(self,cookie):
self.body = b"" # Initialize request body
self.cookies = dict(PHPSESSID = cookie)
self.boundary = self.boundary()
@ -33,13 +29,9 @@ class Texture:
}
self.appendBinaryFormData(b"cosmetic",b"cape")
self.appendBinaryFormData(b"file",self.bOpen(img))
# -----------------------------------
def validate(self,cookie,file):
return True
# Generate boundary header from MD5-hash of current time
def boundary(self):
seed = str(time.time())
@ -83,7 +75,9 @@ class Texture:
# -----------------------------------
def update(self):
def update(self,img):
self.appendBinaryFormData(b"file",self.bOpen(img))
self.closeBinaryFormData() # Add final boundary header
request = requests.post(Texture.endpoint,
@ -93,6 +87,157 @@ class Texture:
)
# 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))
request.raise_for_status()
class Template:
endpoint = "https://www.labymod.net/page/php/setCapeTpl.php"
templates = {
"labymod": "10_LABYMOD.png",
"minecon2011": "30_MINECON2011.png",
"minecon2012": "30_MINECON2012.png",
"minecon2013": "30_MINECON2013.png",
"minecon2015": "30_MINECON2015.png",
"minecon2016": "30_MINECON2016.png",
"minecon2019": "30_MINECON2019.png",
"prismarine": "30_PRISMARINE.png",
"christmas2010": "40_CHRISTMAS2010.png",
"cobalt": "40_COBALT.png",
"julianclark": "40_JULIANCLARK.png",
"mapmaker": "40_MAPMAKER.png",
"mojira": "40_MOJIRA.png",
"mrmessiah": "40_MRMESSIAH.png",
"newyear": "40_NEWYEAR.png",
"scrolls": "40_SCROLLS.png",
"translator": "40_TRANSLATOR.png",
"turtle": "40_TURTLE.png",
"winner": "40_WINNER.png"
}
def __init__(self,cookie):
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("cosmetic","cape")
# -----------------------------------
# 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,value):
value = value.lower()
if(value not in Template.templates):
raise ValueError(f"'{value}' is not a valid template.")
texture = Template.templates[value]
self.addEncodedFormData("cape",texture)
request = requests.post(Template.endpoint,
headers = self.headers,
cookies = self.cookies,
data = self.body
)
# Raise exception if request fails
request.raise_for_status()
class Visibility:
endpoint = "https://www.labymod.net/api/change"
def __init__(self,cookie):
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("item",459595)
self.addEncodedFormData("site","control")
# -----------------------------------
# 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,value):
# Interpret strings
if(type(value) != int):
if(value == "show"):
value = 1
elif(value == "hide"):
value = 0
else:
raise ValueError(f"'{value}' is not a valid visibility state.")
self.addEncodedFormData("value",value)
request = requests.post(Visibility.endpoint,
headers = self.headers,
cookies = self.cookies,
data = self.body
)
# Raise exception if request fails
request.raise_for_status()

126
labylib/Hat.py Normal file
View file

@ -0,0 +1,126 @@
import requests
class Texture:
endpoint = "https://www.labymod.net/api/change"
def __init__(self,cookie):
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","country")
self.addEncodedFormData("item",459594)
self.addEncodedFormData("site","control")
# -----------------------------------
# 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,value):
self.addEncodedFormData("value",value)
request = requests.post(Texture.endpoint,
headers = self.headers,
cookies = self.cookies,
data = self.body
)
# Raise exception if request fails
request.raise_for_status()
class Visibility:
endpoint = "https://www.labymod.net/api/change"
def __init__(self,cookie):
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("item",459594)
self.addEncodedFormData("site","control")
# -----------------------------------
# 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,value):
# Interpret strings
if(type(value) != int):
if(value == "show"):
value = 1
else:
value = 0
self.addEncodedFormData("value",value)
request = requests.post(Visibility.endpoint,
headers = self.headers,
cookies = self.cookies,
data = self.body
)
# Raise exception if request fails
request.raise_for_status()

171
labylib/Mask.py Normal file
View file

@ -0,0 +1,171 @@
import requests
class Visibility:
endpoint = "https://www.labymod.net/api/change"
def __init__(self,cookie):
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("item",544349)
self.addEncodedFormData("site","control")
# -----------------------------------
# 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,value):
# Interpret strings
if(type(value) != int):
if(value == "show"):
value = 1
else:
value = 0
self.addEncodedFormData("value",value)
request = requests.post(Visibility.endpoint,
headers = self.headers,
cookies = self.cookies,
data = self.body
)
# Raise exception if request fails
request.raise_for_status()
class Multi:
endpoint = "https://www.labymod.net/api/change"
def __init__(self,cookie):
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 = ""
self.values = (000000,000000,0,0) # Color,Color,Size,Texture
# Payload
self.addEncodedFormData("type","multi")
self.addEncodedFormData("item",544349)
self.addEncodedFormData("site","control")
# -----------------------------------
def color(color,color2 = None):
if(color2):
self.values[0] = color
self.values[1] = color2
return
self.values[0] = color[0]
self.values[1] = color[1]
def size(size):
# Interpret strings
if(type(size) != int):
if(size == "big"):
size = 1
else:
size = 0
self.values[2] = size
def template(value):
templates = {
"None": "null",
"3": "26b459ce-2f09-4b50-97ad-c589262b0268",
":3": "3b7492c6-4239-4e4b-9906-d510e722a96b",
":*)": "4120f1eb-19e6-4f34-8417-d7bd6a01d85a",
":#)": "43e1b6bf-2a18-40f4-b0b0-38b7c74a6ddb",
":'3": "4b498414-5894-4124-98f6-b6c5a531b6e8",
":)": "84456b05-85ba-48bf-a0c8-ca4ba981ff8e",
":p)": "a387dde9-a1a8-41b8-9e77-8446f8d6d3cd",
":P": "aaa3db95-6537-4ef0-aa66-050b20412ef6",
":')": "bb9006f9-b67c-4fff-996b-6d74a1b691d6",
"::)": "c6aa01db-bd10-4948-9632-afe6bd0c3f3c",
"X": "e93ec7b5-4148-4d1c-aefd-26c3f125cec7",
";p": "ed2c847c-5b2b-4916-843d-438b6c039804",
":~)": "f9e4f616-e697-441e-be57-1b64cc5c5e41"
}
if(value not in templates):
raise ValueError(f"'{value}' is not a valid template.")
self.values[3] = templates[value]
# -----------------------------------
# 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,value):
value = ",".join(self.values)
self.addEncodedFormData("value",value)
request = requests.post(Visibility.endpoint,
headers = self.headers,
cookies = self.cookies,
data = self.body
)
# Raise exception if request fails
request.raise_for_status()

67
labylib/MooseHat.py Normal file
View file

@ -0,0 +1,67 @@
import requests
class Visibility:
endpoint = "https://www.labymod.net/api/change"
def __init__(self,cookie):
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("item",576242)
self.addEncodedFormData("site","control")
# -----------------------------------
# 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,value):
# Interpret strings
if(type(value) != int):
if(value == "show"):
value = 1
else:
value = 0
self.addEncodedFormData("value",value)
request = requests.post(Visibility.endpoint,
headers = self.headers,
cookies = self.cookies,
data = self.body
)
# Raise exception if request fails
request.raise_for_status()

67
labylib/XMAS.py Normal file
View file

@ -0,0 +1,67 @@
import requests
class Visibility:
endpoint = "https://www.labymod.net/api/change"
def __init__(self,cookie):
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("item",520292)
self.addEncodedFormData("site","control")
# -----------------------------------
# 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,value):
# Interpret strings
if(type(value) != int):
if(value == "show"):
value = 1
else:
value = 0
self.addEncodedFormData("value",value)
request = requests.post(Visibility.endpoint,
headers = self.headers,
cookies = self.cookies,
data = self.body
)
# Raise exception if request fails
request.raise_for_status()