mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 10:03:26 +00:00
chore: run prettier
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
export const name = "tmdb";
|
||||
export * from './search';
|
||||
export * from "./search";
|
||||
|
@@ -1,15 +1,22 @@
|
||||
import type { MovieDetails, TvShowDetails } from 'tmdb-ts';
|
||||
import { TMDB } from 'tmdb-ts';
|
||||
import type { MovieDetails, TvShowDetails } from "tmdb-ts";
|
||||
import { TMDB } from "tmdb-ts";
|
||||
|
||||
const TMDB_API_KEY = 'eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJkYTM1ZTgyMzE4OTc0NTgxNDJmZjljZTE4ODExNWRlNiIsInN1YiI6IjY0OTM0ZDQ1ODliNTYxMDExYzliZDVhMiIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.AzWnIcxPNgDwGdzeIZ_C3mRC_5_qy-Z-SRPglLjzlNc';
|
||||
const TMDB_API_KEY =
|
||||
"eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJkYTM1ZTgyMzE4OTc0NTgxNDJmZjljZTE4ODExNWRlNiIsInN1YiI6IjY0OTM0ZDQ1ODliNTYxMDExYzliZDVhMiIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.AzWnIcxPNgDwGdzeIZ_C3mRC_5_qy-Z-SRPglLjzlNc";
|
||||
const tmdb = new TMDB(TMDB_API_KEY);
|
||||
|
||||
export async function searchTitle(query: string): Promise<unknown[]> {
|
||||
try {
|
||||
const rawResults = await tmdb.search.multi({ query, page: 1, include_adult: false });
|
||||
const results = rawResults.results.filter((result) => result.media_type === 'tv' || result.media_type === 'movie');
|
||||
const rawResults = await tmdb.search.multi({
|
||||
query,
|
||||
page: 1,
|
||||
include_adult: false,
|
||||
});
|
||||
const results = rawResults.results.filter(
|
||||
(result) => result.media_type === "tv" || result.media_type === "movie",
|
||||
);
|
||||
|
||||
if (!results.length) throw new Error('No results found');
|
||||
if (!results.length) throw new Error("No results found");
|
||||
|
||||
return results;
|
||||
} catch (ex) {
|
||||
@@ -18,16 +25,19 @@ export async function searchTitle(query: string): Promise<unknown[]> {
|
||||
}
|
||||
|
||||
export async function fetchMediaDetails(
|
||||
id: string, type: 'movie' | 'tv'
|
||||
): Promise<{ type: 'movie' | 'tv'; result: TvShowDetails | MovieDetails } | undefined> {
|
||||
id: string,
|
||||
type: "movie" | "tv",
|
||||
): Promise<
|
||||
{ type: "movie" | "tv"; result: TvShowDetails | MovieDetails } | undefined
|
||||
> {
|
||||
try {
|
||||
let result: TvShowDetails | MovieDetails;
|
||||
|
||||
switch (type) {
|
||||
case 'tv':
|
||||
case "tv":
|
||||
result = await tmdb.tvShows.details(parseInt(id, 10));
|
||||
break;
|
||||
case 'movie':
|
||||
case "movie":
|
||||
result = await tmdb.movies.details(parseInt(id, 10));
|
||||
break;
|
||||
default:
|
||||
@@ -43,4 +53,3 @@ export async function fetchMediaDetails(
|
||||
export function getMediaPoster(posterPath: string): string {
|
||||
return `https://image.tmdb.org/t/p/w185/${posterPath}`;
|
||||
}
|
||||
|
Reference in New Issue
Block a user