fix(media-releases): support more media type mappings for jellyfin and emby (#4382)
This commit is contained in:
@@ -11,7 +11,7 @@ import type { TestingResult } from "../base/test-connection/test-connection-serv
|
|||||||
import type { IMediaServerIntegration } from "../interfaces/media-server/media-server-integration";
|
import type { IMediaServerIntegration } from "../interfaces/media-server/media-server-integration";
|
||||||
import type { CurrentSessionsInput, StreamSession } from "../interfaces/media-server/media-server-types";
|
import type { CurrentSessionsInput, StreamSession } from "../interfaces/media-server/media-server-types";
|
||||||
import { convertJellyfinType } from "../jellyfin/jellyfin-integration";
|
import { convertJellyfinType } from "../jellyfin/jellyfin-integration";
|
||||||
import type { IMediaReleasesIntegration, MediaRelease } from "../types";
|
import type { IMediaReleasesIntegration, MediaRelease, MediaType } from "../types";
|
||||||
|
|
||||||
const sessionSchema = z.object({
|
const sessionSchema = z.object({
|
||||||
NowPlayingItem: z
|
NowPlayingItem: z
|
||||||
@@ -163,7 +163,7 @@ export class EmbyIntegration extends Integration implements IMediaServerIntegrat
|
|||||||
|
|
||||||
return items.map((item) => ({
|
return items.map((item) => ({
|
||||||
id: item.Id,
|
id: item.Id,
|
||||||
type: item.Type === "Movie" ? "movie" : item.Type === "Series" ? "tv" : "unknown",
|
type: this.mapMediaReleaseType(item.Type),
|
||||||
title: item.Name,
|
title: item.Name,
|
||||||
subtitle: item.Taglines.at(0),
|
subtitle: item.Taglines.at(0),
|
||||||
description: item.Overview,
|
description: item.Overview,
|
||||||
@@ -179,6 +179,27 @@ export class EmbyIntegration extends Integration implements IMediaServerIntegrat
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private mapMediaReleaseType(type: string | undefined): MediaType {
|
||||||
|
switch (type) {
|
||||||
|
case "Audio":
|
||||||
|
case "AudioBook":
|
||||||
|
case "MusicAlbum":
|
||||||
|
return "music";
|
||||||
|
case "Book":
|
||||||
|
return "book";
|
||||||
|
case "Episode":
|
||||||
|
case "Series":
|
||||||
|
case "Season":
|
||||||
|
return "tv";
|
||||||
|
case "Movie":
|
||||||
|
return "movie";
|
||||||
|
case "Video":
|
||||||
|
return "video";
|
||||||
|
default:
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// https://dev.emby.media/reference/RestAPI/UserService/getUsersPublic.html
|
// https://dev.emby.media/reference/RestAPI/UserService/getUsersPublic.html
|
||||||
private async fetchUsersPublicAsync(): Promise<{ id: string; name: string }[]> {
|
private async fetchUsersPublicAsync(): Promise<{ id: string; name: string }[]> {
|
||||||
const apiKey = super.getSecretValue("apiKey");
|
const apiKey = super.getSecretValue("apiKey");
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { Integration } from "../base/integration";
|
|||||||
import type { TestingResult } from "../base/test-connection/test-connection-service";
|
import type { TestingResult } from "../base/test-connection/test-connection-service";
|
||||||
import type { IMediaServerIntegration } from "../interfaces/media-server/media-server-integration";
|
import type { IMediaServerIntegration } from "../interfaces/media-server/media-server-integration";
|
||||||
import type { CurrentSessionsInput, StreamSession } from "../interfaces/media-server/media-server-types";
|
import type { CurrentSessionsInput, StreamSession } from "../interfaces/media-server/media-server-types";
|
||||||
import type { IMediaReleasesIntegration, MediaRelease } from "../types";
|
import type { IMediaReleasesIntegration, MediaRelease, MediaType } from "../types";
|
||||||
|
|
||||||
@HandleIntegrationErrors([integrationAxiosHttpErrorHandler])
|
@HandleIntegrationErrors([integrationAxiosHttpErrorHandler])
|
||||||
export class JellyfinIntegration extends Integration implements IMediaServerIntegration, IMediaReleasesIntegration {
|
export class JellyfinIntegration extends Integration implements IMediaServerIntegration, IMediaReleasesIntegration {
|
||||||
@@ -122,7 +122,7 @@ export class JellyfinIntegration extends Integration implements IMediaServerInte
|
|||||||
return result.data.map((item) => ({
|
return result.data.map((item) => ({
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
id: item.Id!,
|
id: item.Id!,
|
||||||
type: item.Type === "Movie" ? "movie" : item.Type === "Series" ? "tv" : "unknown",
|
type: this.mapMediaReleaseType(item.Type),
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
title: item.Name!,
|
title: item.Name!,
|
||||||
subtitle: item.Taglines?.at(0),
|
subtitle: item.Taglines?.at(0),
|
||||||
@@ -140,6 +140,27 @@ export class JellyfinIntegration extends Integration implements IMediaServerInte
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private mapMediaReleaseType(type: BaseItemKind | undefined): MediaType {
|
||||||
|
switch (type) {
|
||||||
|
case "Audio":
|
||||||
|
case "AudioBook":
|
||||||
|
case "MusicAlbum":
|
||||||
|
return "music";
|
||||||
|
case "Book":
|
||||||
|
return "book";
|
||||||
|
case "Episode":
|
||||||
|
case "Series":
|
||||||
|
case "Season":
|
||||||
|
return "tv";
|
||||||
|
case "Movie":
|
||||||
|
return "movie";
|
||||||
|
case "Video":
|
||||||
|
return "video";
|
||||||
|
default:
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an ApiClient synchronously with an ApiKey or asynchronously
|
* Constructs an ApiClient synchronously with an ApiKey or asynchronously
|
||||||
* with a username and password.
|
* with a username and password.
|
||||||
|
|||||||
Reference in New Issue
Block a user