Skip to main content

Python API to modify LabyMod cosmetics

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

labylib-0.1.0.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

labylib-0.1.0-py3-none-any.whl (16.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page