r/programmingrequests • • Jun 17 '18

Making this API code bring through more relevant data?

I have this code I have written here:

https://jsfiddle.net/dfwq57pz/

However the code does not bring up relevant/modern movies, it brings up random movies that I have never heard of, also I can't get it to skip the movies it does not find.

I wanted to do something like on this website:

https://www.randomlists.com/random-movies?qty=1&dup=false

But it is impossible to contact the owner, view the sites source code etc... I presume they have done it on the backend.

I am thinking I would need to do something as per:

https://developers.themoviedb.org/3/discover/movie-discover

However, when I try to amend my code in the above JSFiddle it does not work. An attempt as such can viewed here:

https://pastebin.com/RkrZ2WKz

Overall to reiterate I want to:

1 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Jun 17 '18

UPDATE 2: I just noticed in your code you took the genre part out, I tried to get this working according to the docs but I failed:

https://jsfiddle.net/rgqtbLnu/

1

u/tresteo Jun 17 '18

The problem with the genres is, that you only get the ids of the genres.

You will probably need to get the list of genres before loading the movies. The list is available from this endpoint: https://developers.themoviedb.org/3/genres/get-movie-list

You can then lookup the correct name for each genre_id per result.