Skip to content
Draft
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
9 changes: 9 additions & 0 deletions docs/using-seerr/settings/general.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ When enabled, media that has been blocklisted will not appear on the "Discover"

This setting is **disabled** by default.

## Release Date Restrictions

Enable **Release Date Restrictions** to prevent ordinary users from requesting media before it is released:

- A movie becomes requestable once TMDB lists a Digital release (release type 4) dated today or earlier in any region. Theatrical and physical releases do not make a movie eligible.
- A TV season becomes requestable on its TMDB air date.

Users with the **Manage Requests** permission can bypass the restriction. Media with no valid Digital release date or season air date remains requestable. Release date restrictions are disabled by default and do not change existing requests.
Comment thread
h2nkm5vydg-oss marked this conversation as resolved.

## Allow Partial Series Requests

When enabled, users will be able to submit requests for specific seasons of TV series. If disabled, users will only be able to submit requests for all unavailable seasons.
Expand Down
36 changes: 36 additions & 0 deletions seerr-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ components:
hideAvailable:
type: boolean
example: false
releaseDateRestrictionEnabled:
type: boolean
default: false
description: Prevent non-managers from requesting movies before a Digital release or TV seasons before their air date.
partialRequestsEnabled:
type: boolean
example: false
Expand Down Expand Up @@ -708,6 +712,7 @@ components:
required:
- initialized
- plexClientIdentifier
- releaseDateRestrictionEnabled
properties:
initialized:
type: boolean
Expand All @@ -717,6 +722,9 @@ components:
format: uuid
description: Instance Plex OAuth client identifier
example: 6919275e-142a-48d8-be6b-93594cbd4626
releaseDateRestrictionEnabled:
type: boolean
default: false
MovieResult:
type: object
required:
Expand Down Expand Up @@ -6622,6 +6630,20 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/MediaRequest'
'403':
description: The request is forbidden, including when release date restrictions block it.
content:
application/json:
schema:
type: object
required:
- message
properties:
message:
type: string
description: Release restriction failures use MEDIA_NOT_RELEASED.
example:
message: MEDIA_NOT_RELEASED
/request/count:
get:
summary: Gets request counts
Expand Down Expand Up @@ -6727,6 +6749,20 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/MediaRequest'
'403':
description: The update is forbidden, including when newly added TV seasons are blocked by release date restrictions.
content:
application/json:
schema:
type: object
required:
- message
properties:
message:
type: string
description: Release restriction failures use MEDIA_NOT_RELEASED.
example:
message: MEDIA_NOT_RELEASED
'409':
description: Only pending requests can be modified
delete:
Expand Down
1 change: 1 addition & 0 deletions server/constants/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum ApiErrorCode {
NotAdmin = 'NOT_ADMIN',
NoAdminUser = 'NO_ADMIN_USER',
ConnectionError = 'CONNECTION_ERROR',
MediaNotReleased = 'MEDIA_NOT_RELEASED',
SyncErrorGroupedFolders = 'SYNC_ERROR_GROUPED_FOLDERS',
SyncErrorNoLibraries = 'SYNC_ERROR_NO_LIBRARIES',
Unauthorized = 'UNAUTHORIZED',
Expand Down
49 changes: 48 additions & 1 deletion server/entity/MediaRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ import { Permission } from '@server/lib/permissions';
import { getSettings } from '@server/lib/settings';
import logger from '@server/logger';
import { DbAwareColumn, resolveDbType } from '@server/utils/DbColumnHelper';
import {
evaluateReleaseRestriction,
getMovieReleaseEligibility,
getTvSeasonReleaseEligibility,
type ReleaseEligibility,
} from '@server/utils/releaseEligibility';
import requestLock from '@server/utils/requestLock';
import { truncate } from 'lodash';
import {
Expand All @@ -38,6 +44,24 @@ export class QuotaRestrictedError extends Error {}
export class DuplicateMediaRequestError extends Error {}
export class NoSeasonsAvailableError extends Error {}
export class BlocklistedMediaError extends Error {}
export class ReleaseDateRestrictedError extends Error {}

export const assertReleaseRestriction = (
eligibilities: ReleaseEligibility[],
actingUser: User
): void => {
const settings = getSettings();
const decision = evaluateReleaseRestriction(eligibilities, {
enabled: settings.main.releaseDateRestrictionEnabled,
canBypass: actingUser.hasPermission(Permission.MANAGE_REQUESTS),
});

if (!decision.allowed) {
throw new ReleaseDateRestrictedError(
'This media has not been released yet.'
);
}
};

type MediaRequestOptions = {
isAutoRequest?: boolean;
Expand Down Expand Up @@ -155,6 +179,16 @@ export class MediaRequest {
? await tmdb.getMovie({ movieId: requestBody.mediaId })
: await tmdb.getTvShow({ tvId: requestBody.mediaId });

if (
requestBody.mediaType === MediaType.MOVIE &&
'release_dates' in tmdbMedia
) {
assertReleaseRestriction(
[getMovieReleaseEligibility(tmdbMedia.release_dates)],
user
);
}

let media = await mediaRepository.findOne({
where: {
tmdbId: requestBody.mediaId,
Expand Down Expand Up @@ -484,7 +518,20 @@ export class MediaRequest {

if (finalSeasons.length === 0) {
throw new NoSeasonsAvailableError('No seasons available to request');
} else if (
}

assertReleaseRestriction(
finalSeasons.map((seasonNumber) =>
getTvSeasonReleaseEligibility(
tmdbMediaShow.seasons.find(
(season) => season.season_number === seasonNumber
)?.air_date
)
),
user
);

if (
!ignoreQuota &&
quotas.tv.limit &&
finalSeasons.length > (quotas.tv.remaining ?? 0)
Expand Down
1 change: 1 addition & 0 deletions server/interfaces/api/settingsInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface PublicSettingsResponse {
applicationUrl: string;
hideAvailable: boolean;
hideBlocklisted: boolean;
releaseDateRestrictionEnabled: boolean;
localLogin: boolean;
mediaServerLogin: boolean;
movie4kEnabled: boolean;
Expand Down
5 changes: 5 additions & 0 deletions server/lib/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export interface MainSettings {
};
hideAvailable: boolean;
hideBlocklisted: boolean;
releaseDateRestrictionEnabled: boolean;
localLogin: boolean;
mediaServerLogin: boolean;
newPlexLogin: boolean;
Expand Down Expand Up @@ -194,6 +195,7 @@ interface FullPublicSettings extends PublicSettings {
applicationUrl: string;
hideAvailable: boolean;
hideBlocklisted: boolean;
releaseDateRestrictionEnabled: boolean;
localLogin: boolean;
mediaServerLogin: boolean;
movie4kEnabled: boolean;
Expand Down Expand Up @@ -417,6 +419,7 @@ class Settings {
},
hideAvailable: false,
hideBlocklisted: false,
releaseDateRestrictionEnabled: false,
localLogin: true,
mediaServerLogin: true,
newPlexLogin: true,
Expand Down Expand Up @@ -714,6 +717,8 @@ class Settings {
applicationUrl: this.data.main.applicationUrl,
hideAvailable: this.data.main.hideAvailable,
hideBlocklisted: this.data.main.hideBlocklisted,
releaseDateRestrictionEnabled:
this.data.main.releaseDateRestrictionEnabled,
localLogin: this.data.main.localLogin,
mediaServerLogin: this.data.main.mediaServerLogin,
jellyfinExternalHost: this.data.jellyfin.externalHostname,
Expand Down
Loading