refactor: pretty much the whole backend module hierarchy

This commit is contained in:
Aleksi Lassila
2025-02-11 02:40:41 +02:00
parent 6969525464
commit fa27f19975
96 changed files with 1786 additions and 2033 deletions

View File

@@ -39,8 +39,8 @@ export default class JellyfinPluginProvider extends PluginProvider {
class JellyfinProvider extends SourceProvider {
name: string = 'jellyfin';
private get proxyUrl() {
return `/api/sources/${this.name}/proxy`;
private getProxyUrl(sourceId: string) {
return `/api/sources/${sourceId}/proxy`;
}
settingsManager: SettingsManager = new JellyfinSettingsManager();
@@ -177,7 +177,7 @@ class JellyfinProvider extends SourceProvider {
const mediasSource = playbackInfo.data?.MediaSources?.[0];
const playbackUri =
this.proxyUrl +
this.getProxyUrl(userContext.sourceId) +
(mediasSource?.TranscodingUrl ||
`/Videos/${mediasSource?.Id}/stream.mp4?Static=true&mediaSourceId=${mediasSource?.Id}&deviceId=${JELLYFIN_DEVICE_ID}&api_key=${context.settings.apiKey}&Tag=${mediasSource?.ETag}`) +
`&reiverr_token=${userContext.token}`;
@@ -209,7 +209,8 @@ class JellyfinProvider extends SourceProvider {
(s) => s.Type === 'Subtitle' && s.DeliveryUrl,
).map((s, i) => ({
src:
this.proxyUrl + `${s.DeliveryUrl}&reiverr_token=${userContext.token}`,
this.getProxyUrl(userContext.sourceId) +
`${s.DeliveryUrl}&reiverr_token=${userContext.token}`,
lang: s.Language,
kind: 'subtitles',
label: s.DisplayTitle,
@@ -335,7 +336,7 @@ class JellyfinProvider extends SourceProvider {
const mediasSource = playbackInfo.data?.MediaSources?.[0];
const playbackUri =
this.proxyUrl +
this.getProxyUrl(userContext.sourceId) +
(mediasSource?.TranscodingUrl ||
`/Videos/${mediasSource?.Id}/stream.mp4?Static=true&mediaSourceId=${mediasSource?.Id}&deviceId=${JELLYFIN_DEVICE_ID}&api_key=${context.settings.apiKey}&Tag=${mediasSource?.ETag}`) +
`&reiverr_token=${userContext.token}`;
@@ -367,7 +368,8 @@ class JellyfinProvider extends SourceProvider {
(s) => s.Type === 'Subtitle' && s.DeliveryUrl,
).map((s, i) => ({
src:
this.proxyUrl + `${s.DeliveryUrl}&reiverr_token=${userContext.token}`,
this.getProxyUrl(userContext.sourceId) +
`${s.DeliveryUrl}&reiverr_token=${userContext.token}`,
lang: s.Language,
kind: 'subtitles',
label: s.DisplayTitle,

View File

@@ -4,7 +4,6 @@ import {
} from '@aleksilassila/reiverr-plugin';
import { Api as JellyfinApi } from './jellyfin.openapi';
import { JELLYFIN_DEVICE_ID } from './utils';
import { PluginSettings } from 'plugins/plugin-types';
export interface JellyfinSettings extends SourceProviderSettings {
apiKey: string;
@@ -21,7 +20,7 @@ export class PluginContext {
settings: JellyfinSettings;
token: string;
constructor(settings: PluginSettings, token = '') {
constructor(settings: SourceProviderSettings, token = '') {
this.token = token;
this.settings = settings as JellyfinSettings;
this.api = new JellyfinApi({