jellyfin-discord-bot/index.ts

27 lines
934 B
TypeScript

import { ExtendedClient } from "./server/structures/client"
export const client = new ExtendedClient()
import { AuthenticateUserByNameRequest, CreateUserByNameRequest } from "./jellyfin/api"
import { UserApi } from "./jellyfin/api/userApi"
import { config } from "./server/configuration"
client.start()
async function start() {
const jfUserAPI: UserApi = new UserApi(config.jellyfin_url)
const options = {
headers: {
"X-MediaBrowser-Token": config.jellfin_token
}
}
let u = (await jfUserAPI.getUsers(false, false, options)).body
console.log(JSON.stringify(u.map(x => x.name), null, 2))
const user: CreateUserByNameRequest = {
name: "Testuser1",
password: "1234"
}
const a = await jfUserAPI.createUserByName(user, options)
console.log(JSON.stringify(a, null, 2))
u = (await jfUserAPI.getUsers(undefined, undefined, options)).body
console.log(JSON.stringify(u.map(x => x.name), null, 2))
}