Skip to content

Commit 6f3b7ec

Browse files
fix(media-releases): support more media type mappings for jellyfin and emby (#4382)
1 parent bbfc6e4 commit 6f3b7ec

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

packages/integrations/src/emby/emby-integration.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { TestingResult } from "../base/test-connection/test-connection-serv
1111
import type { IMediaServerIntegration } from "../interfaces/media-server/media-server-integration";
1212
import type { CurrentSessionsInput, StreamSession } from "../interfaces/media-server/media-server-types";
1313
import { convertJellyfinType } from "../jellyfin/jellyfin-integration";
14-
import type { IMediaReleasesIntegration, MediaRelease } from "../types";
14+
import type { IMediaReleasesIntegration, MediaRelease, MediaType } from "../types";
1515

1616
const sessionSchema = z.object({
1717
NowPlayingItem: z
@@ -163,7 +163,7 @@ export class EmbyIntegration extends Integration implements IMediaServerIntegrat
163163

164164
return items.map((item) => ({
165165
id: item.Id,
166-
type: item.Type === "Movie" ? "movie" : item.Type === "Series" ? "tv" : "unknown",
166+
type: this.mapMediaReleaseType(item.Type),
167167
title: item.Name,
168168
subtitle: item.Taglines.at(0),
169169
description: item.Overview,
@@ -179,6 +179,27 @@ export class EmbyIntegration extends Integration implements IMediaServerIntegrat
179179
}));
180180
}
181181

182+
private mapMediaReleaseType(type: string | undefined): MediaType {
183+
switch (type) {
184+
case "Audio":
185+
case "AudioBook":
186+
case "MusicAlbum":
187+
return "music";
188+
case "Book":
189+
return "book";
190+
case "Episode":
191+
case "Series":
192+
case "Season":
193+
return "tv";
194+
case "Movie":
195+
return "movie";
196+
case "Video":
197+
return "video";
198+
default:
199+
return "unknown";
200+
}
201+
}
202+
182203
// https://dev.emby.media/reference/RestAPI/UserService/getUsersPublic.html
183204
private async fetchUsersPublicAsync(): Promise<{ id: string; name: string }[]> {
184205
const apiKey = super.getSecretValue("apiKey");

packages/integrations/src/jellyfin/jellyfin-integration.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { Integration } from "../base/integration";
1515
import type { TestingResult } from "../base/test-connection/test-connection-service";
1616
import type { IMediaServerIntegration } from "../interfaces/media-server/media-server-integration";
1717
import type { CurrentSessionsInput, StreamSession } from "../interfaces/media-server/media-server-types";
18-
import type { IMediaReleasesIntegration, MediaRelease } from "../types";
18+
import type { IMediaReleasesIntegration, MediaRelease, MediaType } from "../types";
1919

2020
@HandleIntegrationErrors([integrationAxiosHttpErrorHandler])
2121
export class JellyfinIntegration extends Integration implements IMediaServerIntegration, IMediaReleasesIntegration {
@@ -122,7 +122,7 @@ export class JellyfinIntegration extends Integration implements IMediaServerInte
122122
return result.data.map((item) => ({
123123
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
124124
id: item.Id!,
125-
type: item.Type === "Movie" ? "movie" : item.Type === "Series" ? "tv" : "unknown",
125+
type: this.mapMediaReleaseType(item.Type),
126126
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
127127
title: item.Name!,
128128
subtitle: item.Taglines?.at(0),
@@ -140,6 +140,27 @@ export class JellyfinIntegration extends Integration implements IMediaServerInte
140140
}));
141141
}
142142

143+
private mapMediaReleaseType(type: BaseItemKind | undefined): MediaType {
144+
switch (type) {
145+
case "Audio":
146+
case "AudioBook":
147+
case "MusicAlbum":
148+
return "music";
149+
case "Book":
150+
return "book";
151+
case "Episode":
152+
case "Series":
153+
case "Season":
154+
return "tv";
155+
case "Movie":
156+
return "movie";
157+
case "Video":
158+
return "video";
159+
default:
160+
return "unknown";
161+
}
162+
}
163+
143164
/**
144165
* Constructs an ApiClient synchronously with an ApiKey or asynchronously
145166
* with a username and password.

0 commit comments

Comments
 (0)