RBangel / weneedtowatch

0 stars 1 forks source link

Feature: Pull some fields from IMDB #4

Open McPolemic opened 6 years ago

McPolemic commented 6 years ago

This could probably be done via JS, but I don't really like JS.

IMDB has an autocomplete API that is called without authentication. It can give us the following fields with little effort:

After inputting a title, we could have an interstitial that asks if any of the following movies are what we meant, rendering thumbnails of the poster, the title, and the year. They can also skip and just enter in what was entered.

Sample Queries

curl -s 'https://v2.sg.media-imdb.com/suggests/a/arrival.json'
curl -s 'https://v2.sg.media-imdb.com/suggests/m/mission+impossible.json'

Sample Response (Arrival)

Note that it returns JSONP, so we'd have to remove the wrapping function call

imdb$arrival({"v":1,"q":"arrival","d":[{"l":"Arrival","id":"tt2543164","s":"Amy Adams, Jeremy Renner","y":2016,"q":"feature","i":["https://images-na.ssl-images-amazon.com/images/M/MV5BMTExMzU0ODcxNDheQTJeQWpwZ15BbWU4MDE1OTI4MzAy._V1_.jpg",1311,2048]},{"l":"The Arrival","id":"tt0115571","s":"Charlie Sheen, Lindsay Crouse","y":1996,"q":"feature","i":["https://images-na.ssl-images-amazon.com/images/M/MV5BMzhiN2M1NGUtOWVmNi00YWU1LWJlNGMtZDMzYjkwZTQ4MmY4XkEyXkFqcGdeQXVyNjc2NDI1ODA@._V1_.jpg",750,1104]},{"l":"Dead on Arrival","id":"tt5903088","s":"Christa B. Allen, Scottie Thompson","y":2017,"q":"feature","i":["https://images-na.ssl-images-amazon.com/images/M/MV5BYTU3Mjg1YTgtNjMyMy00ZTg1LWFlNGUtMjhiMTBlOGZmMTBkXkEyXkFqcGdeQXVyMjA0NjgxOTk@._V1_.jpg",668,1014]},{"l":"Departures","id":"tt4859168","s":"Nina Dobrev, Maisie Williams","y":2018,"q":"feature"},{"l":"Arrival II","id":"tt0122961","s":"Patrick Muldoon, Jane Sibbett","y":1998,"q":"feature","i":["https://images-na.ssl-images-amazon.com/images/M/MV5BMjA2MDI3NjcyN15BMl5BanBnXkFtZTcwOTMxOTUyMQ@@._V1_.jpg",261,475]},{"l":"Arrivals","id":"tt3779852","s":"Amrita Acharia, Philip Arditti","y":2016,"q":"feature"},{"l":"Arrival","id":"tt3831316","s":"Scott St. Patrick, Scott St. Patrick","q":"feature"},{"l":"Arrival: Principles of Time, Memory and Language","id":"tt6591152","s":"Ted Chiang, Jessica Coon","y":2017,"q":"video","i":["https://images-na.ssl-images-amazon.com/images/M/MV5BMGYzMWVlZjQtZjMzYS00Zjk3LWI0ZmEtMTJmODNjYjViNTZhXkEyXkFqcGdeQXVyNjE0OTE2MDY@._V1_.jpg",1280,720]}]})

Formatted (and without the JSONP garbage)

$ curl -s 'https://v2.sg.media-imdb.com/suggests/a/arrival.json' | cut -d '(' -f 2 | cut -d ')' -f 1 | jq .
{
  "v": 1,
  "q": "arrival",
  "d": [
    {
      "l": "Arrival",
      "id": "tt2543164",
      "s": "Amy Adams, Jeremy Renner",
      "y": 2016,
      "q": "feature",
      "i": [
        "https://images-na.ssl-images-amazon.com/images/M/MV5BMTExMzU0ODcxNDheQTJeQWpwZ15BbWU4MDE1OTI4MzAy._V1_.jpg",
        1311,
        2048
      ]
    },
    {
      "l": "The Arrival",
      "id": "tt0115571",
      "s": "Charlie Sheen, Lindsay Crouse",
      "y": 1996,
      "q": "feature",
      "i": [
        "https://images-na.ssl-images-amazon.com/images/M/MV5BMzhiN2M1NGUtOWVmNi00YWU1LWJlNGMtZDMzYjkwZTQ4MmY4XkEyXkFqcGdeQXVyNjc2NDI1ODA@._V1_.jpg",
        750,
        1104
      ]
    },
    {
      "l": "Dead on Arrival",
      "id": "tt5903088",
      "s": "Christa B. Allen, Scottie Thompson",
      "y": 2017,
      "q": "feature",
      "i": [
        "https://images-na.ssl-images-amazon.com/images/M/MV5BYTU3Mjg1YTgtNjMyMy00ZTg1LWFlNGUtMjhiMTBlOGZmMTBkXkEyXkFqcGdeQXVyMjA0NjgxOTk@._V1_.jpg",
        668,
        1014
      ]
    },
    {
      "l": "Departures",
      "id": "tt4859168",
      "s": "Nina Dobrev, Maisie Williams",
      "y": 2018,
      "q": "feature"
    },
    {
      "l": "Arrival II",
      "id": "tt0122961",
      "s": "Patrick Muldoon, Jane Sibbett",
      "y": 1998,
      "q": "feature",
      "i": [
        "https://images-na.ssl-images-amazon.com/images/M/MV5BMjA2MDI3NjcyN15BMl5BanBnXkFtZTcwOTMxOTUyMQ@@._V1_.jpg",
        261,
        475
      ]
    },
    {
      "l": "Arrivals",
      "id": "tt3779852",
      "s": "Amrita Acharia, Philip Arditti",
      "y": 2016,
      "q": "feature"
    },
    {
      "l": "Arrival",
      "id": "tt3831316",
      "s": "Scott St. Patrick, Scott St. Patrick",
      "q": "feature"
    },
    {
      "l": "Arrival: Principles of Time, Memory and Language",
      "id": "tt6591152",
      "s": "Ted Chiang, Jessica Coon",
      "y": 2017,
      "q": "video",
      "i": [
        "https://images-na.ssl-images-amazon.com/images/M/MV5BMGYzMWVlZjQtZjMzYS00Zjk3LWI0ZmEtMTJmODNjYjViNTZhXkEyXkFqcGdeQXVyNjE0OTE2MDY@._V1_.jpg",
        1280,
        720
      ]
    }
  ]
}
RBangel commented 6 years ago

Any particular reason you suggest IMDb? In the past, I've pulled data for Plex from TheMovieDb and I've seen others recommend OMDB (Open Move Database). While TMDB requires an API key, OMDB doesn't and they both seem to have slightly better responses [that don't use single char keys]

McPolemic commented 6 years ago

IMDB was the default. This should've probably just been "Get movie metadata".

It looks like OMDB not only requires an API key but also doesn't provide movie posters unless you're a patron of theirs. Posters is probably the feature in this for me because it makes it easier to skim.

I was also attracted to the idea of using IMDB's ID as a canonical representation of a movie because, in theory, that would make it easier to interact with other services that store that ID (like having Plex automatically open and start watching a movie). That's all a bit of a pipe dream, though.