use yavin to get random movies
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
import { GuildMember } from "discord.js";
|
||||
import { Config } from "../configuration";
|
||||
import { Maybe, PermissionLevel } from "../interfaces";
|
||||
import { JellyfinConfig, Maybe, PermissionLevel } from "../interfaces";
|
||||
import { logger } from "../logger";
|
||||
import { CreateUserByNameOperationRequest, DeleteUserRequest, GetItemsRequest, ItemsApi, SystemApi, UpdateUserPasswordOperationRequest, UpdateUserPolicyOperationRequest, UserApi } from "./apis";
|
||||
import { BaseItemDto, UpdateUserPasswordRequest } from "./models";
|
||||
@ -15,34 +14,27 @@ export class JellyfinHandler {
|
||||
private moviesApi: ItemsApi
|
||||
private token: string
|
||||
private authHeader: { headers: { 'X-Emby-Authorization': string } }
|
||||
private config: Config
|
||||
private config: JellyfinConfig
|
||||
private serverName = "";
|
||||
|
||||
public async ServerName(): Promise<string> {
|
||||
if (this.serverName === "") {
|
||||
const info = await this.systemApi.getSystemInfo(this.authHeader)
|
||||
this.serverName = info.serverName ?? this.config.bot.jellyfin_url
|
||||
}
|
||||
return this.serverName
|
||||
}
|
||||
constructor(_config: Config, _userApi?: UserApi, _systemApi?: SystemApi, _itemsApi?: ItemsApi) {
|
||||
constructor(_config: JellyfinConfig, _userApi?: UserApi, _systemApi?: SystemApi, _itemsApi?: ItemsApi) {
|
||||
this.config = _config
|
||||
this.token = this.config.bot.jellfin_token
|
||||
this.token = this.config.jellyfinToken
|
||||
this.authHeader = {
|
||||
headers: {
|
||||
"X-Emby-Authorization": this.config.bot.workaround_token
|
||||
"X-Emby-Authorization": this.config.jellyfinToken
|
||||
}
|
||||
}
|
||||
const userApiConfigurationParams: ConfigurationParameters = {
|
||||
basePath: this.config.bot.jellyfin_url,
|
||||
basePath: this.config.jellyfinUrl,
|
||||
headers: this.authHeader.headers
|
||||
}
|
||||
const systemApiConfigurationParams: ConfigurationParameters = {
|
||||
basePath: this.config.bot.jellyfin_url,
|
||||
basePath: this.config.jellyfinUrl,
|
||||
headers: this.authHeader.headers
|
||||
}
|
||||
const libraryApiConfigurationParams: ConfigurationParameters = {
|
||||
basePath: this.config.bot.jellyfin_url,
|
||||
basePath: this.config.jellyfinUrl,
|
||||
headers: this.authHeader.headers
|
||||
}
|
||||
|
||||
@ -228,11 +220,9 @@ export class JellyfinHandler {
|
||||
public async getAllMovies(guildId: string, requestId: string): Promise<BaseItemDto[]> {
|
||||
logger.info("requesting all movies from jellyfin", { guildId, requestId })
|
||||
|
||||
const liloJfUser = await this.getUser(<GuildMember>{ guild: { id: guildId }, displayName: "lilo" }, requestId)
|
||||
|
||||
const searchParams: GetItemsRequest = {
|
||||
userId: liloJfUser?.id,
|
||||
parentId: this.config.bot.jf_collection_id // collection ID for all movies
|
||||
userId: this.config.collectionUser,
|
||||
parentId: this.config.movieCollectionId // collection ID for all movies
|
||||
}
|
||||
const movies = (await (this.moviesApi.getItems(searchParams))).items?.filter(item => !item.isFolder)
|
||||
// logger.debug(JSON.stringify(movies, null, 2), { guildId: guildId, requestId })
|
||||
|
Reference in New Issue
Block a user