diff --git a/backend/plugins/jellyfin.plugin/src/generate-openapi.ts b/backend/plugins/jellyfin.plugin/src/generate-openapi.ts index b8f78ca..0a3c819 100644 --- a/backend/plugins/jellyfin.plugin/src/generate-openapi.ts +++ b/backend/plugins/jellyfin.plugin/src/generate-openapi.ts @@ -1,7 +1,6 @@ import { generateApi } from 'swagger-typescript-api'; import * as path from 'path'; -console.log(path.join(require.main.path, '..', 'plugins')); generateApi({ name: 'jellyfin.openapi.ts', url: 'https://api.jellyfin.org/openapi/jellyfin-openapi-stable.json', diff --git a/backend/plugins/jellyfin.plugin/src/index.ts b/backend/plugins/jellyfin.plugin/src/index.ts index 60c5908..3038305 100644 --- a/backend/plugins/jellyfin.plugin/src/index.ts +++ b/backend/plugins/jellyfin.plugin/src/index.ts @@ -219,6 +219,14 @@ export default class JellyfinPlugin implements SourcePlugin { }); } + getEpisodeStreams: ( + tmdbId: string, + season: number, + episode: number, + context: UserContext, + config?: PlaybackConfig, + ) => Promise; + async getMovieStream( tmdbId: string, key: string, @@ -396,7 +404,7 @@ export default class JellyfinPlugin implements SourcePlugin { } class PluginContext { - api: JellyfinApi<{}>; + api: JellyfinApi; settings: JellyfinSettings; token: string; diff --git a/backend/plugins/plugin-types.ts b/backend/plugins/plugin-types.ts index 0d9def7..cf22f05 100644 --- a/backend/plugins/plugin-types.ts +++ b/backend/plugins/plugin-types.ts @@ -142,8 +142,18 @@ export interface SourcePlugin { tmdbId: string, season: number, episode: number, - settings: PluginSettings, - ) => Promise; + key: string, + context: UserContext, + config?: PlaybackConfig, + ) => Promise; + + getEpisodeStreams: ( + tmdbId: string, + season: number, + episode: number, + context: UserContext, + config?: PlaybackConfig, + ) => Promise; // handleProxy( // request: { uri: string; headers: any }, @@ -156,7 +166,7 @@ export interface SourcePlugin { proxyHandler?: ( req: any, res: any, - options: { context: UserContext; uri: string, targetUrl?: string }, + options: { context: UserContext; uri: string; targetUrl?: string }, ) => Promise; } diff --git a/backend/src/common/common.dto.ts b/backend/src/common/common.dto.ts index 528b4cb..af0ccf3 100644 --- a/backend/src/common/common.dto.ts +++ b/backend/src/common/common.dto.ts @@ -1,6 +1,23 @@ -import { ApiProperty } from '@nestjs/swagger'; +import { Type } from '@nestjs/common'; +import { + ApiProperty, + IntersectionType, + OmitType, + PartialType, + PickType, +} from '@nestjs/swagger'; import { PaginatedResponse, PaginationParams } from 'plugins/plugin-types'; +export const PickAndPartial = ( + clazz: Type, + pick: K[] = [], + partial: K[] = [], +) => + IntersectionType( + OmitType(PickType(clazz, pick), partial), + PickType(PartialType(clazz), partial), + ); + export class PaginatedResponseDto implements PaginatedResponse { @ApiProperty() total: number; @@ -26,4 +43,4 @@ export class PaginationParamsDto implements PaginationParams { export class SuccessResponseDto { @ApiProperty() success: boolean; -} \ No newline at end of file +} diff --git a/backend/src/metadata/tmdb/tmdb.controller.ts b/backend/src/metadata/tmdb/tmdb.controller.ts index 9ffa195..9e110fe 100644 --- a/backend/src/metadata/tmdb/tmdb.controller.ts +++ b/backend/src/metadata/tmdb/tmdb.controller.ts @@ -74,12 +74,12 @@ export class TmdbController { }); if (cached && req.method === 'GET') { - console.log('returning cached response', uri); + // console.log('returning cached response', uri); res.json(cached); return cached; } - console.log('TMDB PROXY', req.url); + // console.log('TMDB PROXY', req.url); // if (params[0].match(/^3\/movie\/\d+\/?$/)) { // // console.log('req.params', req.params); diff --git a/backend/src/users/user-sources/user-source.dto.ts b/backend/src/users/user-sources/user-source.dto.ts index 042db6b..09890d3 100644 --- a/backend/src/users/user-sources/user-source.dto.ts +++ b/backend/src/users/user-sources/user-source.dto.ts @@ -7,16 +7,7 @@ import { } from '@nestjs/swagger'; import { MediaSource } from './user-source.entity'; import { Type } from '@nestjs/common'; - -const PickAndPartial = ( - clazz: Type, - pick: K[] = [], - partial: K[] = [], -) => - IntersectionType( - OmitType(PickType(clazz, pick), partial), - PickType(PartialType(clazz), partial), - ); +import { PickAndPartial } from 'src/common/common.dto'; export class SourceDto extends PickAndPartial( MediaSource, diff --git a/src/lib/pages/MoviePage/MoviePage.svelte b/src/lib/pages/MoviePage/MoviePage.svelte index 31ff1fc..980dd77 100644 --- a/src/lib/pages/MoviePage/MoviePage.svelte +++ b/src/lib/pages/MoviePage/MoviePage.svelte @@ -191,8 +191,9 @@ } }); } else if (numberOfStreams === 1) { - const sourceId = awaited[0]?.source.id; - const key = awaited[0]?.streams[0]?.key; + const asd = awaited.find((p) => p.streams.length > 0); + const sourceId = asd?.source.id; + const key = asd?.streams[0]?.key; movieUserData.then((userData) => playerState.streamMovie(id, userData, sourceId, key)); }