Search for a show or movie with a keyword (e.g. "Breaking Bad") and receive
basic info of the first search result. It's main use is to retrieve
the IDs or proper show/movie title for further use, as well
as receiving a quick overview of a show/movie.
Usage
search_query(
query,
type = "show",
n_results = 1L,
extended = c("min", "full"),
years = NULL,
genres = NULL,
languages = NULL,
countries = NULL,
runtimes = NULL,
ratings = NULL,
certifications = NULL,
networks = NULL,
status = NULL
)
search_id(
id,
id_type = c("trakt", "imdb", "tmdb", "tvdb"),
type = "show",
n_results = 1L,
extended = c("min", "full")
)Source
search_query() wraps endpoint /search/:type?query=.
search_id() wraps endpoint /search/:id_type/:id?type=.
Arguments
- query
character(1): Search string for titles and descriptions. Forsearch_query()other fields are searched depending on thetypeof media. See the API docs for a full reference.- type
character(1) ["show"]: The type of data you're looking for. One ofshow,movie,episode,personorlistor a character vector with those elements, e.g.c("show", "movie"). Note that not every combination is reasonably combinable, e.g.c("movie", "list"). Use separate function calls in that case.- n_results
integer(1) [1]: How many results to return.- extended
character(1): Either"min"(API default) or"full". The latter returns more variables and should generally only be used if required. Seevignette("tRakt")for more details.- years
character | integer: 4-digit year (2010) or range, e.g."2010-2020". Can also be an integer vector of length two which will be coerced appropriately, e.g.c(2010, 2020).- genres
character(n): Genre slug(s). Seetrakt_genresfor a table of genres. Multiple values are allowed and will be concatenated.- languages
character(n): Two-letter language code(s). Also seetrakt_languagesfor available languages (code and name).- countries
character(n): Two-letter country code(s). Seetrakt_countries.- runtimes
character | integer: Integer range in minutes, e.g.30-90. Can also be an integer vector of length two which will be coerced appropriately.- ratings
character | integer: Integer range between0and100. Can also be an integer vector of length two which will be coerced appropriately. Note that user-supplied ratings are in the range of 1 to 10, yet the ratings on the site itself are scaled to the range of 1 to 100.- certifications
character(n): Certification(s) likepg-13. Multiple values are allowed. Usetrakt_certificationsfor reference. Note that there are different certifications for shows and movies.- networks
character(n): (Shows only) Network name likeHBO. Seetrakt_networksfor a list of known networks.- status
character(n): (Shows only) The status of the shows. One of"returning series","in production","planned","canceled", or"ended".- id
character(1): The id used for the search, e.g.14701for aTrakt ID.- id_type
character(1) ["trakt"]: The type ofid. One oftrakt,imdb,tmdb,tvdb.
Value
A tibble containing n_results results.
Variable type is equivalent to the value of the type argument, and
variable score indicates the search match, where 1000 is a perfect
match.
If no results are found, the tibble has 0 rows.
If more than one type is specified, e.g. c("movie", "show"),
there will be n_results results per type.
Details
The amount of information returned is equal to *_summary API methods and
in turn depends on the value of extended.
See also the
API reference here for
which fields of the item metadata are searched by default.
Examples
# A show
search_query("Breaking Bad", type = "show", n_results = 3)
#> # A tibble: 3 × 9
#> type score title year trakt slug tvdb imdb tmdb
#> <chr> <dbl> <chr> <int> <chr> <chr> <chr> <chr> <chr>
#> 1 show 1.16e18 Breaking Bad 2008 1388 brea… 81189 tt09… 1396
#> 2 show 1.16e18 Breaking Bad: Original Mini… 2009 2945… brea… NA NA 2979…
#> 3 show 1.16e18 Breaking Bad Fortune Teller 2016 2568… brea… 4154… NA 2325…
if (FALSE) { # \dontrun{
# A show by its trakt id, and now with more information
search_id(1388, "trakt", type = "show", extended = "full")
# A person
search_query("J. K. Simmons", type = "person", extended = "full")
# A movie or a show, two of each
search_query("Tron", type = c("movie", "show"), n_results = 2)
} # }
