omdbapi / OMDb-API

The Open Movie Database Bug Tracking
420 stars 21 forks source link

Image API can't find some images but info API has the poster URL #308

Open hsharghi opened 9 months ago

hsharghi commented 9 months ago

Get image via image API returns 404 for the following movie http://img.omdbapi.com/?i=tt2934286&apikey= But when getting info for the same id http://www.omdbapi.com/?i=tt2934286&apikey= poster url is present and is working fine. info API response:

{
...
  "Poster": "https://m.media-amazon.com/images/M/MV5BOTZkNjllMzYtY2ZiNi00YTdkLTg0OTEtZTgzOGY5Njc3NmNiXkEyXkFqcGdeQXVyMTUzMTg2ODkz._V1_SX300.jpg",
...
}

Why image and info API work differently? Does image API get image data from url provided in info API?

Fensterbank commented 3 months ago

I assume that omdbapi only hosts the poster on their CDN, if there is not an external Poster url defined. Probably a way to save bandwitdh and storage space.

In my code, I try to fetch the poster from img.omdbapi and if it returns a 404 and we have Poster url defined, I download this one.

let posterFileName = await fetchPoster(imdbID)

// if posterFileName is null but we have entryData.Poster, then we download the referenced image and save it
if (!posterFileName && entryData.Poster) {
  posterFileName = await downloadPoster(imdbID, entryData.Poster)
}

This seems to work in 100% of the cases, so it's either hosted on their side or referenced in Poster.