mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-20 14:37:43 +01:00
more refactorings
This commit is contained in:
parent
63f26b81de
commit
c17f8a15e8
4 changed files with 62 additions and 46 deletions
|
@ -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 a new issue