Work in progress; Change visibility of cosmetics with 'Visibility()' Currently not working. Getting HTTP Conflict response from endpoint. Needs further investigation |
||
---|---|---|
labylib | ||
.gitignore | ||
__init__.py | ||
LICENSE | ||
README.md |
labylib
Cosmetics API for Labymod
Set and update Labymod cosmetics programmatically.
Created by VicW |
---|
Installation
- Download and install Python 3.x.x for your computer's architecture
- 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
- 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:
Find your PHPSESSID
-cookie
Instructions for your browser:
Chrome
- Open labymod.net and log in with your Labymod account
- Press F12 on your keyboard (or Ctrl+⇧ Shift+I) to open DevTools
- Click on the
Application
tab. - Expand
Cookies
under theStorage
cateogry in the sidebar and selecthttps://www.labymod.net/
- Type
PHPSESSID
into the search box called 'Filter' - Copy
Value
(PHPSESSID) from the filtered table. If nothing comes up; try navigating to another page on labymod.net - Close DevTools
Firefox
- Open labymod.net and log in with your Labymod account
- Press F12 on your keyboard (or Right-click the page and select "Inspect Element") to open Developer Tools
- Click on the
Storage
tab. Cookies
should already be expanded and selected, but if it isn't; expand it and selecthttps://www.labymod.net
- Using the search bar called 'Filter items', type:
PHPSESSID
- Copy
Value
(PHPSESSID) from the filtered table. If nothing comes up; try navigating to another page on labymod.net - Close Developer Tools
Safari
- Open labymod.net and log in with your Labymod account
- Right-click the page and select "Inspect Element" (or ⌥ Option+⌘ Command+I) to open Web Inspector
- Click on the
Storage
tab. - Expand
Cookies
in the sidebar and selectlabymod.net
- Find
PHPSESSID
in the table under the 'Name' column - Copy
Value
(PHPSESSID) from the filtered table. If nothing comes up; try navigating to another page on labymod.net - Close Web Inspector
Supported cosmetics
Labymod cosmetic | labylib module name |
---|---|
Cloak | Cape |