lacymorrow / movie-trailer

📽 Fetch movie trailers: "Crash" ➔ http://path/to/trailer
https://www.npmjs.com/package/movie-trailer
MIT License
34 stars 8 forks source link

Cannot fetch TV trailers from TMDB #5

Closed meet1807 closed 1 year ago

aingc commented 3 years ago

Looks like it's because the public API key they use in this current iteration of movie-trailer is invalid. I am having the same problem.

lacymorrow commented 3 years ago

Ah I'm so sorry @meet1807, I didn't see this until now. I'll try to have it fixed this weekend.

lacymorrow commented 3 years ago

It seems to be working now, I'm worried that an API limit has been added that is being hit. Will look into this further.

Patryk-Szylin commented 3 years ago

hey, any news ? I'm having the same issue

lacymorrow commented 3 years ago

TMDB claims not to have a rate limit but something is preventing a response:

As of December 16, 2019, we have disabled the API rate limiting. If you have any questions about this, please head over to https://www.themoviedb.org/talk/category/5047958519c29526b50017d6.

lacymorrow commented 3 years ago

Can someone post an error they are having?

lacymorrow commented 3 years ago

For those willing to test, I've published version 2.0.7 which supports a custom api_key using the flag --api_key or -k.

You can get a free key here: https://developers.themoviedb.org/

That said, I would really like to fix the issue so please post errors if possible.

lacymorrow commented 3 years ago

TV shows are not supported by this library, I will be publishing a similar library soon. Please post any errors you are receiving.

AarshOza commented 3 years ago

The issue still persists

lacymorrow commented 3 years ago

Hi @AarshOza, can you elaborate on what is happening and post any errors?

lacymorrow commented 3 years ago

Please post steps to replicate the error.

Tarek-23 commented 3 years ago

Hello @lacymorrow , the error occurs when attempting to fetch a resource from the search/movie endpoint because the API key is undefined. Since the id of the film cannot be retrieved due to the invalid API key, the second request to /movie/{id} is sent as undefined as well and will always return a 404.

The full request to the /search endpoint --> https://api.themoviedb.org/3/search/movie?api_key=undefined&query=Fate:%20The%20Winx%20Saga and returns an Invalid API key response.

The second request to the /movie/{id} endpoint --> https://api.themoviedb.org/3/movie/undefined/videos?api_key=9d2bff12ed955c7f1f74b83187f188ae and returns a "resource not found". Interestingly, the API key is present here but not in the first request.

Hope this helps!

Tarek-23 commented 3 years ago

The error occurs when attempting to fetch a resource from the search/movie endpoint because the API key is undefined. Since the id of the film cannot be retrieved due to the invalid API key, the second request to /movie/{id} is sent as undefined as well and will always return a 404.

I just tried fetching the resource using a custom api_key flag and that seemed to fix the errors. The issues are: A. The api_key flag in the first API call does not set to your API key by default if a custom API key is not provided B. The error handling from the first API call does not work and passes the undefined response to the second API call to fetch the trailers.

lacymorrow commented 3 years ago

Thanks for confirming @Tarek-23, I've added a few features and fixed the error handling in the most recent version, 2.1.0: https://github.com/lacymorrow/movie-trailer/releases/latest

lacymorrow commented 3 years ago

Leaving this open as the original issue still stands, this library only supports movies, not TV shows.

sum1112 commented 2 years ago

Hey, I have a suggestion to make which I observed during building react web app in which I fetched movie trailer link using this API but wasn't able to receive for many of the movies, shows even after supplying their tmdb id as the parameters. Why don't we use youtube API internally to fetch trailers, and using parameters such as length of trailer < 4min, sort by relevance, and then picking 1st link from the array of links received. What do you think @lacymorrow

lacymorrow commented 2 years ago

I'm hesitant to switch APIs for a few reasons, if anyone is currently using the library it will drastically change the results/order in some cases. The bigger issue is that YouTube will return videos that are not necessarily the corresponding movie trailer, just close keyword matches. This means developers won't be able to rely on the videos being correct.

I'll think about it, but I'd probably create a new library if I wanted to switch APIs

calvieTech commented 2 years ago

Hey I am also having issues with this API! Apparently my trailerURL returns as undefined

calvieTech commented 2 years ago

I think the movieTrailer constructor is not recognizing the movieId for some reason?

lacymorrow commented 2 years ago

What is the movieId you're using that's failing?

lacymorrow commented 1 year ago

@calvieTech

What is the movieId you're using that's failing?

calvieTech commented 1 year ago

Nvm I fixed it @lacymorrow thanks