Skip to content

Commit

Permalink
feat(server): added genres with discover data
Browse files Browse the repository at this point in the history
  • Loading branch information
ADRFranklin committed Jun 15, 2024
1 parent 88c7913 commit 4a68dfe
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion server/src/api/routes/movie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ const getMovieDiscovery = async (ctx: Context) => {
const mapper = getFromContainer(MovieMapper);

const { page, params } = (ctx.request.body as any) || 1;
const { with_companies } = params;
const { with_companies, with_genres } = params;

const results = await service.getDiscover({
page,
limit: 30,
filterByCompanyId: with_companies
? parseInt(with_companies as string)
: undefined,
filterByGenreId: with_genres ? parseInt(with_genres as string) : undefined,
});

ctx.status = StatusCodes.OK;
Expand Down
4 changes: 2 additions & 2 deletions server/src/api/routes/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { NetworkMapper } from '@/resources/network/mapper';
import { ShowMapper } from '@/resources/show/mapper';
import { NetworkService } from '@/services/network/network-service';
import { ShowService } from '@/services/show/show-service';
import { discoverSeries, network } from '@/services/tmdb/show';

const lookupById = async (ctx: Context) => {
const service = getFromContainer(ShowService);
Expand Down Expand Up @@ -44,14 +43,15 @@ const discoverSeriesData = async (ctx: Context) => {
const mapper = getFromContainer(ShowMapper);

const { page, params } = (ctx.request.body as any) || 1;
const { with_networks } = params;
const { with_networks, with_genres } = params;

const results = await service.getDiscover({
page,
limit: 30,
filterByNetworkId: with_networks
? parseInt(with_networks as string)
: undefined,
filterByGenreId: with_genres ? parseInt(with_genres as string) : undefined,
});

ctx.status = StatusCodes.OK;
Expand Down
1 change: 1 addition & 0 deletions server/src/services/movie/movie-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export class MovieService {
const discovery = await this.discoverProvider.getDiscover({
page: options?.page || 1,
withCompanyId: options?.filterByCompanyId,
withGenreId: options?.filterByGenreId,
});
if (discovery.isErr()) {
return [];
Expand Down
1 change: 1 addition & 0 deletions server/src/services/movie/provider/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export abstract class MovieTrendingProvider {
export type MovieDiscoverOptions = {
page?: number;
withCompanyId?: number;
withGenreId?: number;
};
export type MovieDiscoverResponse = Result<number[], ExceptionBase>;
export abstract class MovieDiscoverProvider {
Expand Down
1 change: 1 addition & 0 deletions server/src/services/movie/provider/tmdb/tmdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ export class TmdbMovieProvider
const data = await this.client.default.discoverMovie({
page: options?.page || 1,
withCompanies: options?.withCompanyId?.toString(),
withGenres: options?.withGenreId?.toString(),
});
return (
data.results
Expand Down
1 change: 1 addition & 0 deletions server/src/services/movie/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export type MovieDiscoverOptions = {
page?: number;
limit?: number;
filterByCompanyId?: number;
filterByGenreId?: number;
};
1 change: 1 addition & 0 deletions server/src/services/show/provider/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export abstract class ShowTrendingProvider {
export type ShowProviderDiscoverOptions = {
page?: number;
withNetworkId?: number;
withGenreId?: number;
};
export type ShowProviderDiscoverResponse = Result<number[], ExceptionBase>;
export abstract class ShowDiscoverProvider {
Expand Down
1 change: 1 addition & 0 deletions server/src/services/show/provider/tmdb/tmdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ export class TmdbShowProvider
const data = await this.client.default.discoverTv({
page: options?.page || 1,
withNetworks: options?.withNetworkId,
withGenres: options?.withGenreId?.toString(),
});
return (
data.results
Expand Down
1 change: 1 addition & 0 deletions server/src/services/show/show-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export class ShowService {
const discoverResults = await this.showDiscoverProvider.getDiscover({
page: options?.page || 1,
withNetworkId: options?.filterByNetworkId,
withGenreId: options?.filterByGenreId,
});
if (discoverResults.isErr()) {
return [];
Expand Down
1 change: 1 addition & 0 deletions server/src/services/show/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export type DiscoverShowsOptions = {
page?: number;
limit?: number;
filterByNetworkId?: number;
filterByGenreId?: number;
};

0 comments on commit 4a68dfe

Please sign in to comment.