mirror of
https://github.com/aleksilassila/reiverr.git
synced 2026-04-23 01:05:13 +02:00
Work on migrating files from sveltekit to svelte
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import { browser } from '$app/environment';
|
||||
import { TMDB_API_KEY, TMDB_BACKDROP_SMALL } from '$lib/constants';
|
||||
import { settings } from '$lib/stores/settings.store';
|
||||
import createClient from 'openapi-fetch';
|
||||
import { get } from 'svelte/store';
|
||||
import type { operations, paths } from './tmdb.generated';
|
||||
import type { TitleType } from '$lib/types';
|
||||
import { TMDB_API_KEY, TMDB_BACKDROP_SMALL } from '../../constants';
|
||||
import { settings } from '../../stores/settings.store';
|
||||
import type { TitleType } from '../../types';
|
||||
|
||||
const CACHE_ONE_DAY = 'max-age=86400';
|
||||
const CACHE_FOUR_DAYS = 'max-age=345600';
|
||||
@@ -39,8 +38,8 @@ export interface TmdbSeriesFull2 extends TmdbSeries2 {
|
||||
images: operations['tv-series-images']['responses']['200']['content']['application/json'];
|
||||
}
|
||||
|
||||
const backdropCache = browser ? window?.caches?.open('backdrops') : undefined;
|
||||
const posterCache = browser ? window?.caches?.open('posters') : undefined;
|
||||
const backdropCache = window?.caches?.open('backdrops') || undefined;
|
||||
const posterCache = window?.caches?.open('posters') || undefined;
|
||||
|
||||
const getTmdbCache = async (
|
||||
cachePromise: typeof backdropCache,
|
||||
@@ -72,7 +71,7 @@ export const TmdbApiOpen = createClient<paths>({
|
||||
});
|
||||
|
||||
export const getTmdbMovie = async (tmdbId: number) =>
|
||||
await TmdbApiOpen.get('/3/movie/{movie_id}', {
|
||||
await TmdbApiOpen.GET('/3/movie/{movie_id}', {
|
||||
params: {
|
||||
path: {
|
||||
movie_id: tmdbId
|
||||
@@ -85,7 +84,7 @@ export const getTmdbMovie = async (tmdbId: number) =>
|
||||
}).then((res) => res.data as TmdbMovieFull2 | undefined);
|
||||
|
||||
export const getTmdbSeriesFromTvdbId = async (tvdbId: string) =>
|
||||
TmdbApiOpen.get('/3/find/{external_id}', {
|
||||
TmdbApiOpen.GET('/3/find/{external_id}', {
|
||||
params: {
|
||||
path: {
|
||||
external_id: tvdbId
|
||||
@@ -107,7 +106,7 @@ export const getTmdbIdFromTvdbId = async (tvdbId: number) =>
|
||||
});
|
||||
|
||||
export const getTmdbSeries = async (tmdbId: number): Promise<TmdbSeriesFull2 | undefined> =>
|
||||
await TmdbApiOpen.get('/3/tv/{series_id}', {
|
||||
await TmdbApiOpen.GET('/3/tv/{series_id}', {
|
||||
params: {
|
||||
path: {
|
||||
series_id: tmdbId
|
||||
@@ -126,7 +125,7 @@ export const getTmdbSeriesSeason = async (
|
||||
tmdbId: number,
|
||||
season: number
|
||||
): Promise<TmdbSeason | undefined> =>
|
||||
TmdbApiOpen.get('/3/tv/{series_id}/season/{season_number}', {
|
||||
TmdbApiOpen.GET('/3/tv/{series_id}/season/{season_number}', {
|
||||
params: {
|
||||
path: {
|
||||
series_id: tmdbId,
|
||||
@@ -141,7 +140,7 @@ export const getTmdbSeriesSeasons = async (tmdbId: number, seasons: number) =>
|
||||
);
|
||||
|
||||
export const getTmdbSeriesImages = async (tmdbId: number) =>
|
||||
TmdbApiOpen.get('/3/tv/{series_id}/images', {
|
||||
TmdbApiOpen.GET('/3/tv/{series_id}/images', {
|
||||
params: {
|
||||
path: {
|
||||
series_id: tmdbId
|
||||
@@ -153,7 +152,7 @@ export const getTmdbSeriesImages = async (tmdbId: number) =>
|
||||
}).then((res) => res.data);
|
||||
|
||||
export const getTmdbMovieImages = async (tmdbId: number) =>
|
||||
await TmdbApiOpen.get('/3/movie/{movie_id}/images', {
|
||||
await TmdbApiOpen.GET('/3/movie/{movie_id}/images', {
|
||||
params: {
|
||||
path: {
|
||||
movie_id: tmdbId
|
||||
@@ -203,7 +202,7 @@ export const getTmdbMoviePoster = async (tmdbId: number) =>
|
||||
/** Discover */
|
||||
|
||||
export const getTmdbPopularMovies = () =>
|
||||
TmdbApiOpen.get('/3/movie/popular', {
|
||||
TmdbApiOpen.GET('/3/movie/popular', {
|
||||
params: {
|
||||
query: {
|
||||
language: get(settings)?.language,
|
||||
@@ -213,7 +212,7 @@ export const getTmdbPopularMovies = () =>
|
||||
}).then((res) => res.data?.results || []);
|
||||
|
||||
export const getTmdbPopularSeries = () =>
|
||||
TmdbApiOpen.get('/3/tv/popular', {
|
||||
TmdbApiOpen.GET('/3/tv/popular', {
|
||||
params: {
|
||||
query: {
|
||||
language: get(settings)?.language
|
||||
@@ -222,7 +221,7 @@ export const getTmdbPopularSeries = () =>
|
||||
}).then((res) => res.data?.results || []);
|
||||
|
||||
export const getTmdbNetworkSeries = (networkId: number) =>
|
||||
TmdbApiOpen.get('/3/discover/tv', {
|
||||
TmdbApiOpen.GET('/3/discover/tv', {
|
||||
params: {
|
||||
query: {
|
||||
with_networks: networkId
|
||||
@@ -231,7 +230,7 @@ export const getTmdbNetworkSeries = (networkId: number) =>
|
||||
}).then((res) => res.data?.results || []);
|
||||
|
||||
export const getTmdbGenreMovies = (genreId: number) =>
|
||||
TmdbApiOpen.get('/3/discover/movie', {
|
||||
TmdbApiOpen.GET('/3/discover/movie', {
|
||||
params: {
|
||||
query: {
|
||||
with_genres: String(genreId)
|
||||
@@ -240,7 +239,7 @@ export const getTmdbGenreMovies = (genreId: number) =>
|
||||
}).then((res) => res.data?.results || []);
|
||||
|
||||
export const getTmdbSeriesRecommendations = (tmdbId: number) =>
|
||||
TmdbApiOpen.get('/3/tv/{series_id}/recommendations', {
|
||||
TmdbApiOpen.GET('/3/tv/{series_id}/recommendations', {
|
||||
params: {
|
||||
path: {
|
||||
series_id: tmdbId
|
||||
@@ -249,7 +248,7 @@ export const getTmdbSeriesRecommendations = (tmdbId: number) =>
|
||||
}).then((res) => res.data?.results || []);
|
||||
|
||||
export const getTmdbSeriesSimilar = (tmdbId: number) =>
|
||||
TmdbApiOpen.get('/3/tv/{series_id}/similar', {
|
||||
TmdbApiOpen.GET('/3/tv/{series_id}/similar', {
|
||||
params: {
|
||||
path: {
|
||||
series_id: String(tmdbId)
|
||||
@@ -258,7 +257,7 @@ export const getTmdbSeriesSimilar = (tmdbId: number) =>
|
||||
}).then((res) => res.data?.results || []);
|
||||
|
||||
export const getTmdbSeriesCredits = (tmdbId: number) =>
|
||||
TmdbApiOpen.get('/3/tv/{series_id}/credits', {
|
||||
TmdbApiOpen.GET('/3/tv/{series_id}/credits', {
|
||||
params: {
|
||||
path: {
|
||||
series_id: tmdbId
|
||||
@@ -267,7 +266,7 @@ export const getTmdbSeriesCredits = (tmdbId: number) =>
|
||||
}).then((res) => res.data?.cast || []);
|
||||
|
||||
export const getTmdbMovieRecommendations = (tmdbId: number) =>
|
||||
TmdbApiOpen.get('/3/movie/{movie_id}/recommendations', {
|
||||
TmdbApiOpen.GET('/3/movie/{movie_id}/recommendations', {
|
||||
params: {
|
||||
path: {
|
||||
movie_id: tmdbId
|
||||
@@ -276,7 +275,7 @@ export const getTmdbMovieRecommendations = (tmdbId: number) =>
|
||||
}).then((res) => res.data?.results || []);
|
||||
|
||||
export const getTmdbMovieSimilar = (tmdbId: number) =>
|
||||
TmdbApiOpen.get('/3/movie/{movie_id}/similar', {
|
||||
TmdbApiOpen.GET('/3/movie/{movie_id}/similar', {
|
||||
params: {
|
||||
path: {
|
||||
movie_id: tmdbId
|
||||
@@ -285,7 +284,7 @@ export const getTmdbMovieSimilar = (tmdbId: number) =>
|
||||
}).then((res) => res.data?.results || []);
|
||||
|
||||
export const searchTmdbTitles = (query: string) =>
|
||||
TmdbApiOpen.get('/3/search/multi', {
|
||||
TmdbApiOpen.GET('/3/search/multi', {
|
||||
params: {
|
||||
query: {
|
||||
query
|
||||
@@ -334,7 +333,7 @@ export const getPosterProps = async (
|
||||
};
|
||||
|
||||
export const getTmdbPerson = async (person_id: number) =>
|
||||
TmdbApiOpen.get('/3/person/{person_id}', {
|
||||
TmdbApiOpen.GET('/3/person/{person_id}', {
|
||||
params: {
|
||||
path: {
|
||||
person_id: person_id
|
||||
|
||||
Reference in New Issue
Block a user