@charliehess/tmdb
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -152,7 +152,7 @@ "use strict"; | ||
} | ||
async getWatchProviders(id, type) { | ||
const result = await fetch(`${TMDB_URL}/${type}/${id}/${WATCH_PROVIDERS}`, { | ||
async getWatchProviders(id, type, locale = 'US') { | ||
const { results } = await fetch(`${TMDB_URL}/${type}/${id}/${WATCH_PROVIDERS}`, { | ||
headers: this.headers, | ||
}).then((r) => r.json()); | ||
const providers = utils_1.processWatchProviders((result === null || result === void 0 ? void 0 : result.US) || {}); | ||
const providers = utils_1.processWatchProviders((results === null || results === void 0 ? void 0 : results[locale]) || {}); | ||
providers.forEach((provider) => (provider.logo_path = this.tmdbPathPrefix(provider.logo_path, 200))); | ||
@@ -159,0 +159,0 @@ return providers; |
@@ -122,8 +122,11 @@ export interface TMDb { | ||
} | ||
export declare type TMDbWatchProviderResult = Record<string, { | ||
link?: string; | ||
buy?: Array<TMDbWatchProvider>; | ||
rent?: Array<TMDbWatchProvider>; | ||
flatrate?: Array<TMDbWatchProvider>; | ||
}>; | ||
export interface TMDbWatchProviderResult { | ||
id: number; | ||
results: Record<string, { | ||
link?: string; | ||
buy?: Array<TMDbWatchProvider>; | ||
rent?: Array<TMDbWatchProvider>; | ||
flatrate?: Array<TMDbWatchProvider>; | ||
}>; | ||
} | ||
export interface TMDbWatchProvider { | ||
@@ -130,0 +133,0 @@ display_priority: number; |
@@ -24,3 +24,3 @@ import { TMDbCrewMember, TMDbMovie, TMDbTvShow, TMDbWatchProvider, TMDbWatchProviderResult } from './interfaces'; | ||
export declare function processCrewMembers(crew: Array<TMDbCrewMember>): Array<TMDbCrewMember>; | ||
export declare function processWatchProviders({ buy, rent, flatrate, }: TMDbWatchProviderResult['US']): Array<TMDbWatchProvider>; | ||
export declare function processWatchProviders({ buy, rent, flatrate, }: TMDbWatchProviderResult['results']['US']): Array<TMDbWatchProvider>; | ||
export declare function formattedFutureDate(duration: Duration, pattern?: string): string; |
{ | ||
"name": "@charliehess/tmdb", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "Helpers for TheMovieDB", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
45575
813