@charliehess/tmdb
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -15,4 +15,2 @@ "use strict"; | ||
const TMDB_URL = 'https://api.themoviedb.org/3'; | ||
const MOVIE_PATH = 'movie'; | ||
const TV_PATH = 'tv'; | ||
const SEARCH_PATH = 'search'; | ||
@@ -106,4 +104,3 @@ const CREDITS = 'credits'; | ||
throw new Error('Missing argument'); | ||
const path = type === interfaces_1.MediaType.MOVIE ? MOVIE_PATH : TV_PATH; | ||
const media = await fetch(`${TMDB_URL}/${path}/${id}`, { | ||
const media = await fetch(`${TMDB_URL}/${type}/${id}`, { | ||
headers: this.headers, | ||
@@ -114,3 +111,3 @@ }).then((r) => r.json()); | ||
async discoverMovieQuery(params) { | ||
const url = new url_1.URL(`${TMDB_URL}/discover/${MOVIE_PATH}`); | ||
const url = new url_1.URL(`${TMDB_URL}/discover/movie`); | ||
Object.entries(params).forEach(([name, value]) => { | ||
@@ -132,6 +129,5 @@ if (value) | ||
async getMediaByPath({ path, type, filter, sorter, }) { | ||
const pathForType = type === interfaces_1.MediaType.MOVIE ? MOVIE_PATH : TV_PATH; | ||
const url = path === 'trending' | ||
? `${TMDB_URL}/${path}/${pathForType}/week` | ||
: `${TMDB_URL}/${pathForType}/${path}`; | ||
? `${TMDB_URL}/${path}/${type}/week` | ||
: `${TMDB_URL}/${type}/${path}`; | ||
const response = await fetch(url, { | ||
@@ -147,7 +143,6 @@ headers: this.headers, | ||
searchQueryURL(query) { | ||
return `${TMDB_URL}/${SEARCH_PATH}/${MOVIE_PATH}?query=${query}`; | ||
return `${TMDB_URL}/${SEARCH_PATH}/${interfaces_1.MediaType.MOVIE}?query=${query}`; | ||
} | ||
async getMediaCredits(id, type) { | ||
const path = type === interfaces_1.MediaType.MOVIE ? MOVIE_PATH : TV_PATH; | ||
const { cast, crew } = await fetch(`${TMDB_URL}/${path}/${id}/${CREDITS}`, { | ||
const { cast, crew } = await fetch(`${TMDB_URL}/${type}/${id}/${CREDITS}`, { | ||
headers: this.headers, | ||
@@ -154,0 +149,0 @@ }).then((r) => r.json()); |
@@ -11,4 +11,4 @@ export interface TMDb { | ||
export declare enum MediaType { | ||
MOVIE = 0, | ||
TV_SHOW = 1 | ||
MOVIE = "movie", | ||
TV_SHOW = "tv" | ||
} | ||
@@ -15,0 +15,0 @@ export interface TMDbMedia { |
@@ -6,4 +6,4 @@ "use strict"; | ||
(function (MediaType) { | ||
MediaType[MediaType["MOVIE"] = 0] = "MOVIE"; | ||
MediaType[MediaType["TV_SHOW"] = 1] = "TV_SHOW"; | ||
MediaType["MOVIE"] = "movie"; | ||
MediaType["TV_SHOW"] = "tv"; | ||
})(MediaType = exports.MediaType || (exports.MediaType = {})); | ||
@@ -10,0 +10,0 @@ function isTvShow(media) { |
{ | ||
"name": "@charliehess/tmdb", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"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
26887
498