Description Usage Arguments Details Value Author(s) See Also Examples
Search YouTube for videos, channels and/or playlists.
1 2 3 4 5 6 7 8 9 | searchTube(token, query, n = 50, type = "any", order = "relevance",
video.dimension = NULL, video.caption = NULL, video.category.id = NULL,
video.duration = NULL, video.embeddable = NULL, video.syndicated = NULL,
video.type = NULL, video.definition = NULL, video.license = NULL,
max.results = 50, location = NULL, location.radius = NULL,
region.code = NULL, safe.search = "none", event.type = NULL,
published.before = Sys.time(), published.after = NULL,
channel.id = NULL, relevance.language = NULL, topic.id = NULL,
verbose = FALSE)
|
token |
Your token as returned by |
query |
The query term to search for. Your request can also use the Boolean NOT (-)
and OR (|) operators to exclude videos or to find videos that are
associated with one of several search terms. For example, to search for
videos matching either "boating" or "sailing", set the query parameter value
to |
n |
Number of results to fecth. The default value is |
type |
Restricts a search query to only retrieve a particular type of resource.
The value is a comma-separated list of resource types. The default value is
|
order |
Specifies the method that will be used to order resources in the API
response. The default value is |
video.dimension |
Restricts a search to only retrieve 2D or 3D videos.
The default value is |
video.caption |
Indicates whether the API should filter video search results based on
whether they have captions. The default value is |
video.category.id |
Filters video search results based on their category ID as returned by
|
video.duration |
Filters video search results based on their duration. The default value is
|
video.embeddable |
Restricts a search to only videos that can be embedded into a webpage.
The default value is |
video.syndicated |
Restricts a search to only videos that can be played outside youtube.com.
The default value is |
video.type |
Restricts a search to a particular type of videos.
The default value is |
video.definition |
Restricts a search to only include either high definition (HD) or standard
definition (SD) videos. HD videos are available for playback in at least
720p, though higher resolutions, like 1080p, might also be available.
The default value is |
video.license |
Filters search results to only include videos with a particular license.
YouTube lets video uploaders choose to attach either the Creative Commons
license or the standard YouTube license to each of their videos.
The default value is |
max.results |
Specifies the maximum number of results that should be returned
by each API call. Acceptable values are |
location |
Must be used in conjunction with the locationRadius parameter, defines a circular
geographic area and also restricts a search to videos that specify, in
their metadata, a geographic location that falls within that area. The
parameter value is a vector that specifies latitude and longitude coordinates
e.g. |
location.radius |
Must be used in conjunction with the location parameter, defines a circular
geographic area. The parameter value must be a floating point number
followed by a measurement unit. Valid measurement units are |
region.code |
Instructs the API to return search results for the specified country. The
parameter value is an
ISO 3166-1 alpha-2
country code. The default value is |
safe.search |
Indicates whether the search results should include restricted content as
well as standard content.
The default value is |
event.type |
Restricts a search to broadcast events.
The default value is |
published.before |
Indicates that the API response should only contain resources created
before the specified time. Can be either of class |
published.after |
Indicates that the API response should only contain resources created after
the specified time. Can be either of class |
channel.id |
Indicates that the API response should only contain resources created by the channel. |
relevance.language |
Instructs the API to return search results that are most relevant to the
specified language. The parameter value is typically an
ISO 639-1 two-letter language code.
However, you should use the values |
topic.id |
Indicates that the API response should only contain resources associated with the specified topic. The value identifies a Freebase topic ID. |
verbose |
If |
For more information on the parameters and the API call this
function refers to please see
https://developers.google.com/youtube/v3/docs/search/list.
Some parameters are only applicable to type=video
namely that which
are preceded by video.
and event.type
.
Returns a collection of search results that match the query parameters specified in the API request.
Returns data.frame
John Coene jcoenep@hotmail.com
findParams
, link{youOAuth}
,
findParts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ## Not run:
# Authenticate
token <- youOAuth(client.id = "something.apps.googleusercontent.com",
client.secret = "XxxXX1XxXxXxxx1xxx1xxXXX")
# search
cats <- searchVideos(token, query = "cats")
# filter 2d videos
2d.cats <- searchVideos(token, query = "cats",
video.dimension = findParams("video.dimension")[1],
type = "video")
# find valid values for video.dimension
dims <- findParams(param = "video.dimension")
# fetch 3D cats videos from Belgium
dull.cats <- searchVideos(token, query = "cats", region.code = "BE",
video.dimension = dims[2], type = "video")
# fetch "clean cat" channels from area 51 using coordinates
safety <- findParams("safe.search")[grep("strict",
findParams("safe.search"))]
clean.cats <- searchVideos(token, query = "clean cats", safe.search = safety,
location = c(lat = 37.2350, long = 115.8111),
location.radius = "5km", type = "channel")
# fetch video catgeories
video.cat <- getVideoCategories(token, region.code = "US")
# filter pet-related video categories
video.cat <- video.cat[grep("Pets", video.cat$title),]
# fetch by category
pets <- searchTube(token, query = "cats", video.category.id = video.cat[1])
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.