Skip to main content

Crate banished_banishedinfo

Crate banished_banishedinfo 

Source
Expand description

Optional banishedinfo.com support for Un-Banished: list and search the site’s Banished mods, read a mod’s versions, and install the .pkm packages of a version. It is not part of the original game.

The site has no public API. Its mod list loads from a JSON address the browse page itself uses (/mods/ajax?action=mods&…), its search page carries its results as JSON in the page (var mods = […]), and a mod’s page links each version (/mods/download/<mod>/<n>), whose file (/mods/file/<mod>/<n>) redirects to the package or archive. No account is needed.

Requests are made only when the player lists, searches or installs, one at a time, with a user agent that names Un-Banished (user_agent). The site sends no CORS headers, so a browser page cannot read it: the support is for native builds (native).

This crate builds the addresses and reads the answers; native sends the requests.

Modules§

native
Sending the requests on native builds (blocking; run them off the main thread in a window), and installing a version.

Structs§

Mod
A mod as the site lists it.
Version
One version of a mod, newest first in parse_versions.

Enums§

Error
What can go wrong.
Sort
The order of the site’s list (its sort values).

Constants§

SECTIONS
The site’s mod sections (section values), or all of them.
SITE
The site.

Functions§

file_name
The file name at the end of a download’s address (/mods/file-download/264/XP-Schools.pkm).
list_url
The address of count mods from start of a section ("" for all), in an order.
parse_list
Read the answer of list_url: a JSON list of mods (empty past the end).
parse_search
Read the search page of search_url: the results it carries as var mods = […];.
parse_versions
Read a mod’s page (Mod::page): its versions, newest first, from the links /mods/download/<id>-<name>/<n>">Download version <label> (the page of mod id).
search_url
The address of the site’s search for text.
user_agent
The user agent sent with every request: the application, its version and where it lives.