searchTube: searchTube

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Search YouTube for videos, channels and/or playlists.

Usage

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)

Arguments

token

Your token as returned by youOAuth.

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 boating|sailing. Similarly, to search for videos matching either "boating" or "sailing" but not "fishing", set the query parameter value to boating|sailing -fishing.

n

Number of results to fecth. The default value is 50.

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 any (includes channel, video and playlist).

order

Specifies the method that will be used to order resources in the API response. The default value is relevance. See findParams for valid values.

video.dimension

Restricts a search to only retrieve 2D or 3D videos. The default value is any. If you specify a value for this parameter, you must also set the type parameter's value to video. See findParams for valid values.

video.caption

Indicates whether the API should filter video search results based on whether they have captions. The default value is any. See findParams for valid values. If you specify a value for this parameter, you must also set the type parameter's value to video.

video.category.id

Filters video search results based on their category ID as returned by getVideoCategories.

video.duration

Filters video search results based on their duration. The default value is any. See findParams for valid values. If you specify a value for this parameter, you must also set the type parameter's value to video.

video.embeddable

Restricts a search to only videos that can be embedded into a webpage. The default value is any. See findParams for valid values. If you specify a value for this parameter, you must also set the type parameter's value to video.

video.syndicated

Restricts a search to only videos that can be played outside youtube.com. The default value is any. See findParams for valid values. If you specify a value for this parameter, you must also set the type parameter's value to video.

video.type

Restricts a search to a particular type of videos. The default value is any. See findParams for valid values. If you specify a value for this parameter, you must also set the type parameter's value to video.

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 any. See findParams for valid values. If you specify a value for this parameter, you must also set the type parameter's value to video.

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 any. See findParams for valid values. If you specify a value for this parameter, you must also set the type parameter's value to video.

max.results

Specifies the maximum number of results that should be returned by each API call. Acceptable values are 0 to 50, inclusive. The default value is 50.

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. c(lat = 37.42307, long = -122.08427) or c(37.42307, -122.08427). The default value is NULL.

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 m, km, ft, and mi. For example, valid parameter values include 1500m, 5km, 10000ft, and 0.75mi. The API does NOT support parameter values larger than 1000 kilometers. The default value is NULL.

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 NULL.

safe.search

Indicates whether the search results should include restricted content as well as standard content. The default value is none. See findParams for valid values.

event.type

Restricts a search to broadcast events. The default value is NULL. See findParams for valid values. If you specify a value for this parameter, you must also set the type parameter's value to video.

published.before

Indicates that the API response should only contain resources created before the specified time. Can be either of class Date (" or POSIXct or POSIXlt with time, or an RFC 3339 formatted date-time value (i.e.: 1970-01-01T00:00:00Z). The default value is Sys.time().

published.after

Indicates that the API response should only contain resources created after the specified time. Can be either of class Date (" or POSIXct or POSIXlt with time, or an RFC 3339 formatted date-time value (i.e.: 1970-01-01T00:00:00Z). The default value is NULL.

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 zh-Hans for simplified Chinese and zh-Hant for traditional Chinese. Please note that results in other languages will still be returned if they are highly relevant to the search query term.

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 TRUE prints infromational messages in the console. The default value is FALSE.

Details

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.

Value

Returns a collection of search results that match the query parameters specified in the API request.

Returns data.frame

Author(s)

John Coene jcoenep@hotmail.com

See Also

findParams, link{youOAuth}, findParts

Examples

 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)

JohnCoene/youTubeDataR documentation built on May 7, 2019, 11:59 a.m.