Python API to modify LabyMod cosmetics
Find a file
2020-11-15 15:11:47 +01:00
labylib Pre-Release 0.1.0 2020-11-15 15:05:38 +01:00
.gitignore Pre-Release 0.1.0 2020-11-15 15:05:38 +01:00
LICENSE Initial commit 2020-11-11 20:50:13 +01:00
README.md Update README.md 2020-11-15 15:02:47 +01:00

labylib

Cosmetics API for Labymod

Set and update Labymod cosmetics programmatically.

VicW Created by VicW

Installation

  1. Download and install Python 3.x.x for your computer's architecture
  2. Clone this repo to your machine, or download a zip if you don't speak git
$ git clone https://github.com/VictorWesterlund/labylib/
$ gh repo clone VictorWesterlund/labylib
  1. 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 to find your PHPSESSID

1. Start by importing a module from labylib/<cosmetic>. All supported cosmetics are self-contained modules.

from labylib import Cape

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:

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()

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.

try:
  texture.update()
except RequestError as error:
  print("Caugh RequestError exception:" + error)
# "Caugh RequestError exception: Session expired"

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.

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 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

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)

Additional information:

Instructions for your browser:

Chrome

  1. Open labymod.net and log in with your Labymod account
  2. Press F12 on your keyboard (or Ctrl+⇧ Shift+I) to open DevTools
  3. Click on the Application tab.
  4. Expand Cookies under the Storage cateogry in the sidebar and select https://www.labymod.net/
  5. Type PHPSESSID into the search box called 'Filter'
  6. Copy Value(PHPSESSID) from the filtered table. If nothing comes up; try navigating to another page on labymod.net
  7. Close DevTools

Firefox

  1. Open labymod.net and log in with your Labymod account
  2. Press F12 on your keyboard (or Right-click the page and select "Inspect Element") to open Developer Tools
  3. Click on the Storage tab.
  4. Cookies should already be expanded and selected, but if it isn't; expand it and select https://www.labymod.net
  5. Using the search bar called 'Filter items', type: PHPSESSID
  6. Copy Value(PHPSESSID) from the filtered table. If nothing comes up; try navigating to another page on labymod.net
  7. Close Developer Tools

Safari

  1. Open labymod.net and log in with your Labymod account
  2. Right-click the page and select "Inspect Element" (or ⌥ Option+⌘ Command+I) to open Web Inspector
  3. Click on the Storage tab.
  4. Expand Cookies in the sidebar and select labymod.net
  5. Find PHPSESSID in the table under the 'Name' column
  6. Copy Value(PHPSESSID) from the filtered table. If nothing comes up; try navigating to another page on labymod.net
  7. Close Web Inspector

Supported cosmetics

Labymod cosmetic labylib module name
Cloak Cape