more refactorings

This commit is contained in:
castdrian 2023-06-12 21:25:24 +02:00
parent dfe67157d4
commit 1eac9f886e
4 changed files with 62 additions and 46 deletions

View File

@ -1,13 +1,13 @@
import { FetchError } from "ofetch";
import { formatJWMeta, mediaTypeToJW } from "./justwatch";
import {
JWMediaResult,
JWSeasonMetaResult,
JW_API_BASE,
formatJWMeta,
mediaTypeToJW,
} from "./justwatch";
import { MWMediaMeta, MWMediaType } from "./types";
MWMediaMeta,
MWMediaType,
} from "./types";
import { makeUrl, proxiedFetch } from "../helpers/fetch";
type JWExternalIdType =

View File

@ -1,38 +1,10 @@
import { MWMediaMeta, MWMediaType, MWSeasonMeta } from "./types";
export const JW_API_BASE = "https://apis.justwatch.com";
export const JW_IMAGE_BASE = "https://images.justwatch.com";
export type JWContentTypes = "movie" | "show";
export type JWSeasonShort = {
title: string;
id: number;
season_number: number;
};
export type JWEpisodeShort = {
title: string;
id: number;
episode_number: number;
};
export type JWMediaResult = {
title: string;
poster?: string;
id: number;
original_release_year?: number;
jw_entity_id: string;
object_type: JWContentTypes;
seasons?: JWSeasonShort[];
};
export type JWSeasonMetaResult = {
title: string;
id: string;
season_number: number;
episodes: JWEpisodeShort[];
};
import {
JWContentTypes,
JWMediaResult,
JWSeasonMetaResult,
JW_IMAGE_BASE,
} from "./types";
import { MWMediaMeta, MWMediaType, MWSeasonMeta } from "./types_old";
export function mediaTypeToJW(type: MWMediaType): JWContentTypes {
if (type === MWMediaType.MOVIE) return "movie";

View File

@ -1,12 +1,7 @@
import { SimpleCache } from "@/utils/cache";
import {
JWContentTypes,
JWMediaResult,
JW_API_BASE,
formatJWMeta,
mediaTypeToJW,
} from "./justwatch";
import { formatJWMeta, mediaTypeToJW } from "./justwatch";
import { JWContentTypes, JWMediaResult, JW_API_BASE } from "./types";
import { MWMediaMeta, MWQuery } from "./types_old";
import { proxiedFetch } from "../helpers/fetch";

View File

@ -262,3 +262,52 @@ export interface TMDBMediaStatic {
getMediaDetails(id: string, type: MWMediaType.MOVIE): TMDBMediaDetailsPromise;
getMediaDetails(id: string, type: MWMediaType): TMDBMediaDetailsPromise;
}
export type JWContentTypes = "movie" | "show";
export type JWSearchQuery = {
content_types: JWContentTypes[];
page: number;
page_size: number;
query: string;
};
export type JWPage<T> = {
items: T[];
page: number;
page_size: number;
total_pages: number;
total_results: number;
};
export const JW_API_BASE = "https://apis.justwatch.com";
export const JW_IMAGE_BASE = "https://images.justwatch.com";
export type JWSeasonShort = {
title: string;
id: number;
season_number: number;
};
export type JWEpisodeShort = {
title: string;
id: number;
episode_number: number;
};
export type JWMediaResult = {
title: string;
poster?: string;
id: number;
original_release_year?: number;
jw_entity_id: string;
object_type: JWContentTypes;
seasons?: JWSeasonShort[];
};
export type JWSeasonMetaResult = {
title: string;
id: string;
season_number: number;
episodes: JWEpisodeShort[];
};