ThomasPortolano / movie-watchlist

3rd scrimba solo project - building a movie watchlist using OMDB API
0 stars 0 forks source link

Mapping genre ID with readable words #2

Closed ThomasPortolano closed 9 months ago

ThomasPortolano commented 9 months ago

TMDB returns genre ID instead of words. I need to find a technical solution to return the corresponding strings to the user.

ThomasPortolano commented 9 months ago

The API https://api.themoviedb.org/3/movie/{movie_id} hold both the genre ID and the genre in string.

So I will need to:

  1. store the movie ID first from the search movie API
  2. pass the movie ID to the Details API
  3. grab the array that contains genre
  4. render the array in the DOM

For example:


  "adult": false,
  "backdrop_path": "/8UHbmR3WP86BspfwZZPgsVxxCFJ.jpg",
  "belongs_to_collection": null,
  "budget": 0,
  "genres": [
    {
      "id": 16,
      "name": "Animation"
    },
    {
      "id": 35,
      "name": "Comedy"
    },
    {
      "id": 28,
      "name": "Action"
    },
    {
      "id": 10751,
      "name": "Family"
    },
    {
      "id": 878,
      "name": "Science Fiction"
    }
  ]}
  "homepage": "https://www.warnerbros.com/movies/scooby-doo-batman-brave-and-bold",
  "id": 484862,
  "imdb_id": "tt7578566",
  "original_language": "en",
  "original_title": "Scooby-Doo! & Batman: The Brave and the Bold",
  "overview": "Scooby-Doo and the Mystery Inc. gang meet up with Batman and other friends to defeat evil villains and save the day.",
  "popularity": 20.457,
  "poster_path": "/hSPeF1zoYH8kCOhFMu7x3B55zu6.jpg",
  "production_companies": [
    {
      "id": 1353,
      "logo_path": "/yXhCcOFK5Fy3ZBQwhBYx8Zu9ZIw.png",
      "name": "Hanna-Barbera Productions",
      "origin_country": "US"
    },
    {
      "id": 2785,
      "logo_path": "/l5zW8jjmQOCx2dFmvnmbYmqoBmL.png",
      "name": "Warner Bros. Animation",
      "origin_country": "US"
    },
    {
      "id": 9993,
      "logo_path": "/2Tc1P3Ac8M479naPp1kYT3izLS5.png",
      "name": "DC Entertainment",
      "origin_country": "US"
    },
    {
      "id": 429,
      "logo_path": "/2Tc1P3Ac8M479naPp1kYT3izLS5.png",
      "name": "DC Comics",
      "origin_country": "US"
    }
  ],
  "production_countries": [
    {
      "iso_3166_1": "US",
      "name": "United States of America"
    }
  ],
  "release_date": "2018-01-31",
  "revenue": 0,
  "runtime": 76,
  "spoken_languages": [
    {
      "english_name": "English",
      "iso_639_1": "en",
      "name": "English"
    }
  ],
  "status": "Released",
  "tagline": "",
  "title": "Scooby-Doo! & Batman: The Brave and the Bold",
  "video": false,
  "vote_average": 7.283,
  "vote_count": 217
}```
ThomasPortolano commented 9 months ago

Closing, fixed with last commit (MW-#2-mapping-genre-id)