Helpers
$replace
The $replace
function is used to overwrite properties of an object within an event.
$app.onGetAnime((e) => {
if(e.anime.id === 130003) {
console.log(e.anime.title) // { "english": "Bocchi the Rock!", "romaji": "Bocchi the Rock!", "userPreferred": "Bocchi the Rock!" }
// ⚠️ This will only replace the 'english' property
e.anime.title = { "english": "The One Piece is Real" }
console.log(e.anime.title) // { "english": "The One Piece is Real", "romaji": "Bocchi the Rock!", "userPreferred": "Bocchi the Rock!" }
// ✅ This replaces the entire 'title' object
$replace(e.anime.title, { "english": "The One Piece is Real" })
console.log(e.anime.title) // { "english": "The One Piece is Real" }
e.anime.synonyms[0] = "The One Piece" // ✅ Works
$replace(e.anime.synonyms[0], "The One Piece") // ✅ Works
}
e.next();
})
$app.onGetAnime((e) => {
if(e.anime.id === 130003) {
e.anime.id = 21; // ✅
$replace(e.anime.id, 22) // ⛔️ Doesn't work because under the hood 'id' is not a reference.
console.log(e.anime.id) // 21
}
e.next();
})
$app
$app.getVersion() // "2.8.0"
$app.getVersionName() // "Gold"
// Invalidate certain queries to cause the client to refetch them automatically
// Find the query keys here: https://github.com/5rahim/seanime/blob/main/internal/events/endpoints.go
$app.invalidateClientQuery([])
$toString
Converts binary data to string.
const uint8Array = new Uint8Array(new ArrayBuffer(5));
uint8Array[0] = 104;
uint8Array[1] = 101;
uint8Array[2] = 108;
uint8Array[3] = 108;
uint8Array[4] = 111;
console.log($toString(uint8Array)); // hello
$toBytes
Similar to the Web API TextEncoder.encode
const b = $toBytes("hello")
console.log(b); // Uint8Array [104, 101, 108, 108, 111]
console($toString(b)); // hello
$sleep
Use carefully
// sleeps for 1s
$sleep(1000)
$habari
Filename parser
data := $habari.parse("Hyouka (2012) S1-2 [BD 1080p HEVC OPUS] [Dual-Audio]")
console.log(data.title) // Hyouka
console.log(data.formatted_title) // Hyouka (2012)
console.log(data.year) // 2012
console.log(data.season_number) // ["1", "2"]
console.log(data.video_resolution) // 1080p
Last updated