Skip to content
Closed
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
20 changes: 20 additions & 0 deletions jellyseerr-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,9 @@ components:
is4k:
type: boolean
example: false
isAnime:
type: boolean
example: false
minimumAvailability:
type: string
example: 'In Cinema'
Expand All @@ -492,6 +495,7 @@ components:
- activeProfileName
- activeDirectory
- is4k
- isAnime
- minimumAvailability
- isDefault
SonarrSettings:
Expand Down Expand Up @@ -546,6 +550,9 @@ components:
is4k:
type: boolean
example: false
isAnime:
type: boolean
example: false
enableSeasonFolders:
type: boolean
example: false
Expand All @@ -571,6 +578,7 @@ components:
- activeProfileName
- activeDirectory
- is4k
- isAnime
- enableSeasonFolders
- isDefault
ServarrTag:
Expand Down Expand Up @@ -1135,6 +1143,9 @@ components:
is4k:
type: boolean
example: false
isAnime:
type: boolean
example: false
serverId:
type: number
profileId:
Expand Down Expand Up @@ -5743,6 +5754,9 @@ paths:
is4k:
type: boolean
example: false
isAnime:
type: boolean
example: false
serverId:
type: number
profileId:
Expand Down Expand Up @@ -5847,6 +5861,9 @@ paths:
is4k:
type: boolean
example: false
isAnime:
type: boolean
example: false
serverId:
type: number
profileId:
Expand Down Expand Up @@ -6505,6 +6522,9 @@ paths:
is4k:
type: boolean
example: false
isAnime:
type: boolean
example: false
responses:
'200':
description: Returned media
Expand Down
68 changes: 51 additions & 17 deletions server/entity/MediaRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export class MediaRequest {
.leftJoin('request.media', 'media')
.leftJoinAndSelect('request.requestedBy', 'user')
.where('request.is4k = :is4k', { is4k: requestBody.is4k })
.andWhere('request.isAnime = :isAnime', { isAnime: requestBody.isAnime })
.andWhere('media.tmdbId = :tmdbId', { tmdbId: tmdbMedia.id })
.andWhere('media.mediaType = :mediaType', {
mediaType: requestBody.mediaType,
Expand All @@ -187,6 +188,7 @@ export class MediaRequest {
tmdbId: tmdbMedia.id,
mediaType: requestBody.mediaType,
is4k: requestBody.is4k,
isAnime: requestBody.isAnime,
label: 'Media Request',
});

Expand Down Expand Up @@ -373,6 +375,7 @@ export class MediaRequest {
? user
: undefined,
is4k: requestBody.is4k,
isAnime: requestBody.isAnime,
serverId: requestBody.serverId,
profileId: profileId,
rootFolder: rootFolder,
Expand Down Expand Up @@ -404,6 +407,7 @@ export class MediaRequest {
.filter(
(request) =>
request.is4k === requestBody.is4k &&
request.isAnime === requestBody.isAnime &&
request.status !== MediaRequestStatus.DECLINED
)
.reduce((seasons, request) => {
Expand Down Expand Up @@ -478,6 +482,7 @@ export class MediaRequest {
? user
: undefined,
is4k: requestBody.is4k,
isAnime: requestBody.isAnime,
serverId: requestBody.serverId,
profileId: profileId,
rootFolder: rootFolder,
Expand Down Expand Up @@ -558,6 +563,9 @@ export class MediaRequest {
@Column({ default: false })
public is4k: boolean;

@Column({ default: false })
public isAnime: boolean;

@Column({ nullable: true })
public serverId: number;

Expand Down Expand Up @@ -820,9 +828,20 @@ export class MediaRequest {
}

let radarrSettings = settings.radarr.find(
(radarr) => radarr.isDefault && radarr.is4k === this.is4k
(radarr) =>
radarr.isDefault &&
radarr.is4k === this.is4k &&
radarr.isAnime === this.isAnime
);

// Fallback for requesting anime if there is no default anime server
// This will sent the anime request to the regular default Radarr instance for single-instance setups
if (!radarrSettings && this.isAnime) {
radarrSettings = settings.radarr.find(
(radarr) => radarr.isDefault && radarr.is4k === this.is4k
);
}

if (
this.serverId !== null &&
this.serverId >= 0 &&
Expand All @@ -844,9 +863,9 @@ export class MediaRequest {
if (!radarrSettings) {
logger.warn(
`There is no default ${
this.is4k ? '4K ' : ''
this.isAnime ? 'Anime ' : this.is4k ? '4K ' : ''
}Radarr server configured. Did you set any of your ${
this.is4k ? '4K ' : ''
this.isAnime ? 'Anime ' : this.is4k ? '4K ' : ''
}Radarr servers as default?`,
{
label: 'Media Request',
Expand Down Expand Up @@ -1069,9 +1088,20 @@ export class MediaRequest {
}

let sonarrSettings = settings.sonarr.find(
(sonarr) => sonarr.isDefault && sonarr.is4k === this.is4k
(sonarr) =>
sonarr.isDefault &&
sonarr.is4k === this.is4k &&
sonarr.isAnime == this.isAnime
);

// Fallback for requesting anime if there is no default anime server
// This will sent the anime request to the regular default Sonarr instance for single-instance setups
if (!sonarrSettings && this.isAnime) {
sonarrSettings = settings.sonarr.find(
(sonarr) => sonarr.isDefault && sonarr.is4k === this.is4k
);
}

if (
this.serverId !== null &&
this.serverId >= 0 &&
Expand All @@ -1093,9 +1123,9 @@ export class MediaRequest {
if (!sonarrSettings) {
logger.warn(
`There is no default ${
this.is4k ? '4K ' : ''
this.isAnime ? 'Anime ' : this.is4k ? '4K ' : ''
}Sonarr server configured. Did you set any of your ${
this.is4k ? '4K ' : ''
this.isAnime ? 'Anime ' : this.is4k ? '4K ' : ''
}Sonarr servers as default?`,
{
label: 'Media Request',
Expand Down Expand Up @@ -1149,11 +1179,7 @@ export class MediaRequest {
let seriesType: SonarrSeries['seriesType'] = 'standard';

// Change series type to anime if the anime keyword is present on tmdb
if (
series.keywords.results.some(
(keyword) => keyword.id === ANIME_KEYWORD_ID
)
) {
if (this.isAnime) {
seriesType = sonarrSettings.animeSeriesType ?? 'anime';
}

Expand Down Expand Up @@ -1355,30 +1381,38 @@ export class MediaRequest {

switch (type) {
case Notification.MEDIA_APPROVED:
event = `${this.is4k ? '4K ' : ''}${mediaType} Request Approved`;
event = `${
this.isAnime ? 'Anime ' : this.is4k ? '4K ' : ''
}${mediaType} Request Approved`;
notifyAdmin = false;
break;
case Notification.MEDIA_DECLINED:
event = `${this.is4k ? '4K ' : ''}${mediaType} Request Declined`;
event = `${
this.isAnime ? 'Anime ' : this.is4k ? '4K ' : ''
}${mediaType} Request Declined`;
notifyAdmin = false;
break;
case Notification.MEDIA_PENDING:
event = `New ${this.is4k ? '4K ' : ''}${mediaType} Request`;
event = `New ${
this.isAnime ? 'Anime ' : this.is4k ? '4K ' : ''
}${mediaType} Request`;
break;
case Notification.MEDIA_AUTO_REQUESTED:
event = `${
this.is4k ? '4K ' : ''
this.isAnime ? 'Anime ' : this.is4k ? '4K ' : ''
}${mediaType} Request Automatically Submitted`;
notifyAdmin = false;
notifySystem = false;
break;
case Notification.MEDIA_AUTO_APPROVED:
event = `${
this.is4k ? '4K ' : ''
this.isAnime ? 'Anime ' : this.is4k ? '4K ' : ''
}${mediaType} Request Automatically Approved`;
break;
case Notification.MEDIA_FAILED:
event = `${this.is4k ? '4K ' : ''}${mediaType} Request Failed`;
event = `${
this.isAnime ? 'Anime ' : this.is4k ? '4K ' : ''
}${mediaType} Request Failed`;
break;
}

Expand Down
1 change: 1 addition & 0 deletions server/interfaces/api/requestInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type MediaRequestBody = {
tvdbId?: number;
seasons?: number[] | 'all';
is4k?: boolean;
isAnime?: boolean;
serverId?: number;
profileId?: number;
profileName?: string;
Expand Down
1 change: 1 addition & 0 deletions server/interfaces/api/serviceInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface ServiceCommonServer {
id: number;
name: string;
is4k: boolean;
isAnime: boolean;
isDefault: boolean;
activeProfileId: number;
activeDirectory: string;
Expand Down
1 change: 1 addition & 0 deletions server/lib/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export interface DVRSettings {
activeDirectory: string;
tags: number[];
is4k: boolean;
isAnime: boolean;
isDefault: boolean;
externalUrl?: string;
syncEnabled: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type { MigrationInterface, QueryRunner } from 'typeorm';

export class AddMediaRequestIsAnimeField1742938382322
implements MigrationInterface
{
name = 'AddMediaRequestIsAnimeField1742938382322';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "media_request" ADD "isAnime" boolean NOT NULL DEFAULT false`
);
await queryRunner.query(
`ALTER TABLE "user_push_subscription" ADD "userAgent" character varying`
);
await queryRunner.query(
`ALTER TABLE "user_push_subscription" ADD "createdAt" TIMESTAMP DEFAULT now()`
);
await queryRunner.query(
`ALTER TABLE "user_push_subscription" DROP CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b"`
);
Comment on lines +12 to +20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's up with these schema changes? Seems unrelated to this PR?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea, I did not make those changes, sorry.

}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "user_push_subscription" ADD CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth")`
);
await queryRunner.query(
`ALTER TABLE "user_push_subscription" DROP COLUMN "createdAt"`
);
await queryRunner.query(
`ALTER TABLE "user_push_subscription" DROP COLUMN "userAgent"`
);
await queryRunner.query(
`ALTER TABLE "media_request" DROP COLUMN "isAnime"`
);
}
}
Loading
Loading