Introduction

This document gives you a walkthrough of the package and describes several usecases. I assume you have knowledge of downloading and installing a package.

library(dplyr)# for this specific part
tibble::tribble(
        ~Term, ~explanation,
        "API", "Application Programming Interface, a term most often used when describing an internet endpoint (but also used within a single piece of software to describe what parts can be used by other programs). An internet API allows us to send a request to a service and recieve a standardized result back.",
        "OMDBapi", "Open Movie Database API",
        ".Renviron", "When R starts it reads in this file and adds all keys to it's configuration. This allows you to access keys without ever putting them in your console."
)
#> # A tibble: 3 x 2
#>   Term      explanation                                                   
#>   <chr>     <chr>                                                         
#> 1 API       Application Programming Interface, a term most often used whe…
#> 2 OMDBapi   Open Movie Database API                                       
#> 3 .Renviron When R starts it reads in this file and adds all keys to it's…

First use - get a key

To use the service, you need a key. This key identifies you for OMDBapi. Go to the website omdbapi.com and click on get key or go directly to http://omdbapi.com/apikey.aspx

If you want to support the OMDBapi authors on Patreon use that option otherwise use the free option, and input your email adres.

I think you recieve an email with the key in it.

First use - save the key safely

You don’t have to add this key to a file, you can call every function with the key argument filled. However this makes it difficult to share a script (it has you secret key in that file!).

We want R to have access to the key and not retype the key with every request. That is why we save the key to a file that is read by R on startup. This file is called .Renviron (the dot means it’s normally hidden from view) Either go manually to ~/.Renviron (On windows )

file.edit("~/.Renviron")

More info on: https://csgillespie.github.io/efficientR/3-3-r-startup.html#renviron and https://stat.ethz.ch/R-manual/R-devel/library/base/html/Startup.html

Or use the convenience function I added to this package:

library(imdb)
add_key_to_renviron("fillInYourKeyHere")

If you leave the key empty a prompt will ask you for the key (that way it never gets recorded in your .Rhistory file).

I want to download imdb information for a movie (I know the title)

Use the title to search for a movie.

This returns a dataframe with a row for every match.

library(imdb)
movies <- imdbMovies(moviename = "2001 a space odyssey")
movies[,c(1:7,15:18)]
#>                   Title Year Rated    Released Runtime             Genre
#> 1 2001: A Space Odyssey 1968     G 12 May 1968 149 min Adventure, Sci-Fi
#>          Director Metascore imdbRating imdbVotes    imdbID
#> 1 Stanley Kubrick        82        8.3   503,419 tt0062622

I want to download basic information about a series (I know the title)

This downloads a dataframe with all episodes.

library(imdb)
series <- imdbSeries("The Orville")
#> Warning in imdbSeries("The Orville"): NAs introduced by coercion
series
#>                         Title   Released Episode imdbRating    imdbID
#> 1                  Old Wounds 2017-09-10       1        7.4 tt5773550
#> 2         Command Performance 2017-09-17       2         NA tt6408626
#> 3                About a Girl 2017-09-21       3        7.9 tt6483038
#> 4  If the Stars Should Appear 2017-09-28       4        8.5 tt6483046
#> 5                        Pria 2017-10-05       5        8.2 tt6483048
#> 6                       Krill 2017-10-12       6        8.3 tt6723482
#> 7               Majority Rule 2017-10-26       7        8.4 tt6845666
#> 8               Into the Fold 2017-11-02       8         NA tt6850950
#> 9              Cupid's Dagger 2017-11-09       9        8.1 tt6850956
#> 10                  Firestorm 2017-11-16      10        8.4 tt6850958
#> 11             New Dimensions 2017-11-30      11        8.2 tt6850962
#> 12              Episode #1.12       <NA>      12         NA tt6850966
#> 13               Mad Idolatry 2017-12-07      12        8.7 tt5943640
#>    Season
#> 1       1
#> 2       1
#> 3       1
#> 4       1
#> 5       1
#> 6       1
#> 7       1
#> 8       1
#> 9       1
#> 10      1
#> 11      1
#> 12      1
#> 13      1

I want to download more information about a series

Use the enrichIMDB function to add more information to the series you downloaded.

series <- enrichIMDB(df = series)
#> Warning in enrichIMDB(df = series): NAs introduced by coercion
series[1:2,]
#>      imdbID runtime        director
#> 2 tt5773550  45 min     Jon Favreau
#> 3 tt6408626  60 min James L. Conway
#>                                          writer
#> 2 Seth MacFarlane (created by), Seth MacFarlane
#> 3                  Seth MacFarlane (created by)
#>                                                                  actors
#> 2 Seth MacFarlane, Adrianne Palicki, Penny Johnson Jerald, Scott Grimes
#> 3 Seth MacFarlane, Adrianne Palicki, Penny Johnson Jerald, Scott Grimes
#>                                                                                                         plot
#> 2               Newly promoted Captain, Ed, is taken back when his ex-wife is assigned as his First Officer.
#> 3 Alara must take command of the Orville when Ed and Kelly end up imprisoned in a replica of their old home.
#>   votes
#> 2  2476
#> 3    NA

I know the imdbID and want to download that specific information

If you have imdbID’s and want more information about a that title you can use the imdbTitleId function to download that specific information from the API.

For instance I want to know more about ‘The Truman Show’, it has id ‘tt0120382’.

trumanshow <- imdbTitleId("tt0120382")
trumanshow
#>             Title Year Rated    Released Runtime                 Genre
#> 1 The Truman Show 1998    PG 05 Jun 1998 103 min Comedy, Drama, Sci-Fi
#>     Director        Writer
#> 1 Peter Weir Andrew Niccol
#>                                                       Actors
#> 1 Jim Carrey, Laura Linney, Noah Emmerich, Natascha McElhone
#>                                                                                                                                                                                                                                                                                                                                                                                                                                               Plot
#> 1 In this movie, Truman is a man whose life is a fake one... The place he lives is in fact a big studio with hidden cameras everywhere, and all his friends and people around him, are actors who play their roles in the most popular TV-series in the world: The Truman Show. Truman thinks that he is an ordinary man with an ordinary life and has no idea about how he is exploited. Until one day... he finds out everything. Will he react?
#>   Language Country
#> 1  English     USA
#>                                                      Awards
#> 1 Nominated for 3 Oscars. Another 38 wins & 65 nominations.
#>                                                                                                                          Posterlink
#> 1 https://ia.media-imdb.com/images/M/MV5BMDIzODcyY2EtMmY2MC00ZWVlLTgwMzAtMjQwOWUyNmJjNTYyXkEyXkFqcGdeQXVyNDk3NzU2MTQ@._V1_SX300.jpg
#>   Metascore imdbRating imdbVotes    imdbID
#> 1        90        8.1   770,648 tt0120382

I want something else

I’m sorry, I don’t have more. You can always ask a question by opening an issue on github.