Compare commits
No commits in common. "2fae61fc1fb1bc77965816f2eb6f590a90e0cb63" and "8caf80f54ebc8dacfc91b9b35c74234779df81e4" have entirely different histories.
2fae61fc1f
...
8caf80f54e
3
index.ts
3
index.ts
@ -5,8 +5,7 @@ import { JellyfinHandler } from "./server/jellyfin/handler"
|
||||
import { attachedImages } from "./server/assets/attachments"
|
||||
const requestId = 'startup'
|
||||
|
||||
export const jellyfinHandler = new JellyfinHandler({jellyfinToken: config.bot.workaround_token, jellyfinUrl: config.bot.jellyfin_url, movieCollectionId: config.bot.jf_collection_id, collectionUser: config.bot.jf_user})
|
||||
export const yavinJellyfinHandler = new JellyfinHandler({jellyfinToken: config.bot.yavin_jellyfin_token, jellyfinUrl: config.bot.yavin_jellyfin_url, movieCollectionId: config.bot.yavin_collection_id, collectionUser: config.bot.yavin_jellyfin_collection_user})
|
||||
export const jellyfinHandler = new JellyfinHandler(config)
|
||||
|
||||
export const client = new ExtendedClient(jellyfinHandler)
|
||||
|
||||
|
@ -67,7 +67,7 @@ async function sendInitialAnnouncement(guildId: string, requestId: string): Prom
|
||||
|
||||
const body = `[initial] Hey! @everyone! Hier ist der Watchparty Bot vom Hartzarett.
|
||||
|
||||
Wir machen in Zukunft regelmäßig Watchparties in denen wir zusammen Filme gucken! Falls du mitmachen möchtest, reagiere einfach auf diesen Post mit 🎫, dann bekommst du automatisch eine Rolle zugewiesen und wirst benachrichtigt sobald es in der Zukunft weitere Watchparties und Filme zum abstimmen gibt.
|
||||
Wir machen in Zukunft regelmäßig Watchparties! Falls du mitmachen möchtest, reagiere einfach auf diesen Post mit 🎫, dann bekommst du automatisch eine Rolle zugewiesen und wirst benachrichtigt sobald es in der Zukunft weitere Watchparties und Filme zum abstimmen gibt.
|
||||
|
||||
Für eine Erklärung wie das alles funktioniert mach einfach /mitgucken für eine lange Erklärung am Stück oder /guides wenn du auswählen möchtest wozu du Infos bekommst.`
|
||||
|
||||
|
@ -25,11 +25,6 @@ export interface Config {
|
||||
announcement_role: string
|
||||
announcement_channel_id: string
|
||||
jf_collection_id: string
|
||||
jf_user: string
|
||||
yavin_collection_id: string
|
||||
yavin_jellyfin_url: string
|
||||
yavin_jellyfin_token: string
|
||||
yavin_jellyfin_collection_user: string
|
||||
}
|
||||
}
|
||||
export const config: Config = {
|
||||
@ -64,11 +59,6 @@ export const config: Config = {
|
||||
jf_admin_role: process.env.ADMIN_ROLE ?? "",
|
||||
announcement_role: process.env.WATCHPARTY_ANNOUNCEMENT_ROLE ?? "",
|
||||
announcement_channel_id: process.env.CHANNEL_ID ?? "",
|
||||
jf_collection_id: process.env.JELLYFIN_COLLECTION_ID ?? "",
|
||||
yavin_collection_id: process.env.YAVIN_COLLECTION_ID ?? "",
|
||||
yavin_jellyfin_url: process.env.YAVIN_JELLYFIN_URL ?? "",
|
||||
yavin_jellyfin_token: process.env.YAVIN_TOKEN ?? "",
|
||||
yavin_jellyfin_collection_user: process.env.YAVIN_COLLECTION_USER ?? "",
|
||||
jf_user: process.env.JELLYFIN_USER ?? ""
|
||||
jf_collection_id: process.env.JELLYFIN_COLLECTION_ID ?? ""
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,11 @@ import toDate from "date-fns/fp/toDate";
|
||||
import { GuildScheduledEvent, Message, MessageCreateOptions, TextChannel } from "discord.js";
|
||||
import { ScheduledTask, schedule } from "node-cron";
|
||||
import { v4 as uuid } from "uuid";
|
||||
import { client, yavinJellyfinHandler } from "../..";
|
||||
import { client, jellyfinHandler } from "../..";
|
||||
import { closePoll } from "../commands/closepoll";
|
||||
import { config } from "../configuration";
|
||||
import { Maybe } from "../interfaces";
|
||||
import { logger } from "../logger";
|
||||
import { Maybe } from "../interfaces";
|
||||
|
||||
|
||||
export const name = 'guildScheduledEventCreate'
|
||||
@ -24,7 +24,7 @@ export async function execute(event: GuildScheduledEvent) {
|
||||
logger.info("Event was a placeholder event to start a new watchparty and voting. Creating vote!", { guildId: event.guildId, requestId })
|
||||
logger.debug("Renaming event", { guildId: event.guildId, requestId })
|
||||
event.edit({ name: "Watchparty - Voting offen" })
|
||||
const movies = await yavinJellyfinHandler.getRandomMovies(5, event.guildId, requestId)
|
||||
const movies = await jellyfinHandler.getRandomMovies(5, event.guildId, requestId)
|
||||
|
||||
logger.info(`Got ${movies.length} random movies. Creating voting`, { guildId: event.guildId, requestId })
|
||||
logger.debug(`Movies: ${JSON.stringify(movies.map(movie => movie.name))}`, { guildId: event.guildId, requestId })
|
||||
|
@ -32,10 +32,4 @@ export interface ChangedRoles {
|
||||
addedRoles: Collection<string, Role>
|
||||
removedRoles: Collection<string, Role>
|
||||
}
|
||||
export interface JellyfinConfig {
|
||||
jellyfinUrl: string,
|
||||
jellyfinToken: string,
|
||||
movieCollectionId: string,
|
||||
collectionUser: string
|
||||
}
|
||||
export type PermissionLevel = "VIEWER" | "ADMIN" | "TEMPORARY"
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { GuildMember } from "discord.js";
|
||||
import { JellyfinConfig, Maybe, PermissionLevel } from "../interfaces";
|
||||
import { Config } from "../configuration";
|
||||
import { Maybe, PermissionLevel } from "../interfaces";
|
||||
import { logger } from "../logger";
|
||||
import { CreateUserByNameOperationRequest, DeleteUserRequest, GetItemsRequest, ItemsApi, SystemApi, UpdateUserPasswordOperationRequest, UpdateUserPolicyOperationRequest, UserApi } from "./apis";
|
||||
import { BaseItemDto, UpdateUserPasswordRequest } from "./models";
|
||||
@ -14,27 +15,34 @@ export class JellyfinHandler {
|
||||
private moviesApi: ItemsApi
|
||||
private token: string
|
||||
private authHeader: { headers: { 'X-Emby-Authorization': string } }
|
||||
private config: JellyfinConfig
|
||||
private config: Config
|
||||
private serverName = "";
|
||||
|
||||
constructor(_config: JellyfinConfig, _userApi?: UserApi, _systemApi?: SystemApi, _itemsApi?: ItemsApi) {
|
||||
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) {
|
||||
this.config = _config
|
||||
this.token = this.config.jellyfinToken
|
||||
this.token = this.config.bot.jellfin_token
|
||||
this.authHeader = {
|
||||
headers: {
|
||||
"X-Emby-Authorization": this.config.jellyfinToken
|
||||
"X-Emby-Authorization": this.config.bot.workaround_token
|
||||
}
|
||||
}
|
||||
const userApiConfigurationParams: ConfigurationParameters = {
|
||||
basePath: this.config.jellyfinUrl,
|
||||
basePath: this.config.bot.jellyfin_url,
|
||||
headers: this.authHeader.headers
|
||||
}
|
||||
const systemApiConfigurationParams: ConfigurationParameters = {
|
||||
basePath: this.config.jellyfinUrl,
|
||||
basePath: this.config.bot.jellyfin_url,
|
||||
headers: this.authHeader.headers
|
||||
}
|
||||
const libraryApiConfigurationParams: ConfigurationParameters = {
|
||||
basePath: this.config.jellyfinUrl,
|
||||
basePath: this.config.bot.jellyfin_url,
|
||||
headers: this.authHeader.headers
|
||||
}
|
||||
|
||||
@ -220,9 +228,11 @@ 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: this.config.collectionUser,
|
||||
parentId: this.config.movieCollectionId // collection ID for all movies
|
||||
userId: liloJfUser?.id,
|
||||
parentId: this.config.bot.jf_collection_id // 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 })
|
||||
|
@ -33,6 +33,7 @@ export class ExtendedClient extends Client {
|
||||
Promise.all(promises).then(() => {
|
||||
this.login(config.bot.token)
|
||||
})
|
||||
logger.info(`Connected with ${await this.jellyfin.ServerName()}`)
|
||||
}
|
||||
private async importFile(filepath: string): Promise<any> {
|
||||
logger.debug(`Importing ${filepath}`)
|
||||
|
Loading…
Reference in New Issue
Block a user