Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions packages/integrations/src/emby/emby-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 { CurrentSessionsInput, StreamSession } from "../interfaces/media-server/media-server-types";
import { convertJellyfinType } from "../jellyfin/jellyfin-integration";
import type { IMediaReleasesIntegration, MediaRelease } from "../types";
import type { IMediaReleasesIntegration, MediaRelease, MediaType } from "../types";

const sessionSchema = z.object({
NowPlayingItem: z
Expand Down Expand Up @@ -163,7 +163,7 @@ export class EmbyIntegration extends Integration implements IMediaServerIntegrat

return items.map((item) => ({
id: item.Id,
type: item.Type === "Movie" ? "movie" : item.Type === "Series" ? "tv" : "unknown",
type: this.mapMediaReleaseType(item.Type),
title: item.Name,
subtitle: item.Taglines.at(0),
description: item.Overview,
Expand All @@ -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
private async fetchUsersPublicAsync(): Promise<{ id: string; name: string }[]> {
const apiKey = super.getSecretValue("apiKey");
Expand Down
25 changes: 23 additions & 2 deletions packages/integrations/src/jellyfin/jellyfin-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Integration } from "../base/integration";
import type { TestingResult } from "../base/test-connection/test-connection-service";
import type { IMediaServerIntegration } from "../interfaces/media-server/media-server-integration";
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])
export class JellyfinIntegration extends Integration implements IMediaServerIntegration, IMediaReleasesIntegration {
Expand Down Expand Up @@ -122,7 +122,7 @@ export class JellyfinIntegration extends Integration implements IMediaServerInte
return result.data.map((item) => ({
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
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
title: item.Name!,
subtitle: item.Taglines?.at(0),
Expand All @@ -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
* with a username and password.
Expand Down