Giter VIP home page Giter VIP logo

moviedb-promise's Introduction

moviedb-promise

npm

A Node library that makes the interaction with themoviedb.org V3 API easy... Now in TypeScript!

This was originally a pull request that went stale, so it's its own package now. The original package developed by Dan Zajdband uses callbacks to handle the asynchronous nature of Node, while this package uses native Promises.

The main credit goes to the original moviedb package by Dan Zajdband.

What is themoviedb.org?

The Movie Database (TMDB) is a community built project that stores data about movies and television shows. The project started in 2008 and has become one of the largest databases in the world. There are few databases with the vast data TMDB provides. In addition, TMDB gives special attention to international content which is often difficult to find on other databases. TMDB supports 39 different languages and is currently used in 180 countries.

In addition to information about actors, directors, production years, movie titles, genres, etc., TMDB also provides high resolution posters and fanart that can easily be incorporated into personal projects. The size of the image database is vast and growing at a rate of 1000 images a day. TMDB processes over 3 billion requests by millions of users daily.

The vast amount of data gathered and stored by TMDB can be accessed via its API. With a key and a URL, making a request is simple. However, managing all the requests needed to create say, a movie rating website, would be quite the task. You'd have to create a function for every type of request needed. That's where moviedb-promise comes in. With it's suite of over 100 functions, moviedb-promise makes interacting with TMDB easy.

