Python API to modify LabyMod cosmetics
Project description
Cosmetics API for Labymod
Modify LabyMod cosmetics programmatically with Python.
Created by VicW |
---|
labylib or Victor Westerlund is in no way sponsored by or affiliated with LabyMod or LabyMedia GmbH.
This program is offered as-is and might stop working at any time
Installation
- Download and install Python 3 for your architecture.
- Clone this repo to your machine, or download a zip
$ git clone https://github.com/VictorWesterlund/labylib/
$ gh repo clone VictorWesterlund/labylib
Quickstart
1. Import a cosmetics module from labylib/<cosmetic>
.
A list of all modules and classes can be found here
from labylib import Cape
2. Initialize a module class.
All labylib classes take a PHPSESSID
as their first argument.
Example with Cape
where a file-path is expected as a second argument:
texture = Cape.Texture("<String PHPSESSID>","<String PATH_TO_PNG>") # labylib = Cape.Texture("772nnas663jkc8ahbb2","/home/VicW/coolCape-2.png")
3. Submit a cosmetic update
texture.update()
Python's Built-in-exceptions are rasied as needed 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; containing the response received from the endpoint.
try:
texture.update()
except RequestError as error:
print("Caugh RequestError exception:" + error)
# "Caugh RequestError exception: Session expired."
Advanced usage
HTTP POST Headers
Request headers and cookies can be accessed and modified pre-submission by applying standard list modifications on the followin objects: self.headers
and self.cookies
texture = Cape.Texture("<String PHPSESSID>","<String PATH_TO_PNG>")
texture.headers["Origin"] = "https://example.com/"
texture.cookies["Foo"] = "Bar"
labylib.update()
HTTP POST Body
Binary form-data can be appended by calling self.appendBinaryFormData(name,payload)
.
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)
Special form-data types ('names'):
name | Description |
---|---|
'file' |
Submit cosmetic texture file as BLOB by passing payload a binary-encoded PNG.self.bOpen() can be used to 'open()' a file as binary string. |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.