From 6c075e9cb54f8cc93c5a4e96b93a11bafc558b4f Mon Sep 17 00:00:00 2001 From: Ahmed Siddiqui <36286128+AhmedNSidd@users.noreply.github.com> Date: Sun, 20 Oct 2024 22:02:10 -0700 Subject: [PATCH] feat: add support for requesting "Specials" for TV Shows (#3724) * feat: add support for requesting "Specials" for TV Shows This commit is responsible for adding support in Overseerr for requesting "Special" episodes for TV Shows. This request has become especially pertinent when you consider shows like "Doctor Who". These shows have Specials that are critical to understanding the plot of a TV show. fix #779 * chore(yarn.lock): undo inappropriate changes to yarn.lock I was informed by @sct in a comment on the #3724 PR that it was not appropriate to commit the changes that ended up being made to the yarn.lock file. This commit is responsible, then, for undoing the changes to the yarn.lock file that ended up being submitted. * refactor: change loose equality to strict equality I received a comment from OwsleyJr pointing out that we are using loose equality when we could alternatively just be using strict equality to increase the robustness of our code. This commit does exactly that by squashing out previous usages of loose equality in my commits and replacing them with strict equality * refactor: move 'Specials' string to a global message Owsley pointed out that we are redefining the 'Specials' string multiple times throughout this PR. Instead, we can just move it as a global message. This commit does exactly that. It squashes out and previous declarations of the 'Specials' string inside the src files, and moves it directly to the global messages file. --- server/entity/MediaRequest.ts | 4 +--- server/lib/scanners/plex/index.ts | 6 +----- server/lib/scanners/sonarr/index.ts | 6 ++---- src/components/RequestCard/index.tsx | 6 +----- .../RequestList/RequestItem/index.tsx | 6 +----- .../RequestModal/TvRequestModal.tsx | 21 ++++--------------- src/components/TvDetails/index.tsx | 13 +++++------- src/i18n/globalMessages.ts | 10 --------- 8 files changed, 15 insertions(+), 57 deletions(-) diff --git a/server/entity/MediaRequest.ts b/server/entity/MediaRequest.ts index cdfa17c3a..3d170d893 100644 --- a/server/entity/MediaRequest.ts +++ b/server/entity/MediaRequest.ts @@ -381,9 +381,7 @@ export class MediaRequest { >; let requestedSeasons = requestBody.seasons === 'all' - ? tmdbMediaShow.seasons - .filter((season) => season.season_number !== 0) - .map((season) => season.season_number) + ? tmdbMediaShow.seasons.map((season) => season.season_number) : (requestBody.seasons as number[]); if (!settings.main.enableSpecialEpisodes) { requestedSeasons = requestedSeasons.filter((sn) => sn > 0); diff --git a/server/lib/scanners/plex/index.ts b/server/lib/scanners/plex/index.ts index 24862e558..574a6dfc7 100644 --- a/server/lib/scanners/plex/index.ts +++ b/server/lib/scanners/plex/index.ts @@ -323,11 +323,7 @@ class PlexScanner const processableSeasons: ProcessableSeason[] = []; const settings = getSettings(); - const filteredSeasons = settings.main.enableSpecialEpisodes - ? seasons - : seasons.filter((sn) => sn.season_number !== 0); - - for (const season of filteredSeasons) { + for (const season of seasons) { const matchedPlexSeason = metadata.Children?.Metadata.find( (md) => Number(md.index) === season.season_number ); diff --git a/server/lib/scanners/sonarr/index.ts b/server/lib/scanners/sonarr/index.ts index 7a6e95c0a..b5a7cfa60 100644 --- a/server/lib/scanners/sonarr/index.ts +++ b/server/lib/scanners/sonarr/index.ts @@ -104,10 +104,8 @@ class SonarrScanner const tmdbId = tvShow.id; const settings = getSettings(); - const filteredSeasons = sonarrSeries.seasons.filter( - (sn) => - tvShow.seasons.find((s) => s.season_number === sn.seasonNumber) && - (!settings.main.enableSpecialEpisodes ? sn.seasonNumber !== 0 : true) + const filteredSeasons = sonarrSeries.seasons.filter((sn) => + tvShow.seasons.find((s) => s.season_number === sn.seasonNumber) ); for (const season of filteredSeasons) { diff --git a/src/components/RequestCard/index.tsx b/src/components/RequestCard/index.tsx index 4a3b9d2c6..f91657732 100644 --- a/src/components/RequestCard/index.tsx +++ b/src/components/RequestCard/index.tsx @@ -403,11 +403,7 @@ const RequestCard = ({ request, onTitleData }: RequestCardProps) => { {intl.formatMessage(messages.seasons, { seasonCount: - (settings.currentSettings.enableSpecialEpisodes - ? title.seasons.length - : title.seasons.filter( - (season) => season.seasonNumber !== 0 - ).length) === request.seasons.length + title.seasons.length === request.seasons.length ? 0 : request.seasons.length, })} diff --git a/src/components/RequestList/RequestItem/index.tsx b/src/components/RequestList/RequestItem/index.tsx index ae12bb883..ed537b710 100644 --- a/src/components/RequestList/RequestItem/index.tsx +++ b/src/components/RequestList/RequestItem/index.tsx @@ -471,11 +471,7 @@ const RequestItem = ({ request, revalidateList }: RequestItemProps) => { {intl.formatMessage(messages.seasons, { seasonCount: - (settings.currentSettings.enableSpecialEpisodes - ? title.seasons.length - : title.seasons.filter( - (season) => season.seasonNumber !== 0 - ).length) === request.seasons.length + title.seasons.length === request.seasons.length ? 0 : request.seasons.length, })} diff --git a/src/components/RequestModal/TvRequestModal.tsx b/src/components/RequestModal/TvRequestModal.tsx index 5d2249de8..37bbee356 100644 --- a/src/components/RequestModal/TvRequestModal.tsx +++ b/src/components/RequestModal/TvRequestModal.tsx @@ -236,13 +236,9 @@ const TvRequestModal = ({ }; const getAllSeasons = (): number[] => { - let allSeasons = (data?.seasons ?? []).filter( - (season) => season.episodeCount !== 0 - ); - if (!settings.currentSettings.enableSpecialEpisodes) { - allSeasons = allSeasons.filter((season) => season.seasonNumber > 0); - } - return allSeasons.map((season) => season.seasonNumber); + return (data?.seasons ?? []) + .filter((season) => season.episodeCount !== 0) + .map((season) => season.seasonNumber); }; const getAllRequestedSeasons = (): number[] => { @@ -574,16 +570,7 @@ const TvRequestModal = ({ {data?.seasons - .filter( - (season) => - (!settings.currentSettings.enableSpecialEpisodes - ? season.seasonNumber !== 0 - : true) && - (!settings.currentSettings.partialRequestsEnabled - ? season.episodeCount !== 0 && - season.seasonNumber !== 0 - : season.episodeCount !== 0) - ) + .filter((season) => season.episodeCount !== 0) .map((season) => { const seasonRequest = getSeasonRequest( season.seasonNumber diff --git a/src/components/TvDetails/index.tsx b/src/components/TvDetails/index.tsx index 03b1e9ba9..a3a67e69a 100644 --- a/src/components/TvDetails/index.tsx +++ b/src/components/TvDetails/index.tsx @@ -304,9 +304,7 @@ const TvDetails = ({ tv }: TvDetailsProps) => { }; const showHasSpecials = data.seasons.some( - (season) => - season.seasonNumber === 0 && - settings.currentSettings.enableSpecialEpisodes + (season) => season.seasonNumber === 0 ); const isComplete = @@ -317,6 +315,10 @@ const TvDetails = ({ tv }: TvDetailsProps) => { (showHasSpecials ? seasonCount + 1 : seasonCount) <= getAllRequestedSeasons(true).length; + const is4kComplete = + (showHasSpecials ? seasonCount + 1 : seasonCount) <= + getAllRequestedSeasons(true).length; + const streamingRegion = user?.settings?.streamingRegion ? user.settings.streamingRegion : settings.currentSettings.streamingRegion @@ -785,11 +787,6 @@ const TvDetails = ({ tv }: TvDetailsProps) => { {data.seasons .slice() .reverse() - .filter( - (season) => - settings.currentSettings.enableSpecialEpisodes || - season.seasonNumber !== 0 - ) .map((season) => { const show4k = settings.currentSettings.series4kEnabled && diff --git a/src/i18n/globalMessages.ts b/src/i18n/globalMessages.ts index 54fd89869..e948e8745 100644 --- a/src/i18n/globalMessages.ts +++ b/src/i18n/globalMessages.ts @@ -57,16 +57,6 @@ const globalMessages = defineMessages('i18n', { noresults: 'No results.', open: 'Open', resolved: 'Resolved', - blacklist: 'Blacklist', - blacklisted: 'Blacklisted', - blacklistSuccess: '{title} was successfully blacklisted.', - blacklistError: 'Something went wrong. Please try again.', - blacklistDuplicateError: - '{title} has already been blacklisted.', - removeFromBlacklistSuccess: - '{title} was successfully removed from the Blacklist.', - addToBlacklist: 'Add to Blacklist', - removefromBlacklist: 'Remove from Blacklist', specials: 'Specials', });