Python API to modify LabyMod cosmetics
Find a file
2020-11-30 01:24:33 +01:00
labylib Added new cosmetic 'Hat' and finished 'Cape' 2020-11-30 01:18:45 +01:00
.gitignore Draft: Visibility 2020-11-22 20:29:52 +01:00
LICENSE Initial commit 2020-11-11 20:50:13 +01:00
README.md Update README 2020-11-22 21:35:16 +01:00

Labylib

Cosmetics API for Labymod

GitHub release (latest by date including pre-releases) GitHub last commit Maintenance

Modify LabyMod cosmetics programmatically with Python.

VicW 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

  1. Download and install Python 3 for your architecture.
  2. 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.