Skip to content

Commit

Permalink
feat: isaac mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanjones98 committed Apr 18, 2024
1 parent 99b3607 commit 056bb2c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions overseerr-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4199,6 +4199,11 @@ paths:
schema:
type: string
example: 2022-01-01
- in: query
name: isaacMode
schema:
type: string
example: true
- in: query
name: primaryReleaseDateLte
schema:
Expand Down
3 changes: 3 additions & 0 deletions server/api/themoviedb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ interface DiscoverMovieOptions {
sortBy?: SortOptions;
watchRegion?: string;
watchProviders?: string;
withoutKeywords?: string;
}

interface DiscoverTvOptions {
Expand Down Expand Up @@ -468,6 +469,7 @@ class TheMovieDb extends ExternalAPI {
voteCountLte,
watchProviders,
watchRegion,
withoutKeywords,
}: DiscoverMovieOptions = {}): Promise<TmdbSearchMovieResponse> => {
try {
const defaultFutureDate = new Date(
Expand Down Expand Up @@ -506,6 +508,7 @@ class TheMovieDb extends ExternalAPI {
with_genres: genre,
with_companies: studio,
with_keywords: keywords,
without_keywords: withoutKeywords,
'with_runtime.gte': withRuntimeGte,
'with_runtime.lte': withRuntimeLte,
'vote_average.gte': voteAverageGte,
Expand Down
2 changes: 2 additions & 0 deletions server/routes/discover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const QueryFilterOptions = z.object({
network: z.coerce.string().optional(),
watchProviders: z.coerce.string().optional(),
watchRegion: z.coerce.string().optional(),
isaacMode: z.coerce.string().optional(),
});

export type FilterOptions = z.infer<typeof QueryFilterOptions>;
Expand Down Expand Up @@ -102,6 +103,7 @@ discoverRoutes.get('/movies', async (req, res, next) => {
voteCountLte: query.voteCountLte,
watchProviders: query.watchProviders,
watchRegion: query.watchRegion,
withoutKeywords: query.isaacMode === 'true' ? '155477|190370' : '',
});

const media = await Media.getRelatedMedia(
Expand Down
15 changes: 15 additions & 0 deletions src/components/Discover/FilterSlideover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
useUpdateQueryParams,
} from '@app/hooks/useUpdateQueryParams';
import { XCircleIcon } from '@heroicons/react/24/outline';
import { useState } from 'react';
import { defineMessages, useIntl } from 'react-intl';
import Datepicker from 'react-tailwindcss-datepicker-sct';

Expand Down Expand Up @@ -58,12 +59,18 @@ const FilterSlideover = ({
const { currentSettings } = useSettings();
const updateQueryParams = useUpdateQueryParams({});
const batchUpdateQueryParams = useBatchUpdateQueryParams({});
const [isaacMode, setIsaacMode] = useState('false');

const dateGte =
type === 'movie' ? 'primaryReleaseDateGte' : 'firstAirDateGte';
const dateLte =
type === 'movie' ? 'primaryReleaseDateLte' : 'firstAirDateLte';

function handleChangeIsaacMode() {
setIsaacMode(isaacMode === 'false' ? 'true' : 'false');
updateQueryParams('isaacMode', isaacMode);
}

return (
<SlideOver
show={show}
Expand Down Expand Up @@ -170,6 +177,14 @@ const FilterSlideover = ({
updateQueryParams('language', value);
}}
/>
<span className="text-lg font-semibold">Isaac Mode</span>
<input
type="checkbox"
id="collapseTags"
name="collapseTags"
checked={isaacMode === 'true' ? true : false}
onChange={handleChangeIsaacMode}
/>
<span className="text-lg font-semibold">
{intl.formatMessage(messages.runtime)}
</span>
Expand Down
5 changes: 5 additions & 0 deletions src/components/Discover/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const QueryFilterOptions = z.object({
voteCountGte: z.string().optional(),
watchRegion: z.string().optional(),
watchProviders: z.string().optional(),
isaacMode: z.string().optional(),
});

export type FilterOptions = z.infer<typeof QueryFilterOptions>;
Expand All @@ -123,6 +124,10 @@ export const prepareFilterValues = (
filterValues.sortBy = values.sortBy;
}

if (values.isaacMode) {
filterValues.isaacMode = values.isaacMode;
}

if (values.primaryReleaseDateGte) {
filterValues.primaryReleaseDateGte = values.primaryReleaseDateGte;
}
Expand Down

0 comments on commit 056bb2c

Please sign in to comment.