Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove requests of unmonitored movies/seasons during scan #817

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions cypress/config/settings.cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"mediaServerType": 1,
"partialRequestsEnabled": true,
"enableSpecialEpisodes": false,
"removeUnmonitoredEnabled": false,
"locale": "en"
},
"plex": {
Expand Down
3 changes: 3 additions & 0 deletions overseerr-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ components:
partialRequestsEnabled:
type: boolean
example: false
removeUnmonitoredEnabled:
type: boolean
example: false
localLogin:
type: boolean
example: true
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 @@ -38,6 +38,7 @@ export interface PublicSettingsResponse {
mediaServerType: number;
partialRequestsEnabled: boolean;
enableSpecialEpisodes: boolean;
removeUnmonitoredEnabled: boolean;
cacheImages: boolean;
vapidPublic: string;
enablePushRegistration: boolean;
Expand Down
17 changes: 16 additions & 1 deletion server/lib/scanners/baseScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class BaseScanner<T> {

/**
* processShow takes a TMDB ID and an array of ProcessableSeasons, which
* should include the total episodes a sesaon has + the total available
* should include the total episodes a season has + the total available
* episodes that each season currently has. Unlike processMovie, this method
* does not take an `is4k` option. We handle both the 4k _and_ non 4k status
* in one method.
Expand Down Expand Up @@ -618,6 +618,21 @@ class BaseScanner<T> {
get protectedBundleSize(): number {
return this.bundleSize;
}

protected async processUnmonitoredMovie(tmdbId: number): Promise<void> {
const mediaRepository = getRepository(Media);
await this.asyncLock.dispatch(tmdbId, async () => {
const existing = await this.getExisting(tmdbId, MediaType.MOVIE);
if (existing && existing.status === MediaStatus.PROCESSING) {
existing.status = MediaStatus.UNKNOWN;
await mediaRepository.save(existing);
this.log(
`Movie TMDB ID ${tmdbId} unmonitored from Radarr. Media status set to UNKNOWN.`,
'info'
);
}
});
}
}

export default BaseScanner;
15 changes: 7 additions & 8 deletions server/lib/scanners/radarr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,13 @@ class RadarrScanner
}

private async processRadarrMovie(radarrMovie: RadarrMovie): Promise<void> {
if (!radarrMovie.monitored && !radarrMovie.hasFile) {
this.log(
'Title is unmonitored and has not been downloaded. Skipping item.',
'debug',
{
title: radarrMovie.title,
}
);
const settings = getSettings();
if (
settings.main.removeUnmonitoredEnabled &&
!radarrMovie.monitored &&
!radarrMovie.hasFile
) {
this.processUnmonitoredMovie(radarrMovie.tmdbId);
return;
}

Expand Down
4 changes: 4 additions & 0 deletions server/lib/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export interface MainSettings {
mediaServerType: number;
partialRequestsEnabled: boolean;
enableSpecialEpisodes: boolean;
removeUnmonitoredEnabled: boolean;
locale: string;
proxy: ProxySettings;
}
Expand All @@ -156,6 +157,7 @@ interface FullPublicSettings extends PublicSettings {
jellyfinServerName?: string;
partialRequestsEnabled: boolean;
enableSpecialEpisodes: boolean;
removeUnmonitoredEnabled: boolean;
cacheImages: boolean;
vapidPublic: string;
enablePushRegistration: boolean;
Expand Down Expand Up @@ -346,6 +348,7 @@ class Settings {
mediaServerType: MediaServerType.NOT_CONFIGURED,
partialRequestsEnabled: true,
enableSpecialEpisodes: false,
removeUnmonitoredEnabled: false,
locale: 'en',
proxy: {
enabled: false,
Expand Down Expand Up @@ -591,6 +594,7 @@ class Settings {
mediaServerType: this.main.mediaServerType,
partialRequestsEnabled: this.data.main.partialRequestsEnabled,
enableSpecialEpisodes: this.data.main.enableSpecialEpisodes,
removeUnmonitoredEnabled: this.data.main.removeUnmonitoredEnabled,
cacheImages: this.data.main.cacheImages,
vapidPublic: this.vapidPublic,
enablePushRegistration: this.data.notifications.agents.webpush.enabled,
Expand Down
34 changes: 34 additions & 0 deletions src/components/Settings/SettingsMain/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ const messages = defineMessages('components.Settings.SettingsMain', {
validationApplicationUrlTrailingSlash: 'URL must not end in a trailing slash',
partialRequestsEnabled: 'Allow Partial Series Requests',
enableSpecialEpisodes: 'Allow Special Episodes Requests',
removeUnmonitoredEnabled: 'Remove Unmonitored Media',
removeUnmonitoredExplanation:
'Remove Movies/Seasons from Jellyseerr that are not available and have been un-monitored since',
locale: 'Display Language',
proxyEnabled: 'HTTP(S) Proxy',
proxyHostname: 'Proxy Hostname',
Expand Down Expand Up @@ -160,6 +163,7 @@ const SettingsMain = () => {
streamingRegion: data?.streamingRegion || 'US',
partialRequestsEnabled: data?.partialRequestsEnabled,
enableSpecialEpisodes: data?.enableSpecialEpisodes,
removeUnmonitoredEnabled: data?.removeUnmonitoredEnabled,
trustProxy: data?.trustProxy,
cacheImages: data?.cacheImages,
proxyEnabled: data?.proxy?.enabled,
Expand Down Expand Up @@ -191,6 +195,7 @@ const SettingsMain = () => {
originalLanguage: values.originalLanguage,
partialRequestsEnabled: values.partialRequestsEnabled,
enableSpecialEpisodes: values.enableSpecialEpisodes,
removeUnmonitoredEnabled: values.removeUnmonitoredEnabled,
trustProxy: values.trustProxy,
cacheImages: values.cacheImages,
proxy: {
Expand Down Expand Up @@ -524,6 +529,35 @@ const SettingsMain = () => {
/>
</div>
</div>
<div className="form-row">
<label
htmlFor="removeUnmonitoredEnabled"
className="checkbox-label"
>
<span className="mr-2">
{intl.formatMessage(messages.removeUnmonitoredEnabled)}
</span>
<SettingsBadge badgeType="experimental" />
<span className="label-tip">
{intl.formatMessage(
messages.removeUnmonitoredExplanation
)}
</span>
</label>
<div className="form-input-area">
<Field
type="checkbox"
id="removeUnmonitoredEnabled"
name="removeUnmonitoredEnabled"
onChange={() => {
setFieldValue(
'removeUnmonitoredEnabled',
!values.removeUnmonitoredEnabled
);
}}
/>
</div>
</div>
<div className="form-row">
<label htmlFor="proxyEnabled" className="checkbox-label">
<span className="mr-2">
Expand Down
1 change: 1 addition & 0 deletions src/context/SettingsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const defaultSettings = {
mediaServerType: MediaServerType.NOT_CONFIGURED,
partialRequestsEnabled: true,
enableSpecialEpisodes: false,
removeUnmonitoredEnabled: false,
cacheImages: false,
vapidPublic: '',
enablePushRegistration: false,
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,7 @@
"components.Settings.SettingsMain.proxyUser": "Proxy Username",
"components.Settings.SettingsMain.streamingRegion": "Streaming Region",
"components.Settings.SettingsMain.streamingRegionTip": "Show streaming sites by regional availability",
"components.Settings.SettingsMain.removeUnmonitoredFromRequestsEnabled": "Remove Request for Movies/Seasons that have been un-monitored since",
"components.Settings.SettingsMain.toastApiKeyFailure": "Something went wrong while generating a new API key.",
"components.Settings.SettingsMain.toastApiKeySuccess": "New API key generated successfully!",
"components.Settings.SettingsMain.toastSettingsFailure": "Something went wrong while saving settings.",
Expand Down
1 change: 1 addition & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ CoreApp.getInitialProps = async (initialProps) => {
mediaServerType: MediaServerType.NOT_CONFIGURED,
partialRequestsEnabled: true,
enableSpecialEpisodes: false,
removeUnmonitoredEnabled: false,
cacheImages: false,
vapidPublic: '',
enablePushRegistration: false,
Expand Down
Loading