powershellomdbapi

Query omdbapi.com to get Series\Episode info


I want to get the info for a specific season and episode using PowerShell:

$Movies = Invoke-RestMethod "http://www.omdbapi.com/?apikey=$key&s=The Last Ship&season=2&episode=12"# &season=2&episode=2
$Movies.totalResults
$movies.Search | where-object {$_.Type -eq "series"}

This just gives the generic show info. I would like to get Season 2/Episode 2, what kind of format does the query need to be?


Solution

  • I don't think this question is PowerShell-specific, but omdbapi-specific. I think that you need to use the By ID or Title search type and specify the IMDB ID of the series and the IMDB ID. And perhaps the data about this particular series (The Last Ship) is missing from omdbapi.

    Perhaps OMDB API is missing information about these series and episodes? I see open tickets regarding missing information on series like this one https://github.com/omdbapi/OMDb-API/issues/15.

    For instance, I get results when I use the following URL (for ID tt0137330 episode 4):

    Invoke-RestMethod "http://www.omdbapi.com/?apikey=$key&i=tt0137330&season=1&Episode=4"
    
    Title      : Two Guys, a Girl and a Celtic Game
    Year       : 1998
    Rated      : N/A
    Released   : 01 Apr 1998
    Season     : 1
    Episode    : 4
    Runtime    : 22 min
    Genre      : Comedy, Romance
    Director   : John Fortenberry
    Writer     : Rick Wiener, Kenny Schwartz, Danny Jacobson
    Actors     : Traylor Howard, Ryan Reynolds, Richard Ruccolo
    Plot       : Pete is very eager to go to a Celtics game with Sharon and Melissa. Berg is not so keen 
                 to go. Despite this, Berg is in the lucky seat that gets him a seat on the bench, which 
                 upsets Pete. What can Berg do to make him happy again?
    Language   : English
    Country    : United States
    Awards     : N/A
    Poster     : https://m.media-amazon.com/images/M/MV5BZDFkYmJjMDQtMjE1Zi00MGU1LWE0NTEtNjE5ZTMwY2IyYWQ1Xk
                 EyXkFqcGdeQXVyNzA2NzkwNTA@._V1_SX300.jpg
    Ratings    : {}
    Metascore  : N/A
    imdbRating : N/A
    imdbVotes  : 401
    imdbID     : tt0735044
    seriesID   : tt0137330
    Type       : episode
    Response   : True
    

    The same IMDB ID, but episode 2 is not found:

    Invoke-RestMethod "http://www.omdbapi.com/?apikey=$key&i=tt0137330&season=1&Episode=2"
    
    Response Error
    -------- -----
    False    Series or episode not found!
    

    And I don't get any results when I use these URLs (for other IMDB IDs tt8068860 or tt2402207):

    tt8068860

    Invoke-RestMethod "http://www.omdbapi.com/?apikey=$key&i=tt8068860&season=1"
    

    tt2402207

    Invoke-RestMethod "http://www.omdbapi.com/?apikey=$key&i=tt2402207&season=1"