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 thetype
of 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
,person
orlist
or 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("finding-things")
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_genres
for a table of genres. Multiple values are allowed and will be concatenated.- languages
character(n)
: Two-letter language code(s). Also seetrakt_languages
for 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 between0
and100
. 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_certifications
for reference. Note that there are different certifications for shows and movies.- networks
character(n)
: (Shows only) Network name likeHBO
. Seetrakt_networks
for 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.14701
for 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 1281. The Langoliers 1995 164166 the-langoli… 2117… tt01… 18197
#> 2 show 1258. Danny Phantom 2004 2295 danny-phant… 78443 tt03… 2309
#> 3 show 1241. Ben 10: Ultimate Alien 2010 30974 ben-10-ulti… 1585… tt16… 31109
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)
} # }