Changelog for v4

  • Updated dependencies that may not support lower versions of Node
  • Implemented a throttle for Cloudflare rate limiting (#72) (thanks @alexanderroidl)

Changelog for v3

  • Each tmdb function has the correct parameter and response types based on the documentation
  • append_to_response should be added to the request parameter of the appropriate functions and not on the options
  • The last parameter to each function can be an axios config object and will overwrite anything on the underlying request.
  • Several functions have been renamed.
  • Search functions accept a string and will be used for the query property.

Changelog for v2

  • Source has been ported to TypeScript.
  • Rate limiting was removed by tmdb. The functionality had remained, but has since been removed in v2. If you wish to add it back, you're welcome to open a PR to discuss its need.
  • The MovieDb class has been moved to be a property of the package export. You will need to reference the MovieDb property of the export in order to instantiate the class. See usage below for an example.
  • The constructor has been changed to accept only two parameters: an api key and the base url for tmdb.
  • The session() function has been renamed to retrieveSession()
  • Requests were previously made using superagent as it was used by the original moviedb package. It has been replaced with axios now.

Integrations

Installation

npm install moviedb-promise --save

Usage

Require the module and instantiate the class with your themoviedb.org api key.

const { MovieDb } = require('moviedb-promise')
const moviedb = new MovieDb('your api key')

async/await reminder

All functions return a Promise, which means that you can also use async/await. The caveat of using await when making function calls is that the await has to be within a function that has been declared async. Keep that in mind if you plan to use await.

Examples

// Using just the Promise
moviedb
  .searchMovie({ query: 'Alien' })
  .then((res) => {
    console.log(res)
  })
  .catch(console.error)

// Using await
// You probably wouldn't ever use it this way...
;(async function () {
  try {
    const res = await moviedb.searchMovie({ query: 'alien' })
    console.log(res)
  } catch (e) {
    console.log(e)
  }
})()

// This is a more reasonable example
const findMovie = async (title) => {
  // Equivalant to { query: title }
  const res = await moviedb.searchMovie(title)

  return res
}

try {
  const results = findMovie('alien')
} catch (e) {
  // Do something
}

or

moviedb
  .movieInfo({ id: 666 })
  .then((res) => {
    console.log(res)
  })
  .catch(console.error)

or

controller file example that

  • uses async await
  • reads from a .env file
  • includes parameters
  • handles errors
import { MovieDb } from 'moviedb-promise'
import dotenv from 'dotenv'

dotenv.config()

const moviedb = new MovieDb(process.env.KEY)

const newError = (name) => {
  const e = new Error(name)
  e.name = name
  return Promise.reject(e)
}

export const searchMovie = async (req) => {
  const parameters = {
    query: req.query.name,
    page: req.query.page,
  }
  try {
    const res = await moviedb.searchMovie(parameters)
    return res.results
  } catch (error) {
    return newError(error)
  }
}

export const searchPerson = async (req) => {
  const parameters = {
    query: req.query.name,
    page: 1,
  }
  try {
    const res = await moviedb.searchPerson(parameters)
    return res.results
  } catch (error) {
    return newError(error)
  }
}

export const movieKeywords = async (req) => {
  try {
    const res = await moviedb.movieKeywords({ query: req.query.name })
    return res.results
  } catch (error) {
    return newError(error)
  }
}

Some endpoints, such as watchlist endpoints, have an optional account id parameter. If you have a session id, you don't need to provide that parameter.

// This is the same as calling it as
// moviedb.accountMovieWatchlist({ id: '{account_id}' })
moviedb.sessionId = 'my-cached-session-id'
moviedb
  .accountMovieWatchlist()
  .then((res) => {
    // Your watchlist items
    console.log(res)
  })
  .catch(console.error)

// Creating a session id would look something like this
moviedb
  .requestToken()
  .then((token) => {
    // Now you need to visit this url to authorize
    const tokenUrl = `https://www.themoviedb.org/authenticate/${token}`
  })
  .catch(console.error)

// After that has been authorized, you can get the session id
moviedb
  .retrieveSession()
  .then((sessionId) => {
    // Probably cache this id somewhere to avoid this workflow
    console.log(sessionId)

    // After the sessionId is cached, the next time use instantiate the class,
    // set the sessionId by moviedb.sessionId = 'my-session-id'

    // This can be called now because sessionId is set
    moviedb
      .accountMovieWatchlist()
      .then((res) => {
        // Your watchlist items
        console.log(res)
      })
      .catch(console.error)
  })
  .catch(console.error)

Available methods

The Function column lists all the available functions in the class. The Endpoint column lists possible request parameters (placeholders prefixed with :) needed for the call. If the endpoint doesn't have any placeholders, check out the documentation for the query parameters you can use.

Examples

Function Endpoint
tvInfo tv/:id
// Two ways:
// The object key matches the placeholder name
moviedb.tvInfo({ id: 61888 }).then(...)

// Or for simplicity, if it only has one placeholder
moviedb.tvInfo(61888).then(...)
Function Endpoint
searchMovie search/movie

There aren't any placeholders, but the documentation shows there are language, query, page, include_adult, region, year, and primary_release_year available to use. Each expects a certain data type or format, so check out the docs for the details.

const parameters = {
  query: 'Kindergarten Cop',
  language: 'fr' // ISO 639-1 code
}

moviedb.searchMovie(parameters).then(...)

Complete function list

Function
configuration
countries
jobs
languages
primaryTranslations
timezones
find
searchCompany
searchCollection
searchKeyword
searchMovie
searchMulti
searchPerson
searchTv
searchList
collectionInfo
collectionImages
collectionTranslations
discoverMovie
discoverTv
trending
movieInfo
movieAccountStates
movieAlternativeTitles
movieChanges
movieCredits
movieExternalIds
movieImages
movieKeywords
movieReleaseDates
movieVideos
movieWatchProvidersForId
movieWatchProviders
movieTranslations
movieRecommendations
movieSimilar
movieReviews
movieLists
movieRatingUpdate
movieRatingDelete
movieLatest
movieNowPlaying
moviePopular
movieTopRated
upcomingMovies
tvInfo
tvAccountStates
tvAlternativeTitles
tvChanges
tvContentRatings
tvCredits
episodeGroups
tvExternalIds
tvImages
tvKeywords
tvRecommendations
tvReviews
tvScreenedTheatrically
tvSimilar
tvTranslations
tvVideos
tvWatchProvidersForId
tvWatchProviders
tvRatingUpdate
tvRatingDelete
tvLatest
tvAiringToday
tvOnTheAir
tvPopular
tvTopRated
seasonInfo
seasonChanges
seasonAccountStates
seasonCredits
seasonExternalIds
seasonImages
seasonVideos
episodeInfo
episodeChanges
episodeAccountStates
episodeCredits
episodeExternalIds
episodeImages
episodeTranslations
episodeRatingUpdate
episodeRatingDelete
episodeVideos
personInfo
personChanges
personMovieCredits
personTvCredits
personCombinedCredits
personExternalIds
personImages
personTaggedImages
personTranslations
personLatest
personPopular
creditInfo
listInfo
listStatus
createList
createListItem
removeListItem
clearList
deleteList
genreMovieList
genreTvList
keywordInfo
keywordMovies
companyInfo
companyAlternativeNames
companyImages
accountInfo
accountLists
accountFavoriteMovies
accountFavoriteTv
accountFavoriteUpdate
accountRatedMovies
accountRatedTv
accountRatedTvEpisodes
accountMovieWatchlist
accountTvWatchlist
accountWatchlistUpdate
changedMovies
changedTvs
changedPeople
movieCertifications
tvCertifications
networkInfo
networkAlternativeNames
networkImages
review
episodeGroup

Support for append_to_response

The movieInfo, tvInfo, seasonInfo, episodeInfo and personInfo methods support an option to specify the TMDB API's append_to_response query parameter. This makes it possible to make sub requests within the same namespace in a single HTTP request. Each request will get appended to the response as a new JSON object.

In order to receive type support for the items returned with an append_to_response request, you'll need to cast the attributes as their appropriate type. Note this requires you to be using TypeScript.

const response = await moviedb.movieInfo({ id: tmdbId, append_to_response: "release_dates" })
  as MovieResponse & { release_dates: MovieReleaseDatesResponse }

In this case, response.release_dates will be cast as MovieReleaseDatesResponse since it's not in the default MovieResponse that gets returned with movieInfo().

const res = await api.tvInfo({
  id: 4629,
  append_to_response: 'season/1,season/1/credits',
})

Request Options

The last parameter of the endpoint function calls is an axios request config object. Those settings will overwrite anything on the underlying request.

// Add a timeout restriction to the request
const res = await api.tvInfo(4629, { timeout: 10000 })

or when combining multiple options append_to_response is desired:

const res = await api.tvInfo(
  {
    id: 4629,
    append_to_response: 'season/1,season/1/credits',
  },
  {
    timeout: 10000,
  },
)

Contributing

First, thanks for taking the time!

Testing

  • Before submitting a pull request, please run npm run test
  • Make sure all tests pass before submitting a pull request
  • Add tests from any features you add

Submitting changes

Please submit a pull request with an outline of what you've added/changed/removed. When you submit your code, please include examples and make sure that you submit one feature per commit.

Syntax guidelines

  • Use TypeScript
  • Run npm run format before submitting to let Prettier handle the formatting
  • Avoid code that is platform dependent

Documentation guidelines

  • Use Markdown
  • Reference a class with [ClassName]
  • Reference an instance of a class with [Classname::methodName]
  • Reference a method in class with [Classname.methodName]

License

MIT

moviedb-promise's People

Contributors

alexanderroidl avatar bdjessup avatar carlcrede avatar chadacious avatar ddvega avatar gielcobben avatar grantholle avatar griest024 avatar gutala avatar irwing-reza avatar itsjinendrajain avatar j0053f avatar jbarrus avatar jeb5 avatar jnorris441 avatar lucafaggianelli avatar mike-grant avatar mithunm93 avatar mocanew avatar odysseaspapadimas avatar shabith avatar shaunlwm avatar shaypet avatar subjunk avatar thidasapankaja avatar vbenny42 avatar wrherbert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moviedb-promise's Issues

Missing return types and RequestParams is not suitable for many methods

I just saw that you ported the lib to TS... that's amazing, as I'm porting my app as well!

I have some issues with functions params and return types:

  • searchX returns any and accepts RequestParams as input but it's missing year, query options

Actually, RequestParams seems to be used in many methods, also in tvEpisodeInfo(), where I would expect seasonNumber and episodeNumber.

WatchProvider type is not exported

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch [email protected] for the project I'm working on.

I had to do this, because I realised that you cannot use the WatchProvider type, as it is not exported.

Here is the diff that solved my problem:

diff --git a/node_modules/moviedb-promise/dist/request-types.d.ts b/node_modules/moviedb-promise/dist/request-types.d.ts
index ffec639..91e5c2d 100644
--- a/node_modules/moviedb-promise/dist/request-types.d.ts
+++ b/node_modules/moviedb-promise/dist/request-types.d.ts
@@ -567,7 +567,7 @@ interface WatchProviderCountry {
     flatrate?: Array<WatchProvider>;
     flatrate_and_buy?: Array<WatchProvider>;
 }
-interface WatchProvider {
+export interface WatchProvider {
     display_priority?: number;
     logo_path?: string;
     provider_id?: number;

Unexported interfaces

The interfaces WatchProviderCountry and WatchProvider are not exported, it would be useful to have these exported so they can be easier used by implementers.

Support for Deno runtime

Is support for Deno planned? I see that Axios is a major dependency of this project, and Deno doesn't really have that, so compatibility might be a hard thing to achieve.

type probably incorrect

docs

moviedb-promise wants an id passed, but I see no reason why and in the docs of tmdb the id parameter for top rated movies is not given either

"Too Many Requests" -error when using default rate limiter

When using the default rate limiter, the module consistently gives a "Too Many Requests" -error when lots of queries are sent in a quick succession. For example, the following code seems to always throw this error after a few seconds:

const moviedb = new MovieDB(API_KEY);

for (var i = 0; i < 21; i++) {
    moviedb.searchMovie({ query: "Movie Name" })
        .then(data => {
            console.log(data);
        })
        .catch(err => {
            console.error(err);
        });
}

Discussion

Firstly, I would like to congratulate you on taking initiative for this project. πŸ‘

I like the switch to Promises, but I'm wondering why you didn't go all the way and use async/await.

Also, I think that the examples in the readme should be using async/await so that they are simpler.

API token is requested multiple times when sending multiple queries in a quick succession

When sending multiple queries in a quick succession, the module requests the MovieDB API token multiple times, even though it should only request it once. This leads to wasted API calls and it fills up the rate limit. Here's a simple example:

const moviedb = new MovieDB(API_KEY);

for (var i = 0; i < 20; i++) {
    moviedb.searchMovie({ query: "Movie Name" })
        .then(data => {
            console.log(data);
        })
        .catch(err => {
            console.error(err);
        });
}

In this case the module requests a new API token for each of the requests. This leads to a total of 40 requests, instead of 21. This could be fixed by checking if a token is already being requested, and waiting for that request to resolve.

Axios missing from dependencies

Upgraded to 2.1.0 from 1.5 and now I get this error

Error: Cannot find module 'axios'

Looks like axios is only included in devDependencies and not in dependencies within package.json

.tvInfo Problem

Hi I'm trying to pull data with tvInfo
I'm success with pulling data but I can't specify a language parameter
pls Help
Here is my code;
moviedb .tvInfo('66732') .then((resInfo) => { console.log(resInfo) })

Possible issue in the documentation : Submitted a pull request

In Installation part of the documentation it mention to install the module by npm install moviedb-promise --save
But in Usage it mention to use moviedb module instead of moviedb-promise

const MovieDb = require('moviedb')
const moviedb = new MovieDb('your api key')

So Isn't the usage should be

const MovieDb = require('moviedb-promise')
const moviedb = new MovieDb('your api key')

instead.

Export types from `index.ts`

Please export all your types from index.ts. Currently I'm having to do import type {MovieResult, PersonResult, TvResult} from 'moviedb-promise/dist/request-types' which is evil.

Cannot read property 'makeRequest' of undefined

gettings an error "Cannot read property 'makeRequest' of undefined" when calling "movieInfo"

const { MovieDb } = require('moviedb-promise');
const moviedb = new MovieDb(process.env.MOVIEDB_API_KEY);

let a = moviedb.movieInfo({ id: req.params.entityId });

Changelog

Hi, thanks for this library, it's great!
It would be useful to either include a changelog.md or do GitHub releases so it's easier to see what has changed between versions

movieDb is not a constructor

After setting up the file and importing the package. When I run the script it gives the following error.

TypeError: movieDb is not a constructor

Here's my code:

const {movieDb} = require('moviedb-promise')
const moviedb = new movieDb('my-key')

const findMovie = async title => {
    // Equivalant to { query: title }
    const res = await moviedb.searchMovie(title)
   
    return res
  }
   
  try {
    const results = findMovie('alien')
    console.log(results)
  } catch (e) {
    console.log(e)
  }

find function throws 404

Hi,

The find function seems outdated and not to work anymore. It throws a 404 error every I call it.

According to The Movie Database's API documentation, the parameters should be an external_id (in the path), an external_source and optionally a language.

I believe the current implementation of the find function is bugged because:

  1. Its params parameter is of type string | number | FindRequest | undefined which doesn't make sense, you can't pass a single string/number for it to work.
  2. FindRequest (which extends Request) has id: ExternalId (on top of external_source?: 'imdb_id' | 'freebase_mid' | ...) where ExternalId is an enum containing something similar to external_source:
export enum ExternalId {
    ImdbId = "imdb_id",
    Freebase_Mid = "freebase_mid",
    ...
}

Here is an example code using the current version:

import { MovieDb } from "moviedb-promise";

const moviedb = new MovieDb("xxx");

// Instagram
moviedb.find("avengers");  // Error: Request failed with status code 404

// IMDb
moviedb.find("tt0959621"); // Error: Request failed with status code 404

// TheTVDB non-existing ID
moviedb.find("0");         // Error: Request failed with status code 404

Here would be an example code of the expected usage:

import { MovieDb } from "moviedb-promise";

const moviedb = new MovieDb("xxx");

// Instagram (URL: https://api.themoviedb.org/3/find/avengers?api_key=xxx&language=en-US&external_source=instagram_id)
moviedb.find({ id: "avengers", external_source: "instagram_id" });
// { movie_results: [ { title: "Avengers: Endgame", ... }, { title: "Avengers: Infinity War", ... } ], person_results: [], tv_results: [], tv_episode_results: [], tv_season_results: [] }

// IMDb (URL: https://api.themoviedb.org/3/find/tt0959621?api_key=xxx&language=en-US&external_source=imdb_id)
moviedb.find({ id: "tt0959621", external_source: "imdb_id" });
// { movie_results: [], person_results: [], tv_results: [], tv_episode_results: [ { name: "Pilot", ... } ], tv_season_results: [] }

// TheTVDB non-existing ID (URL: https://api.themoviedb.org/3/find/0?api_key=xxx&language=en-US&external_source=tvdb_id)
moviedb.find({ id: "0", external_source: "tvdb_id" });
// { movie_results: [], person_results: [], tv_results: [], tv_episode_results: [], tv_season_results: [] }

Replace axios with fetch global function

Fetch was added to node v18 without the experimental flag. Deno and Bun both have support for it, so it makes the most sense to refactor to use fetch and release a new major version with v18 of node being the minimum version.

appendToResponse with typescript question...

I'm just getting into typescript, and attempting to implement the latest moviedb-promise in my project. Where I'm stuck is in how to specify the type when including appendToResponse in my movieInfo call.

I thought maybe I could use typescript intersection but it doesn't seem to work:

      const mainInfo = (await moviedb.movieInfo(
        {
          id: tmdbId,
          append_to_response:
            "credits,release_dates",
        },
        {
          timeout: LONG_AXIOS_TIMEOUT,
        }
      )) as MovieResponse & MovieReleaseDatesResponse & CreditsResponse;

So then I figured I could at least cast the mainInfo from above into what I wanted, but that isn't quite working either, I just get undefined:
const releaseDatesUS = (mainInfo as MovieReleaseDatesResponse).results
returns undefined.

How do I properly access the appendToResponse props that are not included in MovieResponse?

Allow for specifying a timeout parameter

Now that the append_to_response option is available, I have encountered some request timeout errors. I'll make a pull request to add the option to provide a timeout argument to the current methods.

TMDB Stremio Addon

Hello, your work is incredible, I would like to know if you are not interested in taking this to Stremio, today it is a shortcoming of them the question of information about films and series, because they use an imdb scraping system, not all titles and updates take time to happen, you can also participate in the competition of addons that this year has a prize of U $ 5,000.00, if you are interested it will get a lot to the community that is still very small.

Here the Stremio documentation: https://github.com/Stremio/stremio-addon-sdk/tree/f02ad7337429805e5651402343920171bfae1ce0/docs

Here the competition announcement: https://www.stremio.com/competition

If you want help you can call me on Discord: mrcanelas#3552

[Help Wanted] Fetching Multiple person name and images

Hi, There's no issue. I am just a beginner developer and couldn't understand how to fulfill my requirement. Please help. I want to fetch multiple celebrities and store only their name and images into my database.

How can I fetch multiple celeb pics, their names, and gender without making the requests too much complicated? Here's the initial request that I made. But If I want to fetch 150,000 celebs that'll be a nightmare. Please provide any code example. that'll make it easier for me to fetch celebs.

const personPic = async () => {
  const person1 = await moviedb.personInfo('78080')
  const config = await moviedb.configuration()
  console.log(`${person1.name}`)
  console.log(
    `${config.images.secure_base_url}${config.images.profile_sizes[2]}${person1.profile_path}`
  )
}

personPic()

Nullable types on everything

Is there some unexpected reason why is every single field on every type is nullable? Surely things like id are guaranteed to be returned by the API at least.

async/await clarification

How can I achieve this

routes.get('/search/:movie', (req, res) => {
    console.log(req.params.movie);
    movie = req.params.movie;
    moviedb.searchMovie({ query: 'Alien' }).then(result => {
        res.send(result);
      }).catch(console.error);
});

with async/await here ?

Tnterface Translation is diffent from API Reference

package:"moviedb-promise": "^3.4.0"

//node_modules/moviedb-promise/dist/request-types.d.ts
export interface Translation {
    iso_3166_1?: string;
    iso_639_1?: string;
    name?: string;
    english_name?: string;
    data?: {
        title?: string;
        overview?: string;
        homepage?: string;
    };
}

It should be translation.data.name rather than translation.data.title

image

image

Incorrect type for providers

The interface WatchProviderCountry is incorrect.

Is:

interface WatchProviderCountry {
    link?: string;
    rent?: Array<WatchProvider>;
    buy?: Array<WatchProvider>;
    flatrate?: Array<WatchProvider>;
    flatrate_and_buy?: Array<WatchProvider>;
}

Should be:

interface WatchProviderCountry {
    link?: string;
    rent?: Array<WatchProvider>;
    buy?: Array<WatchProvider>;
    flatrate?: Array<WatchProvider>;
    ads?: Array<WatchProvider>;
    free?: Array<WatchProvider>;
}

The TMDB API documentation is incorrect as is reported here:

ECONNRESET

API queries cause a ECONNRESET

read ECONNRESET at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27)

To reproduce,
make a search movie call repetitively, the error is generated after random number of iterations. (hardly after 2-3 iteration)

The issue seems to be related to AXIOS - handling params in the GET request. Tried doing repetitive API calls with axios with API key and the search string as param.
thanks

Use of sequential requests

Out of curiosity, why does this library only send requests sequentially with a queue system? Why not support parallel requests? It would allow me to optimise by doing things like this:

const movieIds = ['1', '2', '3']
const movies = await Promise.all(movieIds.map(id => moviedb.movieInfo({id}))

Test "should only request one token" fails

moviedb-promise/index.js

Lines 44 to 47 in dbc442a

async requestToken () {
if (!this.token || Date.now() > new Date(this.token.expires_at).getTime()) {
this.token = await this.makeRequest('get', {}, endpoints.authentication.requestToken)
}

The await was purposely removed so that requestToken will return immediately and the user will await on the same variable if multiple calls were made before the first response was received.

Since the user it's already expecting a promise (extract from README.md):

// Creating a session id would look something like this
moviedb.requestToken().then(token => {
  // Now you need to visit this url to authorize
  const tokenUrl = `https://www.themoviedb.org/authenticate/${token}`
}).catch(console.error)

we can return the makeRequest promise directly.

"should only request one token" test should have caught this but it doesn't seem to fail everytime with the broken version. I think it depends on the speed of the first request and can't find a way to correctly test this (first world problems? πŸ˜…).

ShowResponse - next_episode_to_air?

I noticed that the ShowResponse interface includes this: next_episode_to_air?: null;

Shouldn't this be next_episode_to_air?: SimpleEpisode; , the same as this: last_episode_to_air?: SimpleEpisode;?

Here's a snippet from the response from TMDB:

"last_episode_to_air": {
    "id": 3587355,
    "name": "Coming Home",
    "overview": "The DMA approaches Earth and Ni’Var. With evacuations underway, Burnham and the team aboard the U.S.S. Discovery must find a way to communicate and connect with a species far different from their own before time runs out.",
    "vote_average": 6.4,
    "vote_count": 14,
    "air_date": "2022-03-17",
    "episode_number": 13,
    "episode_type": "finale",
    "production_code": "",
    "runtime": 60,
    "season_number": 4,
    "show_id": 67198,
    "still_path": "/8aqDSsMHFPReRhzwTcFmXBGQ2A2.jpg"
  },
  "name": "Star Trek: Discovery",
  "next_episode_to_air": {
    "id": 4596046,
    "name": "Red Directive",
    "overview": "Captain Burnham and the U.S.S. Discovery are sent to retrieve a mysterious 800-year-old Romulan vessel; until the artifact hidden inside is stolen, leading to an epic chase. Meanwhile, Saru is offered the position of a lifetime, and Tilly's efforts to help pull her into a tangled web of secrecy.",
    "vote_average": 6,
    "vote_count": 2,
    "air_date": "2024-04-04",
    "episode_number": 1,
    "episode_type": "standard",
    "production_code": "",
    "runtime": 60,
    "season_number": 5,
    "show_id": 67198,
    "still_path": "/z7kLGr1712Dn2R0upkwom8uwOiI.jpg"
  },

Some request URLs are wrong (extra slash prefix)

I was trying to call movieExternalIds and getting 404s - eventually managed to figure out what URL it was actually sending, and it looks like https://api.themoviedb.org/3//movie/123/external_ids. Note the extra slash after 3//, which is caused by a leading slash in the string used by movieExternalIds.

It looks like one other method also has this, episodeChanges. Both should have the leading slash removed so they work correctly.

For now I can work around the issue by manually specifying the url in the Axios options, though it's kind of silly to be doing with an API client library.

personInfo missing IdAppendToResponseRequest

The docs say tvSeasonInfo (seasonInfo), tvEpisodeInfo (episodeInfo) and personInfo should also allow you to append more fields

personInfo doesn't allow IdAppendToResponseRequest

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.