mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-30 16:17:41 +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 { FetchError } from "ofetch";
|
||||||
|
|
||||||
|
import { formatJWMeta, mediaTypeToJW } from "./justwatch";
|
||||||
import {
|
import {
|
||||||
JWMediaResult,
|
JWMediaResult,
|
||||||
JWSeasonMetaResult,
|
JWSeasonMetaResult,
|
||||||
JW_API_BASE,
|
JW_API_BASE,
|
||||||
formatJWMeta,
|
MWMediaMeta,
|
||||||
mediaTypeToJW,
|
MWMediaType,
|
||||||
} from "./justwatch";
|
} from "./types";
|
||||||
import { MWMediaMeta, MWMediaType } from "./types";
|
|
||||||
import { makeUrl, proxiedFetch } from "../helpers/fetch";
|
import { makeUrl, proxiedFetch } from "../helpers/fetch";
|
||||||
|
|
||||||
type JWExternalIdType =
|
type JWExternalIdType =
|
||||||
|
|
|
@ -1,38 +1,10 @@
|
||||||
import { MWMediaMeta, MWMediaType, MWSeasonMeta } from "./types";
|
import {
|
||||||
|
JWContentTypes,
|
||||||
export const JW_API_BASE = "https://apis.justwatch.com";
|
JWMediaResult,
|
||||||
export const JW_IMAGE_BASE = "https://images.justwatch.com";
|
JWSeasonMetaResult,
|
||||||
|
JW_IMAGE_BASE,
|
||||||
export type JWContentTypes = "movie" | "show";
|
} from "./types";
|
||||||
|
import { MWMediaMeta, MWMediaType, MWSeasonMeta } from "./types_old";
|
||||||
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[];
|
|
||||||
};
|
|
||||||
|
|
||||||
export function mediaTypeToJW(type: MWMediaType): JWContentTypes {
|
export function mediaTypeToJW(type: MWMediaType): JWContentTypes {
|
||||||
if (type === MWMediaType.MOVIE) return "movie";
|
if (type === MWMediaType.MOVIE) return "movie";
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import { SimpleCache } from "@/utils/cache";
|
import { SimpleCache } from "@/utils/cache";
|
||||||
|
|
||||||
import {
|
import { formatJWMeta, mediaTypeToJW } from "./justwatch";
|
||||||
JWContentTypes,
|
import { JWContentTypes, JWMediaResult, JW_API_BASE } from "./types";
|
||||||
JWMediaResult,
|
|
||||||
JW_API_BASE,
|
|
||||||
formatJWMeta,
|
|
||||||
mediaTypeToJW,
|
|
||||||
} from "./justwatch";
|
|
||||||
import { MWMediaMeta, MWQuery } from "./types_old";
|
import { MWMediaMeta, MWQuery } from "./types_old";
|
||||||
import { proxiedFetch } from "../helpers/fetch";
|
import { proxiedFetch } from "../helpers/fetch";
|
||||||
|
|
||||||
|
|
|
@ -262,3 +262,52 @@ export interface TMDBMediaStatic {
|
||||||
getMediaDetails(id: string, type: MWMediaType.MOVIE): TMDBMediaDetailsPromise;
|
getMediaDetails(id: string, type: MWMediaType.MOVIE): TMDBMediaDetailsPromise;
|
||||||
getMediaDetails(id: string, type: MWMediaType): 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