Socket
Socket
Sign inDemoInstall

themoviedb.js

Package Overview
Dependencies
7
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.2 to 3.0.0

.github/dependabot.yml

12

package.json
{
"name": "themoviedb.js",
"displayName": "themoviedb.js",
"version": "2.0.2",
"description": "Node.js Movie Database API wrapper for Node.js",
"version": "3.0.0",
"description": "The Movie Database API wrapper for Node.js",
"author": "Giovani de Oliveira <giovanioliveira@outlook.com.br>",

@@ -27,10 +27,10 @@ "license": "MIT",

],
"dependencies": {
"node-fetch": "^2.6.1"
},
"devDependencies": {
"eslint": "^6.8.0",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.20.0"
},
"dependencies": {
"node-fetch": "^2.6.1"
}
}

@@ -24,3 +24,3 @@ # themoviedb.js

# Docs
Official The Movie Database [Documentation](https://www.themoviedb.org/documentation/api).
[Documentation](https://developers.themoviedb.org/3)

@@ -39,6 +39,6 @@ # Prerequisites

# Account
Create an TMDb (https://www.themoviedb.org/) account.
Create an The Movie DB account on https://www.themoviedb.org/.
# API Key
You can apply for an API key by clicking the "API" (https://www.themoviedb.org/settings/api) link from the left hand sidebar within your account settings page. You need to have a legitimate business name, address, phone number and description to apply for an API key.
Create an API key on https://www.themoviedb.org/settings/api.
````

@@ -51,6 +51,6 @@

const tmdb = new Tmdb({
apiKey: 'TMDB_API_KEY',
api_key: 'TMDB_API_KEY',
});
async function example() {
(async () => {
try {

@@ -71,6 +71,6 @@ const trending = await tmdb.all().getTrending();

console.log(topRatedMovie);
} catch (err) {
console.error(err);
} catch (error) {
console.error(error);
}
}
})();
```

@@ -77,0 +77,0 @@

const api = {
url: 'https://api.themoviedb.org',
trending: '/3/trending/all/TIME_WINDOW',

@@ -3,0 +4,0 @@ movie: {

@@ -9,9 +9,19 @@ const {

class TmdbController {
constructor(config = { baseUrl: null, apiKey: null }) {
this._allService = new AllService(config);
this._movieService = new MovieService(config);
this._personService = new PersonService(config);
this._tvService = new TvService(config);
/**
* @param {Object} config Configs
* @param {string} config.api_key API key
*/
constructor(config) {
this.config = config;
this.config.api_key = config.api_key;
this._allService = new AllService(this.config);
this._movieService = new MovieService(this.config);
this._personService = new PersonService(this.config);
this._tvService = new TvService(this.config);
}
/**
* This is used when you require a general features
*/
all() {

@@ -21,2 +31,5 @@ return this._allService;

/**
* This is used when you require a movie features
*/
movie() {

@@ -26,2 +39,5 @@ return this._movieService;

/**
* This is used when you require a people features
*/
person() {

@@ -31,2 +47,5 @@ return this._personService;

/**
* This is used when you require a tv features
*/
tv() {

@@ -33,0 +52,0 @@ return this._tvService;

@@ -1,3 +0,2 @@

const fetch = require('node-fetch');
const { URLSearchParams } = require('url');
const { request } = require('../utils');

@@ -8,22 +7,18 @@ const { apiConfig } = require('../configs');

constructor(config) {
this._baseUrl = config.baseUrl || 'https://api.themoviedb.org';
this._apiKey = config.apiKey;
this._query = {
api_key: this._apiKey,
};
this.config = config;
}
/**
* /trending/{media_type}/{time_window}
*
* @see https://developers.themoviedb.org/3/trending/get-trending
* @param {string} timeWindow Time Window
* @returns {Promise} Promise
*/
async getTrending(timeWindow) {
try {
const params = new URLSearchParams();
Object.keys(this._query).forEach((key) => params.append(key, this._query[key]));
const url = `${this._baseUrl}${apiConfig.trending}?${params}`.replace('TIME_WINDOW', timeWindow || 'day');
const trending = await request({
url: `${apiConfig.url}${apiConfig.trending}`.replace('TIME_WINDOW', timeWindow || 'day'), qs: this.config,
});
const trending = await fetch(url, { method: 'GET' });
return trending.json();
} catch (error) {
return error;
}
return trending;
}

@@ -30,0 +25,0 @@ }

@@ -1,3 +0,2 @@

const fetch = require('node-fetch');
const { URLSearchParams } = require('url');
const { request } = require('../utils');

@@ -8,79 +7,69 @@ const { apiConfig } = require('../configs');

constructor(config) {
this._baseUrl = config.baseUrl || 'https://api.themoviedb.org';
this._apiKey = config.apiKey;
this._query = {
api_key: this._apiKey,
};
this.config = config;
}
/**
* /trending/{media_type}/{time_window}
*
* @see https://developers.themoviedb.org/3/trending/get-trending
* @param {string} timeWindow Time Window
* @returns {Promise} Promise
*/
async getTrending(timeWindow) {
try {
const params = new URLSearchParams();
Object.keys(this._query).forEach((key) => params.append(key, this._query[key]));
const url = `${this._baseUrl}${apiConfig.movie.trending}?${params}`.replace('TIME_WINDOW', timeWindow || 'day');
const trending = await request({
url: `${apiConfig.url}${apiConfig.movie.trending}`.replace('TIME_WINDOW', timeWindow || 'day'), qs: this.config,
});
const trending = await fetch(url, { method: 'GET' });
return trending.json();
} catch (error) {
return error;
}
return trending;
}
async getPopular(query) {
try {
const queryString = {
...query,
api_key: this._apiKey,
};
/**
* /movie/popular
*
* @see https://developers.themoviedb.org/3/movies/get-popular-movies
* @param {Object} options Request params
* @returns {Promise} Promise
*/
async getPopular(options) {
const qs = { ...this.config, ...options };
const params = new URLSearchParams();
Object.keys(queryString).forEach((key) => params.append(key, queryString[key]));
const url = `${this._baseUrl}${apiConfig.movie.popular}?${params}`;
const popular = await request({
url: `${apiConfig.url}${apiConfig.movie.popular}`, qs,
});
const popular = await fetch(url, { method: 'GET' });
return popular.json();
} catch (error) {
return error;
}
return popular;
}
async getNowPlaying(query) {
try {
const queryString = {
...query,
api_key: this._apiKey,
};
/**
* /movie/now_playing
*
* @see https://developers.themoviedb.org/3/movies/get-now-playing
* @param {Object} options Request params
* @returns {Promise} Promise
*/
async getNowPlaying(options) {
const qs = { ...this.config, ...options };
const params = new URLSearchParams();
Object.keys(queryString).forEach((key) => params.append(key, queryString[key]));
const url = `${this._baseUrl}${apiConfig.movie.now_playing}?${params}`;
const nowPlaying = await request({
url: `${apiConfig.url}${apiConfig.movie.now_playing}`, qs,
});
const nowPlaying = await fetch(url, { method: 'GET' });
return nowPlaying.json();
} catch (error) {
return error;
}
return nowPlaying;
}
async getTopRated(query) {
try {
const queryString = {
...query,
api_key: this._apiKey,
};
/**
* /movie/top_rated
*
* @see https://developers.themoviedb.org/3/movies/get-top-rated-movies
* @param {Object} options Request params
* @returns {Promise} Promise
*/
async getTopRated(options) {
const qs = { ...this.config, ...options };
const params = new URLSearchParams();
Object.keys(queryString).forEach((key) => params.append(key, queryString[key]));
const url = `${this._baseUrl}${apiConfig.movie.top_rated}?${params}`;
const topRated = await request({
url: `${apiConfig.url}${apiConfig.movie.top_rated}`, qs,
});
const nowPlaying = await fetch(url, { method: 'GET' });
return nowPlaying.json();
} catch (error) {
return error;
}
return topRated;
}

@@ -87,0 +76,0 @@ }

@@ -1,3 +0,2 @@

const fetch = require('node-fetch');
const { URLSearchParams } = require('url');
const { request } = require('../utils');

@@ -8,41 +7,35 @@ const { apiConfig } = require('../configs');

constructor(config) {
this._baseUrl = config.baseUrl || 'https://api.themoviedb.org';
this._apiKey = config.apiKey;
this._query = {
api_key: this._apiKey,
};
this.config = config;
}
/**
* /trending/{media_type}/{time_window}
*
* @see https://developers.themoviedb.org/3/trending/get-trending
* @param {string} timeWindow Time Window
* @returns {Promise} Promise
*/
async getTrending(timeWindow) {
try {
const params = new URLSearchParams();
Object.keys(this._query).forEach((key) => params.append(key, this._query[key]));
const url = `${this._baseUrl}${apiConfig.person.trending}?${params}`.replace('TIME_WINDOW', timeWindow || 'day');
const trending = await request({
url: `${apiConfig.url}${apiConfig.person.trending}`.replace('TIME_WINDOW', timeWindow || 'day'), qs: this.config,
});
const trending = await fetch(url, { method: 'GET' });
return trending.json();
} catch (error) {
return error;
}
return trending;
}
async getPopular(query) {
try {
const queryString = {
...query,
api_key: this._apiKey,
};
/**
* /person/popular
*
* @see https://developers.themoviedb.org/3/people/get-popular-people
* @param {Object} options Request params
* @returns {Promise} Promise
*/
async getPopular(options) {
const qs = { ...this.config, ...options };
const params = new URLSearchParams();
Object.keys(queryString).forEach((key) => params.append(key, queryString[key]));
const url = `${this._baseUrl}${apiConfig.person.popular}?${params}`;
const popular = await request({
url: `${apiConfig.url}${apiConfig.person.popular}`, qs,
});
const popular = await fetch(url, { method: 'GET' });
return popular.json();
} catch (error) {
return error;
}
return popular;
}

@@ -49,0 +42,0 @@ }

@@ -1,3 +0,2 @@

const fetch = require('node-fetch');
const { URLSearchParams } = require('url');
const { request } = require('../utils');

@@ -8,60 +7,52 @@ const { apiConfig } = require('../configs');

constructor(config) {
this._baseUrl = config.baseUrl || 'https://api.themoviedb.org';
this._apiKey = config.apiKey;
this._query = {
api_key: this._apiKey,
};
this.config = config;
}
/**
* /trending/{media_type}/{time_window}
*
* @see https://developers.themoviedb.org/3/trending/get-trending
* @param {string} timeWindow Time Window
* @returns {Promise} Promise
*/
async getTrending(timeWindow) {
try {
const params = new URLSearchParams();
Object.keys(this._query).forEach((key) => params.append(key, this._query[key]));
const url = `${this._baseUrl}${apiConfig.tv.trending}?${params}`.replace('TIME_WINDOW', timeWindow || 'day');
const trending = await request({
url: `${apiConfig.url}${apiConfig.tv.trending}`.replace('TIME_WINDOW', timeWindow || 'day'), qs: this.config,
});
const trending = await fetch(url, { method: 'GET' });
return trending.json();
} catch (error) {
return error;
}
return trending;
}
async getPopular(query) {
try {
const queryString = {
...query,
api_key: this._apiKey,
};
/**
* /tv/{tv_id}
*
* @see https://developers.themoviedb.org/3/tv/get-tv-details
* @param {Object} options Request params
* @returns {Promise} Promise
*/
async getPopular(options) {
const qs = { ...this.config, ...options };
const params = new URLSearchParams();
Object.keys(queryString).forEach((key) => params.append(key, queryString[key]));
const url = `${this._baseUrl}${apiConfig.tv.popular}?${params}`;
const popular = await request({
url: `${apiConfig.url}${apiConfig.tv.popular}`, qs,
});
const popular = await fetch(url, { method: 'GET' });
return popular.json();
} catch (error) {
return error;
}
return popular;
}
async getTopRated(query) {
try {
const queryString = {
...query,
api_key: this._apiKey,
};
/**
* /tv/top_rated
*
* @see https://developers.themoviedb.org/3/tv/get-top-rated-tv
* @param {Object} options Request params
* @returns {Promise} Promise
*/
async getTopRated(options) {
const qs = { ...this.config, ...options };
const params = new URLSearchParams();
Object.keys(queryString).forEach((key) => params.append(key, queryString[key]));
const url = `${this._baseUrl}${apiConfig.tv.top_rated}?${params}`;
const topRated = await request({
url: `${apiConfig.url}${apiConfig.tv.top_rated}`, qs,
});
const nowPlaying = await fetch(url, { method: 'GET' });
return nowPlaying.json();
} catch (error) {
return error;
}
return topRated;
}

@@ -68,0 +59,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc