mirror of
https://github.com/movie-web/movie-web.git
synced 2024-12-26 18:21:54 +01:00
more refactorings
This commit is contained in:
parent
dfe67157d4
commit
1eac9f886e
@ -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 =
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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[];
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user