Movatterモバイル変換


[0]ホーム

URL:


Title:Client for the YouTube API
Version:1.1.0
Maintainer:Gaurav Sood <gsood07@gmail.com>
Description:Get comments posted on YouTube videos, information on how many times a video has been liked, search for videos with particular content, and much more. You can also scrape captions from a few videos. To learn more about the YouTube API, seehttps://developers.google.com/youtube/v3/.
License:MIT + file LICENSE
URL:https://gojiplus.github.io/tuber/,https://github.com/gojiplus/tuber
BugReports:https://github.com/gojiplus/tuber/issues
Depends:R (≥ 4.1.0)
Imports:askpass, dplyr, httr, httr2, jsonlite, magrittr, mime, plyr,purrr, tibble, tidyr, tidyselect, utils
Suggests:hms, knitr (≥ 1.11), lintr, rmarkdown, testthat, xml2
VignetteBuilder:knitr
Encoding:UTF-8
RoxygenNote:7.3.2
NeedsCompilation:no
Packaged:2025-08-25 02:50:14 UTC; soodoku
Author:Gaurav Sood [aut, cre], Kate Lyons [ctb], John Muschelli [ctb]
Repository:CRAN
Date/Publication:2025-08-25 03:10:02 UTC

tuber: Client for the YouTube API

Description

Get comments posted on YouTube videos, information on how many times a video has been liked, search for videos with particular content, and much more. You can also scrape captions from a few videos. To learn more about the YouTube API, seehttps://developers.google.com/youtube/v3/.

Author(s)

Maintainer: Gaurav Soodgsood07@gmail.com

Other contributors:

See Also

Useful links:


Pipe operator

Description

Seemagrittr::%>% for details.

Usage

lhs %>% rhs

Arguments

lhs

A value or the magrittr placeholder.

rhs

A function call using the magrittr semantics.

Value

The result of calling 'rhs(lhs)'.


Add Video to Playlist

Description

Add Video to Playlist

Usage

add_video_to_playlist(playlist_id, video_id, position = NULL, ...)

Arguments

playlist_id

string; Required. The ID of the playlist.

video_id

string; Required. The ID of the video to add.

position

numeric; Optional. The position of the video in the playlist.If not provided, the video will be added to the end of the playlist.

...

Additional arguments passed totuber_POST_json.

Value

Details of the added video in the playlist.

References

https://developers.google.com/youtube/v3/docs/playlistItems/insert

Examples

## Not run: # Set API token via yt_oauth() firstadd_video_to_playlist(playlist_id = "YourPlaylistID", video_id = "2_gLD1jarfU")## End(Not run)

Change the title of a YouTube playlist.

Description

This function updates the title of an existing YouTube playlist using the YouTube Data API.

Usage

change_playlist_title(playlist_id, new_title)

Arguments

playlist_id

A character string specifying the ID of the playlist you want to update.

new_title

A character string specifying the new title for the playlist.

Value

A list containing the server response after the update attempt.

Examples

## Not run: change_playlist_title(playlist_id = "YourPlaylistID", new_title = "New Playlist Title")## End(Not run)

Clean and Normalize YouTube Text Data

Description

Applies consistent cleaning to YouTube text fields

Usage

clean_youtube_text(  text,  remove_html = TRUE,  normalize_whitespace = TRUE,  max_length = NULL)

Arguments

text

Character vector of text to clean

remove_html

Boolean. Remove HTML tags. Default: TRUE

normalize_whitespace

Boolean. Normalize whitespace. Default: TRUE

max_length

Integer. Maximum length (NULL for no limit). Default: NULL

Value

Cleaned character vector


Create New Playlist

Description

Create New Playlist

Usage

create_playlist(title, description, status, ...)

Arguments

title

string; Required. The title of the playlist.

description

string; Optional. The description of the playlist.

status

string; Optional. Default: 'public'. Can be one of: 'private', 'public', or 'unlisted'.

...

Additional arguments passed totuber_POST.

Value

The created playlist's details.

References

https://developers.google.com/youtube/v3/docs/playlists/insert

Examples

## Not run: # Set API token via yt_oauth() firstcreate_playlist(title = "My New Playlist", description = "This is a test playlist.")## End(Not run)

Delete a Particular Caption Track

Description

Delete a Particular Caption Track

Usage

delete_captions(id = NULL, ...)

Arguments

id

String. Required. id of the caption track that is being retrieved

...

Additional arguments passed totuber_DELETE.

References

https://developers.google.com/youtube/v3/docs/captions/delete

Examples

## Not run: # Set API token via yt_oauth() firstdelete_captions(id = "y3ElXcEME3lSISz6izkWVT5GvxjPu8pA")## End(Not run)

Delete Channel Sections

Description

Delete a Channel Section

Usage

delete_channel_sections(id = NULL, ...)

Arguments

id

Required. ID of the channel section.

...

Additional arguments passed totuber_DELETE.

References

https://developers.google.com/youtube/v3/docs/channelSections/delete

Examples

## Not run: # Set API token via yt_oauth() firstdelete_channel_sections(c(channel_id = "UCRw8bIz2wMLmfgAgWm903cA"))## End(Not run)

Delete a Particular Comment

Description

Delete a Particular Comment

Usage

delete_comments(id = NULL, ...)

Arguments

id

String. Required. id of the comment being retrieved

...

Additional arguments passed totuber_DELETE.

References

https://developers.google.com/youtube/v3/docs/comments/delete

Examples

## Not run: # Set API token via yt_oauth() firstdelete_comments(id = "y3ElXcEME3lSISz6izkWVT5GvxjPu8pA")## End(Not run)

Delete a Playlist Item

Description

Delete a Playlist Item

Usage

delete_playlist_items(id = NULL, ...)

Arguments

id

String. Required. id of the playlist item that is to be deleted

...

Additional arguments passed totuber_DELETE.

References

https://developers.google.com/youtube/v3/docs/playlistItems/delete

Examples

## Not run: # Set API token via yt_oauth() firstdelete_playlist_items(id = "YourPlaylistItemID")## End(Not run)

Delete a Playlist

Description

Delete a Playlist

Usage

delete_playlists(id = NULL, ...)

Arguments

id

String. Required. id of the playlist that is to be deleted

...

Additional arguments passed totuber_DELETE.

References

https://developers.google.com/youtube/v3/docs/playlists/delete

Examples

## Not run: # Set API token via yt_oauth() firstdelete_playlists(id = "y3ElXcEME3lSISz6izkWVT5GvxjPu8pA")## End(Not run)

Delete a Video

Description

Delete a Video

Usage

delete_videos(id = NULL, ...)

Arguments

id

String. Required. id of the video that is to be deleted

...

Additional arguments passed totuber_DELETE.

References

https://developers.google.com/youtube/v3/docs/playlistItems/delete

Examples

## Not run: # Set API token via yt_oauth() firstdelete_videos(id = "y3ElXcEME3lSISz6izkWVT5GvxjPu8pA")## End(Not run)

Add Exponential Backoff

Description

Internal function to handle rate limiting with exponential backoff

Usage

exponential_backoff(attempt_number, max_attempts = 5, base_delay = 1)

Arguments

attempt_number

Integer. Current attempt number

max_attempts

Integer. Maximum attempts before giving up

base_delay

Numeric. Base delay in seconds


Get statistics on all the videos in a Channel

Description

Iterates through the channel's uploads playlist, collecting video IDs fromeach page until no further pages are available. Statistics and details arethen fetched for every video.

Usage

get_all_channel_video_stats(channel_id = NULL, mine = FALSE, ...)

Arguments

channel_id

Character. Id of the channel

mine

Boolean. TRUE if you want to fetch stats of your own channel. Default is FALSE.

...

Additional arguments passed totuber_GET.

Value

Adata.frame containing video metadata along with view, like,dislike and comment counts.

If thechannel_id is mistyped or there is no information, an empty list is returned

References

https://developers.google.com/youtube/v3/docs/channels/list

Examples

## Not run: # Set API token via yt_oauth() firstget_all_channel_video_stats(channel_id="UCxOhDvtaoXDAB336AolWs3A")get_all_channel_video_stats(channel_id="UCMtFAi84ehTSYSE9Xo") # Incorrect channel ID## End(Not run)

Get all the comments for a video including replies

Description

Get all the comments for a video including replies

Usage

get_all_comments(video_id = NULL, ...)

Arguments

video_id

string; Required.video_id: video ID.

...

Additional arguments passed totuber_GET.

Value

adata.frame with the following columns:authorDisplayName, authorProfileImageUrl, authorChannelUrl, authorChannelId.value, videoId, textDisplay,canRate, viewerRating, likeCount, publishedAt, updatedAt,id, moderationStatus, parentId

References

https://developers.google.com/youtube/v3/docs/commentThreads/list

Examples

## Not run: # Set API token via yt_oauth() firstget_all_comments(video_id = "a-UQz7fqR3w")## End(Not run)

Get Particular Caption Track

Description

For getting captions from the v3 API, you must specify the id resource.Checklist_caption_tracks for more information.

Usage

get_captions(id = NULL, lang = "en", format = "sbv", as_raw = TRUE, ...)

Arguments

id

String. Required. id of the caption track that is being retrieved

lang

Optional. Default isen.

format

Optional. Default issbv.

as_raw

IfFALSE the captions be converted to a characterstring versus a raw vector

...

Additional arguments passed totuber_GET.

Value

String.

References

https://developers.google.com/youtube/v3/docs/captions/download

Examples

## Not run: # Set API token via yt_oauth() firstget_captions(id = "y3ElXcEME3lSISz6izkWVT5GvxjPu8pA")## End(Not run)

Get statistics of a Channel

Description

Get statistics of a Channel

Usage

get_channel_stats(channel_id = NULL, mine = NULL, ...)list_my_channel(...)

Arguments

channel_id

Character. Id of the channel

mine

Boolean. TRUE if you want to fetch stats of your own channel. Default is NULL.

...

Additional arguments passed totuber_GET.

Value

nested named list with top element names:kind, etag, id, snippet (list of details of the channelincluding title), statistics (list of 5)

If thechannel_id is mistyped or there is no information, an empty list is returned

References

https://developers.google.com/youtube/v3/docs/channels/list

Examples

## Not run: # Set API token via yt_oauth() firstget_channel_stats(channel_id="UCMtFAi84ehTSYSE9XoHefig")get_channel_stats(channel_id="UCMtFAi84ehTSYSE9Xo") # Incorrect channel ID## End(Not run)

Get Comments Threads

Description

Get Comments Threads

Usage

get_comment_threads(  filter = NULL,  part = "snippet",  text_format = "html",  simplify = TRUE,  max_results = 100,  page_token = NULL,  ...)

Arguments

filter

string; Required.named vector of length 1potential names of the entry in the vector:video_id: video ID.channel_id: channel ID.thread_id: comma-separated list of comment thread IDsthreads_related_to_channel: channel ID.

part

Comment resource requested. Required. Comma separated listof one or more of thefollowing:id, snippet. e.g.,"id, snippet","id", etc. Default:snippet.

text_format

Data Type: Character. Default is"html".Only takes"html" or"plainText". Optional.

simplify

Data Type: Boolean. Default isTRUE. IfTRUE,the function returns a data frame. Else a list with all theinformation returned.

max_results

Maximum number of items that should be returned.Integer. Optional. Default is 100.If the value is greater than 100 then the function fetches all theresults. The outcome is a simplifieddata.frame.

page_token

Specific page in the result set that should bereturned. Optional.

...

Additional arguments passed totuber_GET.

Value

Nested named list. The entryitems is a list of commentsalong with meta information.Within each of theitems is an itemsnippet whichhas an itemtopLevelComment$snippet$textDisplaythat contains the actual comment.

If simplify isTRUE, adata.frame with the following columns:authorDisplayName, authorProfileImageUrl, authorChannelUrl,authorChannelId.value, videoId, textDisplay,canRate, viewerRating, likeCount, publishedAt, updatedAt

References

https://developers.google.com/youtube/v3/docs/commentThreads/list

Examples

## Not run: # Set API token via yt_oauth() firstget_comment_threads(filter = c(video_id = "N708P-A45D0"))get_comment_threads(filter = c(video_id = "N708P-A45D0"), max_results = 101)## End(Not run)

Get Comments

Description

Get Comments

Usage

get_comments(  filter = NULL,  part = "snippet",  max_results = 100,  text_format = "html",  page_token = NULL,  simplify = TRUE,  ...)

Arguments

filter

string; Required.named vector of length 1potential names of the entry in the vector:comment_id: comment ID.parent_id: parent ID.

part

Comment resource requested. Required. Comma separated listof one or more of thefollowing:id, snippet. e.g.,"id, snippet","id",etc. Default:snippet.

max_results

Maximum number of items that should be returned.Integer. Optional. Can be between 20 and 100. Default is 100.

text_format

Data Type: Character. Default is"html".Only takes"html" or"plainText". Optional.

page_token

Specific page in the result set that should bereturned. Optional.

simplify

Data Type: Boolean. Default is TRUE. If TRUE, the functionreturns a data frame. Else a list with all the information returned.

...

Additional arguments passed totuber_GET.

Value

Nested named list. The entryitems is a list of comments alongwith meta information.Within each of theitems is an itemsnippet which has anitemtopLevelComment$snippet$textDisplaythat contains the actual comment.

When filter iscomment_id, andsimplify isTRUE,and there is a correct comment id,it returns adata.frame with the following cols:id, authorDisplayName, authorProfileImageUrl, authorChannelUrl,value, textDisplay, canRate, viewerRating, likeCountpublishedAt, updatedAt

References

https://developers.google.com/youtube/v3/docs/comments/list

Examples

## Not run: # Set API token via yt_oauth() firstget_comments(filter = c(comment_id = "z13dh13j5rr0wbmzq04cifrhtuypwl4hsdk"))get_comments(filter = c(parent_id = "z13ds5yxjq3zzptyx04chlkbhx2yh3ezxtc0k"))get_comments(filter =c(comment_id = "z13dh13j5rr0wbmzq04cifrhtuypwl4hsdk,             z13dh13j5rr0wbmzq04cifrhtuypwl4hsdk"))## End(Not run)

Get Playlist Item IDs

Description

Get Playlist Item IDs

Usage

get_playlist_item_ids(  filter = NULL,  part = "contentDetails",  max_results = 50,  video_id = NULL,  page_token = NULL,  simplify = TRUE,  ...)

Arguments

filter

string; Required.named vector of length 1potential names of the entry in the vector:item_id: comma-separated list of one or more unique playlist item IDs.playlist_id: YouTube playlist ID.

part

Required. Comma separated string including one or more of thefollowing:contentDetails, id, snippet, status. Default:contentDetails.

max_results

Maximum number of items that should be returned.Integer. Optional. Default is 50. Values over 50 will trigger multiplerequests and may increase API quota usage.

video_id

Optional. request should return only the playlistitems that contain the specified video.

page_token

specific page in the result set that should bereturned, optional

simplify

returns a data.frame rather than a list.

...

Additional arguments passed totuber_GET.

Value

playlist items

References

https://developers.google.com/youtube/v3/docs/playlists/list

Examples

## Not run: # Set API token via yt_oauth() firstget_playlist_items(filter =                       c(playlist_id = "PLrEnWoR732-CN09YykVof2lxdI3MLOZda"))get_playlist_items(filter =                       c(playlist_id = "PL0fOlXVeVW9QMO3GoESky4yDgQfK2SsXN"),                       max_results = 51)## End(Not run)

Get Playlist Item Video IDs

Description

Get Playlist Item Video IDs

Usage

get_playlist_item_videoids(  filter = NULL,  part = "contentDetails",  max_results = 50,  video_id = NULL,  page_token = NULL,  simplify = TRUE,  ...)

Arguments

filter

string; Required.named vector of length 1potential names of the entry in the vector:item_id: comma-separated list of one or more unique playlist item IDs.playlist_id: YouTube playlist ID.

part

Required. Comma separated string including one or more of thefollowing:contentDetails, id, snippet, status. Default:contentDetails.

max_results

Maximum number of items that should be returned.Integer. Optional. Default is 50. Values over 50 trigger multiple requests andmay increase API quota usage.

video_id

Optional. request should return only the playlistitems that contain the specified video.

page_token

specific page in the result set that should bereturned, optional

simplify

returns a data.frame rather than a list.

...

Additional arguments passed totuber_GET.

Value

playlist items

References

https://developers.google.com/youtube/v3/docs/playlists/list

Examples

## Not run: # Set API token via yt_oauth() firstget_playlist_items(filter =                       c(playlist_id = "YourPlaylistID"))get_playlist_items(filter =                       c(playlist_id = "YourPlaylistID"),                       max_results = 51)## End(Not run)

Get Playlist Items

Description

Get Playlist Items

Usage

get_playlist_items(  filter = NULL,  part = "contentDetails",  max_results = 50,  video_id = NULL,  page_token = NULL,  simplify = TRUE,  ...)

Arguments

filter

string; Required.named vector of length 1potential names of the entry in the vector:item_id: comma-separated list of one or more unique playlist item IDs.playlist_id: YouTube playlist ID.

part

Required. Comma separated string including one or more of thefollowing:contentDetails, id, snippet, status. Default:contentDetails.

max_results

Maximum number of items that should be returned.Integer. Optional. Default is 50. If over 50, additional requests are madeuntil the requested amount is retrieved. Larger values may increase API quotausage.

video_id

Optional. request should return only the playlistitems that contain the specified video.

page_token

specific page in the result set that should bereturned, optional

simplify

returns a data.frame rather than a list.

...

Additional arguments passed totuber_GET.

Value

playlist items

References

https://developers.google.com/youtube/v3/docs/playlists/list

Examples

## Not run: # Set API token via yt_oauth() firstget_playlist_items(filter =                       c(playlist_id = "PLrEnWoR732-CN09YykVof2lxdI3MLOZda"))get_playlist_items(filter =                       c(playlist_id = "PL0fOlXVeVW9QMO3GoESky4yDgQfK2SsXN"),                       max_results = 51)## End(Not run)

Get Playlists

Description

Get Playlists

Usage

get_playlists(  filter = NULL,  part = "snippet",  max_results = 50,  hl = NULL,  page_token = NULL,  simplify = TRUE,  ...)

Arguments

filter

string; Required.named vector of length 1potential names of the entry in the vector:channel_id: ID of the channelplaylist_id: YouTube playlist ID.

part

Required. One of the following:contentDetails, id,localizations, player, snippet, status. Default:contentDetails.

max_results

Maximum number of items that should be returned.Integer. Optional. Default is 50. Values over 50 trigger additionalrequests and may increase API quota usage.

hl

Language used for text values. Optional. Default isen-US.For other allowed language codes, seelist_langs.

page_token

specific page in the result set that should be returned,optional

simplify

Data Type: Boolean. Default isTRUE. IfTRUE and if part requested iscontentDetails,the function returns adata.frame. Else a list with all theinformation returned.

...

Additional arguments passed totuber_GET.

Value

playlistsWhensimplify isTRUE, adata.frame with 4columns is returned:kind, etag, id, contentDetails.itemCount

References

https://developers.google.com/youtube/v3/docs/playlists/list

Examples

## Not run: # Set API token via yt_oauth() firstget_playlists(filter=c(channel_id="UCMtFAi84ehTSYSE9XoHefig"))get_playlists(filter=c(channel_id="UCMtFAi84ehTSYSE9X")) # incorrect Channel ID## End(Not run)

Description

Takes a video id and returns related videos

Usage

get_related_videos(  video_id = NULL,  max_results = 50,  safe_search = "none",  ...)

Arguments

video_id

Character. Required. No default.

max_results

Maximum number of items that should be returned.Integer. Optional. Default is 50. Values over 50 trigger multiple requests andmay increase API quota usage.

safe_search

Character. Optional. Takes one of three values:'moderate','none' (default) or'strict'

...

Additional arguments passed totuber_GET.

Value

data.frame with 16 columns:video_id, rel_video_id,publishedAt, channelId, title, description,thumbnails.default.url, thumbnails.default.width, thumbnails.default.height,thumbnails.medium.url,thumbnails.medium.width, thumbnails.medium.height, thumbnails.high.url,thumbnails.high.width,thumbnails.high.height, channelTitle, liveBroadcastContent

References

https://developers.google.com/youtube/v3/docs/search/list

Examples

## Not run: # Set API token via yt_oauth() firstget_related_videos(video_id = "yJXTXN4xrI8")## End(Not run)

Get statistics of a Video

Description

Get statistics of a Video

Usage

get_stats(video_id = NULL, ...)

Arguments

video_id

Character. Id of the video. Required.

...

Additional arguments passed totuber_GET.

Value

list with 6 elements:id, viewCount, likeCount,dislikeCount, favoriteCount, commentCount

References

https://developers.google.com/youtube/v3/docs/videos/list#parameters

Examples

## Not run: # Set API token via yt_oauth() firstget_stats(video_id="N708P-A45D0")## End(Not run)

Get Subscriptions

Description

Get Subscriptions

Usage

get_subscriptions(  filter = NULL,  part = "contentDetails",  max_results = 50,  for_channel_id = NULL,  order = NULL,  page_token = NULL,  ...)

Arguments

filter

string; Required.named vector of length 1potential names of the entry in the vector:channel_id: ID of the channel. Required. No default.subscription_id: YouTube subscription ID

part

Part of the resource requested. Required. Character.A comma separated list of one or more of the following:contentDetails, id, snippet, subscriberSnippet. e.g. "id, snippet","id", etc. Default:contentDetails.

max_results

Maximum number of items that should be returned.Integer. Optional. Default is 50. Values over 50 will trigger additionalrequests and may increase API quota usage.

for_channel_id

Optional. String. A comma-separated list ofchannel IDs. Limits response to subscriptions matching those channels.

order

method that will be used to sort resources in the APIresponse. Takes one of the following: alphabetical, relevance, unread

page_token

Specific page in the result set that should bereturned. Optional. String.

...

Additional arguments passed totuber_GET.

Value

named list of subscriptions

References

https://developers.google.com/youtube/v3/docs/subscriptions/list

Examples

## Not run: # Set API token via yt_oauth() firstget_subscriptions(filter = c(channel_id = "UChTJTbr5kf3hYazJZO-euHg"))## End(Not run)

Get Details of a Video or Videos

Description

Get details such as when the video was published, the title, description,thumbnails, category etc.

Usage

get_video_details(  video_id = NULL,  part = "snippet",  as.data.frame = FALSE,  ...)

Arguments

video_id

Comma separated list of IDs of the videos for whichdetails are requested. Required.

part

Comma-separated vector of video resource properties requested.Options include:contentDetails, fileDetails, id, liveStreamingDetails,localizations, player, processingDetails,recordingDetails, snippet, statistics, status, suggestions, topicDetails

as.data.frame

Logical, returns the requested information as data.frame.Does not work for:fileDetails, suggestions, processingDetails

...

Additional arguments passed totuber_GET.

Value

list. If part is snippet, the list will have the following elements:id (video id that was passed),publishedAt, channelId, title, description, thumbnails,channelTitle, categoryId, liveBroadcastContent, localized,defaultAudioLanguage

References

https://developers.google.com/youtube/v3/docs/videos/list

Examples

## Not run: # Set API token via yt_oauth() firstget_video_details(video_id = "yJXTXN4xrI8")get_video_details(video_id = "yJXTXN4xrI8", part = "contentDetails")# retrieve multiple parametersget_video_details(video_id = "yJXTXN4xrI8", part = c("contentDetails", "status"))# get details for multiple videos as data frameget_video_details(video_id = c("LDZX4ooRsWs", "yJXTXN4xrI8"), as.data.frame = TRUE)## End(Not run)

List reasons that can be used to report abusive videos

Description

List reasons that can be used to report abusive videos

Usage

list_abuse_report_reasons(part = "id, snippet", hl = "en-US", ...)

Arguments

part

Caption resource requested. Required. Comma separated list ofone or more of thefollowing:id, snippet. e.g.,"id, snippet","id", etc.Default:snippet.

hl

Language used for text values. Optional. Default isen-US.For other allowed language codes, seelist_langs.

...

Additional arguments passed totuber_GET.

Value

If no results, empty data.frame returnedIf part requested = "id, snippet" or "snippet",data.frame with 4 columns:etag, id, label, secReasonsIf part requested = "id", data.frame with 2 columns:etag, id

References

https://developers.google.com/youtube/v3/docs/videoAbuseReportReasons/list

Examples

## Not run: # Set API token via yt_oauth() firstlist_abuse_report_reasons()list_abuse_report_reasons(part="id")list_abuse_report_reasons(part="snippet")## End(Not run)

List Captions of a Video

Description

List Captions of a Video

Usage

list_caption_tracks(  part = "snippet",  video_id = NULL,  lang = "en",  id = NULL,  simplify = TRUE,  ...)

Arguments

part

Caption resource requested. Required. Comma separatedlist of one or more of thefollowing:id, snippet. e.g., "id, snippet", "id" Default:snippet.

video_id

ID of the video whose captions are requested. Required.No default.

lang

Language of the caption; required; default is English ("en")

id

comma-separated list of IDs that identify the captionresources that should be retrieved; optional; string

simplify

Boolean. Default is TRUE. When TRUE, and part issnippet, a data.frame is returned

...

Additional arguments passed totuber_GET.

Value

list of caption tracks. Whensimplify isTRUE, adata.frame is returned withfollowing columns:videoId, lastUpdated, trackKind, language, name,audioTrackType, isCC,isLarge, isEasyReader, isDraft, isAutoSynced, status, id (caption id)

References

https://developers.google.com/youtube/v3/docs/captions/list

Examples

## Not run: # Set API token via yt_oauth() firstlist_caption_tracks(video_id = "yJXTXN4xrI8")## End(Not run)

Upload Video to Youtube

Description

Upload Video to Youtube

Usage

list_captions(video_id, query = NULL, ...)

Arguments

video_id

ID of the YouTube video

query

Fields for 'query' in 'GET'

...

Additional arguments to send totuber_GET andthereforeGET

Value

A list of the response object from theGET and contentabout captions

Examples

## Not run: video_id <- "M7FIvfx5J10"list_captions(video_id)## End(Not run)

List Channel Activity

Description

Returns a list of channel events that match the request criteria.

Usage

list_channel_activities(  filter = NULL,  part = "snippet",  max_results = 50,  page_token = NULL,  published_after = NULL,  published_before = NULL,  region_code = NULL,  simplify = TRUE,  ...)

Arguments

filter

string; Required.named vector of length 1potential names of the entry in the vector:channel_id: ID of the channel. Required. No default.

part

specify which part do you want. It can only be one of the three:contentDetails, id, snippet. Default issnippet.

max_results

Maximum number of items that should be returned. Integer.Optional. Default is 50. Values over 50 will trigger additional requests andmay increase API quota usage.

page_token

specific page in the result set that should be returned,optional

published_after

Character. Optional. RFC 339 Format. For instance,"1970-01-01T00:00:00Z"

published_before

Character. Optional. RFC 339 Format. For instance,"1970-01-01T00:00:00Z"

region_code

ISO 3166-1 alpha-2 country code, optional, see alsolist_regions

simplify

Data Type: Boolean. Default isTRUE. IfTRUEand if part requested iscontentDetails,the function returns adata.frame. Else a list with all theinformation returned.

...

Additional arguments passed totuber_GET.

Value

named listIfsimplify isTRUE, a data.frame is returned with 18 columns:publishedAt, channelId, title, description, thumbnails.default.url,thumbnails.default.width, thumbnails.default.height,thumbnails.medium.url, thumbnails.medium.width, thumbnails.medium.height,thumbnails.high.url, thumbnails.high.width,thumbnails.high.height, thumbnails.standard.url, thumbnails.standard.width,thumbnails.standard.height, channelTitle, type

References

https://developers.google.com/youtube/v3/docs/activities/list

Examples

## Not run: # Set API token via yt_oauth() firstlist_channel_activities(filter = c(channel_id = "UCRw8bIz2wMLmfgAgWm903cA"))list_channel_activities(filter = c(channel_id = "UCRw8bIz2wMLmfgAgWm903cA", regionCode="US"))list_channel_activities(filter = c(channel_id = "UCMtFAi84ehTSYSE9XoHefig"),                        published_before = "2016-02-10T00:00:00Z",                        published_after = "2016-01-01T00:00:00Z")## End(Not run)

Returns List of Requested Channel Resources

Description

Returns List of Requested Channel Resources

Usage

list_channel_resources(  filter = NULL,  part = "contentDetails",  max_results = 50,  page_token = NULL,  hl = "en-US",  ...)

Arguments

filter

string; Required.named vector with a single valid namepotential names of the entry in the vector:category_id: YouTube guide category that returns channels associatedwith that categoryusername: YouTube username that returns the channel associated with thatusername. Multiple usernames can be provided.channel_id: a comma-separated list of the YouTube channel ID(s) forthe resource(s) that are being retrieved

part

a comma-separated list of channel resource properties thatresponse will include a string. Required.One of the following:auditDetails, brandingSettings, contentDetails,contentOwnerDetails, id, invideoPromotion, localizations, snippet,statistics, status, topicDetails.Default iscontentDetails.

max_results

Maximum number of items that should be returned. Integer.Optional. Default is 50. Values over 50 will trigger additional requests andmay increase API quota usage.

page_token

specific page in the result set that should be returned,optional

hl

Language used for text values. Optional. The default isen-US.For other allowed language codes, seelist_langs.

...

Additional arguments passed totuber_GET.

Value

list. Ifusername is used infilter,a data frame with columnsusername andchannel_id is returned.

References

https://developers.google.com/youtube/v3/docs/channels/list

Examples

## Not run: # Set API token via yt_oauth() firstlist_channel_resources(filter = c(channel_id = "UCT5Cx1l4IS3wHkJXNyuj4TA"))list_channel_resources(filter = c(username = "latenight"), part = "id")list_channel_resources(filter = c(username = c("latenight", "PBS")),                       part = "id")## End(Not run)

List Channel Sections

Description

Returns list of channel sections that channel id belongs to.

Usage

list_channel_sections(filter = NULL, part = "snippet", hl = NULL, ...)

Arguments

filter

string; Required.named vector of length 1potential names of the entry in the vector:channel_id: Channel IDid: Section ID

part

specify which part do you want. It can only be one of thefollowing:contentDetails, id, localizations, snippet, targeting.Default issnippet.

hl

language that will be used for text values, optional, defaultis en-US. See alsolist_langs

...

Additional arguments passed totuber_GET.

Value

captions for the video from one of the first track

References

https://developers.google.com/youtube/v3/docs/activities/list

Examples

## Not run: # Set API token via yt_oauth() firstlist_channel_sections(c(channel_id = "UCRw8bIz2wMLmfgAgWm903cA"))## End(Not run)

Returns List of Requested Channel Videos

Description

Iterate through themax_results number of playlists in channel and getthe videos for each of the playlists.

Usage

list_channel_videos(  channel_id = NULL,  max_results = 50,  page_token = NULL,  hl = "en-US",  ...)

Arguments

channel_id

String. ID of the channel. Required.

max_results

Maximum number of videos returned. Integer. Default is 50.If the number is over 50, all the videos will be returned.

page_token

Specific page in the result set that should be returned.Optional.

hl

Language used for text values. Optional. Default isen-US.For other allowed language codes, seelist_langs

...

Additional arguments passed totuber_GET.

Value

list ofdata.frame with each list corresponding to a differentplaylist

References

https://developers.google.com/youtube/v3/docs/channels/list

Examples

## Not run: # Set API token via yt_oauth() firstlist_channel_videos(channel_id = "UCXOKEdfOFxsHO_-Su3K8SHg")list_channel_videos(channel_id = "UCXOKEdfOFxsHO_-Su3K8SHg", max_results = 10)## End(Not run)

Get list of categories that can be associated with YouTube channels

Description

Get list of categories that can be associated with YouTube channels

Usage

list_guidecats(filter = NULL, hl = NULL, ...)

Arguments

filter

string; Required.named vector of length 1potential names of the entry in the vector:region_code: Character. Required. Has to be a ISO 3166-1 alpha-2 code(seehttps://www.iso.org/obp/ui/#search)category_id: YouTube channel category ID

hl

Language used for text values. Optional. Default isen-US.For other allowed language codes, seelist_langs.

...

Additional arguments passed totuber_GET.

Value

data.frame with 5 columns:region_code, channelId, title,etag, id

References

https://developers.google.com/youtube/v3/docs/guideCategories/list

Examples

## Not run: # Set API token via yt_oauth() firstlist_guidecats(c(region_code = "JP"))## End(Not run)

List Languages That YouTube Currently Supports

Description

List Languages That YouTube Currently Supports

Usage

list_langs(hl = NULL, ...)

Arguments

hl

Language used for text values. Optional. Default isen-US.For other allowed language codes, seelist_langs.

...

Additional arguments passed totuber_GET.

Value

data.frame with 3 columns:hl (two letter abbreviation),name (of the language),etag

References

https://developers.google.com/youtube/v3/docs/i18nLanguages/list

Examples

## Not run: # Set API token via yt_oauth() firstlist_langs()## End(Not run)

List My videos

Description

List My videos

Usage

list_my_videos(...)

Arguments

...

additional arguments to pass tolist_channel_videos

Value

data.frame with each list corresponding to a differentplaylist

Examples

## Not run:   list_my_videos()## End(Not run)

List Content Regions That YouTube Currently Supports

Description

List Content Regions That YouTube Currently Supports

Usage

list_regions(hl = NULL, ...)

Arguments

hl

Language used for text values. Optional. Default isen-US.For other allowed language codes, seelist_langs.

...

Additional arguments passed totuber_GET.

Value

data.frame with 3 columns:gl (two letter abbreviation),name (of the region),etag

References

https://developers.google.com/youtube/v3/docs/i18nRegions/list

Examples

## Not run: # Set API token via yt_oauth() firstlist_regions()## End(Not run)

List of Categories That Can be Associated with Videos

Description

List of Categories That Can be Associated with Videos

Usage

list_videocats(filter = NULL, ...)

Arguments

filter

string; Required.named vector of length 1potential names of the entry in the vector:region_code: Character. Required. Has to be a ISO 3166-1 alpha-2code (seehttps://www.iso.org/obp/ui/#search)category_id: video category ID

...

Additional arguments passed totuber_GET.

Value

data.frame with 6 columns:region_code, channelId, title, assignable, etag, id

References

https://developers.google.com/youtube/v3/docs/videoCategories/list

Examples

## Not run: # Set API token via yt_oauth() firstlist_videocats(c(region_code = "JP"))list_videocats() # Will throw an error asking for a valid filter with valid region_code## End(Not run)

List (Most Popular) Videos

Description

List (Most Popular) Videos

Usage

list_videos(  part = "contentDetails",  max_results = 50,  page_token = NULL,  hl = NULL,  region_code = NULL,  video_category_id = NULL,  ...)

Arguments

part

Required. Comma separated string including one or more of thefollowing:contentDetails,fileDetails, id, liveStreamingDetails, localizations, player,processingDetails, recordingDetails,snippet, statistics, status, suggestions, topicDetails. Default:contentDetails.

max_results

Maximum number of items that should be returned. Integer.Optional. Default is 50. Values over 50 will trigger multiple requests andmay use additional API quota.

page_token

specific page in the result set that should be returned,optional

hl

Language used for text values. Optional. Default isen-US.For other allowed language codes, seelist_langs.

region_code

Character. Required. Has to be a ISO 3166-1 alpha-2 code(seehttps://www.iso.org/obp/ui/#search).

video_category_id

the video category for which the chart should beretrieved. See alsolist_videocats.

...

Additional arguments passed totuber_GET.

Value

data.frame with 5 columns:channelId, title, assignable, etag, id

References

https://developers.google.com/youtube/v3/docs/search/list

Examples

## Not run: # Set API token via yt_oauth() firstlist_videos()## End(Not run)

Apply Unicode Handling to YouTube API Response

Description

Applies consistent Unicode handling to common YouTube API response fields

Usage

process_youtube_text(  response,  text_fields = c("title", "description", "textDisplay", "textOriginal", "channelTitle",    "authorDisplayName", "categoryId"))

Arguments

response

List or data.frame containing YouTube API response data

text_fields

Character vector of field names to process. Default: common YouTube text fields

Value

Processed response with proper Unicode handling


YouTube API Quota Management

Description

Functions to track and manage YouTube API quota usage


Read SBV file

Description

Read SBV file

Usage

read_sbv(file)

Arguments

file

The file name of thesbv file

Value

Adata.frame with start/stop times and the text

Examples

if (yt_authorized()){vids <- list_my_videos()res <- list_caption_tracks(video_id = vids$contentDetails.videoId[1])cap <- get_captions(id = res$id, as_raw = FALSE)tfile <- tempfile(fileext = ".sbv")writeLines(cap, tfile)x <- read_sbv(tfile)if (requireNamespace("hms", quietly = TRUE)) {  x$start <- hms::as_hms(x$start)  x$stop <- hms::as_hms(x$stop)}}

Safely Convert Text to UTF-8

Description

Ensures text fields are properly encoded in UTF-8

Usage

safe_utf8(text, fallback_encoding = "latin1")

Arguments

text

Character vector or list of text to convert

fallback_encoding

Character. Encoding to assume if detection fails. Default: "latin1"

Value

Character vector with UTF-8 encoding


Track Quota Usage

Description

Internal function to track API usage

Usage

track_quota_usage(endpoint, parts = NULL, additional_cost = 0)

Arguments

endpoint

Character. API endpoint name

parts

Character vector. Parts requested

additional_cost

Integer. Additional cost for complex operations


tuber provides access to the YouTube API V3.

Description

tuber provides access to the YouTube API V3 viaRESTful calls.


DELETE

Description

DELETE

Usage

tuber_DELETE(path, query, ...)

Arguments

path

path to specific API request URL

query

query list

...

Additional arguments passed toGET.

Value

list


GET

Description

GET

Usage

tuber_GET(path, query, auth = "token", ...)

Arguments

path

path to specific API request URL

query

query list

auth

A character vector of the authentication method, either "token" (the default) or "key"

...

Additional arguments passed toGET.

Value

list


POST

Description

POST

Usage

tuber_POST(path, query, body = "", ...)

Arguments

path

path to specific API request URL

query

query list

body

passing image through body

...

Additional arguments passed toGET.

Value

list


POST encoded in json

Description

POST encoded in json

Usage

tuber_POST_json(path, query, body = "", ...)

Arguments

path

path to specific API request URL

query

query list

body

passing image through body

...

Additional arguments passed toGET.

Value

list


Request Response Verification

Description

Request Response Verification

Usage

tuber_check(req)

Arguments

req

request

Value

in case of failure, a message


Unicode and Text Processing Utilities

Description

Internal functions for consistent text and Unicode handling across tuber


Update a YouTube Video's Metadata

Description

This function updates the metadata of an existing YouTube video using the YouTube Data API.

Usage

update_video_metadata(  video_id,  title,  category_id,  description,  privacy_status,  made_for_kids)

Arguments

video_id

A character string specifying the ID of the video you want to update.

title

A character string specifying the new title for the video.

category_id

A character string specifying the new category ID for the video.

description

A character string specifying the new description for the video.

privacy_status

A character string specifying the new privacy status for the video ('public', 'private', or 'unlisted').

made_for_kids

A boolean specifying whether the video is self-declared as made for kids.

Value

A list containing the server response after the update attempt.

Examples

## Not run: update_video_metadata(video_id = "YourVideoID",                      title = "New Video Title",                      category_id = "24",                      description = "New Description",                      privacy_status = "public",                      made_for_kids = FALSE)## End(Not run)

Upload Video Caption to Youtube

Description

Upload Video Caption to Youtube

Usage

upload_caption(  file,  video_id,  language = "en-US",  caption_name,  is_draft = FALSE,  query = NULL,  open_url = FALSE,  ...)

Arguments

file

Filename of the caption, probably '.srt'

video_id

YouTube Video ID. Trylist_my_videos for examples.

language

character string of 'BCP47' language type.Seehttps://www.rfc-editor.org/rfc/bcp/bcp47.txt for language specification

caption_name

character vector of the name for the caption.

is_draft

logical indicating whether the caption track is a draft.

query

Fields for 'query' in 'POST'

open_url

Should the video be opened usingbrowseURL

...

Additional arguments to send toPOST

Value

A list of the response object from thePOST, content,and the URL of the video

Note

Seehttps://developers.google.com/youtube/v3/docs/captions#resource forfull specification

Examples

## Not run: xx = list_my_videos()video_id = xx$contentDetails.videoId[1]video_id = as.character(video_id)language = "en-US"## End(Not run)

Upload Video to Youtube

Description

Upload Video to Youtube

Usage

upload_video(  file,  snippet = NULL,  status = list(privacyStatus = "public"),  query = NULL,  open_url = FALSE,  ...)

Arguments

file

Filename of the video locally

snippet

Additional fields for the video, including 'description'and 'title'. Seehttps://developers.google.com/youtube/v3/docs/videos#resource forother fields. Coerced to a JSON object

status

Additional fields to be put into thestatus input.options for 'status' are 'license' (which should hold:'creativeCommon', or 'youtube'), 'privacyStatus', 'publicStatsViewable','publishAt'.

query

Fields for 'query' in 'POST'

open_url

Should the video be opened usingbrowseURL

...

Additional arguments to send totuber_POST andthereforePOST

Value

A list of the response object from thePOST, content,and the URL of the uploaded

Note

The information for 'status' and 'snippet' are athttps://developers.google.com/youtube/v3/docs/videos#resourcebut the subset of these fields to pass in are located at:https://developers.google.com/youtube/v3/docs/videos/insertThe 'part“ parameter serves two purposes in this operation.It identifies the properties that the write operation will set, this will beautomatically detected by the names of 'body'.Seehttps://developers.google.com/youtube/v3/docs/videos/insert#usage

Examples

snippet = list(title = "Test Video",description = "This is just a random test.",tags = c("r language", "r programming", "data analysis"))status = list(privacyStatus = "private")

Get Current Quota Usage

Description

Returns the current estimated quota usage for the day

Usage

yt_get_quota_usage()

Value

List with quota_used, quota_limit, quota_remaining, and reset_time

Examples

## Not run: quota_status <- yt_get_quota_usage()cat("Used:", quota_status$quota_used, "/", quota_status$quota_limit)## End(Not run)

Manage YouTube API key

Description

These functions manage your YouTube API key and package key in.Renviron.

Usage

yt_get_key(decrypt = FALSE)yt_set_key(key, type)

Arguments

decrypt

A boolean vector specifying whether to decrypt the supplied key with 'httr2::secret_decrypt()'. Defaults to 'FALSE'. If 'TRUE', requires the environment variable 'TUBER_KEY' to be set in '.Renviron'.

key

A character vector specifying a YouTube API key.

type

A character vector specifying the type of API key to set. One of 'api' (the default, stored in ‘YOUTUBE_KEY') or ’package'. Package keys are stored in 'TUBER_KEY' and are used to decrypt API keys, for use in continuous integration and testing.

Value

'yt_get_key()' returns a character vector with the YouTube API key stored in '.Renviron'. If this value is not stored in '.Renviron', the functions return 'NULL'.

When the ‘type' argument is set to ’api', ‘yt_set_key()' assigns a YouTube API key to 'YOUTUBE_KEY' in '.Renviron' and invisibly returns 'NULL'. When the 'type' argument is set to ’package', 'yt_set_key()' assigns a package key to 'TUBER_KEY' in '.Renviron' and invisibly returns 'NULL'.

Examples

## Not run: ## for interactive useyt_get_key()list_channel_videos(  channel_id = "UCDgj5-mFohWZ5irWSFMFcng",  max_results = 3,  part = "snippet",  auth = "key")## for continuous integration and testingyt_set_key(httr2::secret_make_key(), type = "package")x <- httr2::secret_encrypt("YOUR_YOUTUBE_API_KEY", "TUBER_KEY")yt_set_key(x, type = "api")yt_get_key(decrypt = TRUE)list_channel_videos(  channel_id = "UCDgj5-mFohWZ5irWSFMFcng",  max_results = 3,  part = "snippet",  auth = "key")## End(Not run)

Set up Authorization

Description

The function looks for.httr-oauth in the working directory. If itdoesn't find it, it expects an application ID and a secret.If you want to remove the existing.httr-oauth, set remove_old_oauthto TRUE. By default, it is set to FALSE.The function launches a browser to allow you to authorize the application

Usage

yt_oauth(  app_id = NULL,  app_secret = NULL,  scope = "ssl",  token = ".httr-oauth",  ...)

Arguments

app_id

client id; required; no default

app_secret

client secret; required; no default

scope

Character.ssl,basic,own_account_readonly,upload_and_manage_own_videos,partner, andpartner_audit.Required.ssl andbasic are basically interchangeable.Default isssl.

token

path to file containing the token. If a path is given,the function will first try to read from it.Default is.httr-oauth in the local directory.So if there is such a file, the function will first try to read from it.

...

Additional arguments passed tooauth2.0_token

Details

If a browser cannot be opened, passuse_oob = TRUE toyt_oauth() so authentication can be completed using anout-of-band code.Delete the.httr-oauth file in the working directory to forcere-authentication.

Value

sets the google_token option and also saves.httr_oauthin the working directory (find out the working directory viagetwd())

References

https://developers.google.com/youtube/v3/docs/

https://developers.google.com/youtube/v3/guides/auth/client-side-web-appsfor different scopes

Examples

 ## Not run: yt_oauth(paste0("998136489867-5t3tq1g7hbovoj46dreqd6k5kd35ctjn",                ".apps.googleusercontent.com"),         "MbOSt6cQhhFkwETXKur-L9rN")## End(Not run)

Reset Quota Counter

Description

Reset the quota counter (typically done automatically at midnight UTC)

Usage

yt_reset_quota()

Description

Search for videos, channels and playlists. (By default, the functionsearches for videos.)

Usage

yt_search(  term = NULL,  max_results = 50,  channel_id = NULL,  channel_type = NULL,  type = "video",  event_type = NULL,  location = NULL,  location_radius = NULL,  published_after = NULL,  published_before = NULL,  video_definition = "any",  video_caption = "any",  video_license = "any",  video_syndicated = "any",  region_code = NULL,  relevance_language = "en",  video_type = "any",  simplify = TRUE,  get_all = TRUE,  page_token = NULL,  max_pages = Inf,  ...)

Arguments

term

Character. Search term; required; no defaultFor using Boolean operators, see the API documentation.Here's some of the relevant information:"Your request can also use the Boolean NOT (-) and OR (|) operators toexclude videos or tofind videos that are associated with one of several search terms. Forexample, to searchfor videos matching either "boating" or "sailing", set the q parametervalue to boating|sailing.Similarly, to search for videos matching either "boating" or "sailing"but not "fishing",set the q parameter value to boating|sailing -fishing"

max_results

Maximum number of items that should be returned in total.Integer. Optional. Can be between 1 and 500. Default is 50. Ifget_all = TRUE, multiple API calls are made until this manyresults are collected (subject to YouTube limits). Requesting a large numberof results will consume more API quota. Search results areconstrained to a maximum of 500 videos if type is video and we have avalue ofchannel_id.

channel_id

Character. Only return search results from thischannel; Optional.

channel_type

Character. Optional. Takes one of two values:'any', 'show'. Default is'any'

type

Character. Optional. Takes one of three values:'video', 'channel', 'playlist'. Default is'video'.

event_type

Character. Optional. Takes one of three values:'completed', 'live', 'upcoming'

location

Character. Optional. Latitude and Longitude withinparentheses, e.g. "(37.42307,-122.08427)"

location_radius

Character. Optional. e.g. "1500m", "5km","10000ft", "0.75mi"

published_after

Character. Optional. RFC 339 Format.For instance, "1970-01-01T00:00:00Z"

published_before

Character. Optional. RFC 339 Format.For instance, "1970-01-01T00:00:00Z"

video_definition

Character. Optional.Takes one of three values:'any' (return all videos; Default),'high', 'standard'

video_caption

Character. Optional. Takes one of three values:'any' (return all videos; Default),'closedCaption', 'none'.Type must be set to video.

video_license

Character. Optional.Takes one of three values:'any' (return all videos; Default),'creativeCommon' (return videos with Creative Commonslicense),'youtube' (return videos with standard YouTube license).

video_syndicated

Character. Optional. Takes one of two values:'any' (return all videos; Default),'true'(return only syndicated videos)

region_code

Character. Required. Has to be a ISO 3166-1 alpha-2 code(seehttps://www.iso.org/obp/ui/#search).

relevance_language

Character. Optional. The relevance_languageargument instructs the API to return search results that are most relevant tothe specified language. The parameter value is typically an ISO 639-1two-letter language code. However, you should use the values zh-Hans forsimplified Chinese and zh-Hant for traditional Chinese. Please note thatresults in other languages will still be returned if they are highly relevantto the search query term.

video_type

Character. Optional. Takes one of three values:'any' (return all videos; Default),'episode'(return episode of shows), 'movie' (return movies)

simplify

Boolean. Return a data.frame ifTRUE.Default isTRUE.IfTRUE, it returns a list that carries additional information.

get_all

get all results, iterating through all the resultspages. Default isTRUE.Result is adata.frame. Optional.

page_token

specific page in the result set that should bereturned, optional

max_pages

Maximum number of pages to retrieve when get_all is TRUE.Default is Inf (no page limit). Setting a lower value can reduce API quotausage.

...

Additional arguments passed totuber_GET.

Value

data.frame with 16 elements:video_id, publishedAt,channelId, title, description,thumbnails.default.url, thumbnails.default.width, thumbnails.default.height,thumbnails.medium.url,thumbnails.medium.width, thumbnails.medium.height, thumbnails.high.url,thumbnails.high.width,thumbnails.high.height, channelTitle, liveBroadcastContentThe returned data.frame also has the following attributes:total_results: The total number of results reported by the APIactual_results: The actual number of rows returnedapi_limit_reached: Whether the YouTube API result limit was reached

References

https://developers.google.com/youtube/v3/docs/search/list

Examples

## Not run: # Set API token via yt_oauth() firstyt_search(term = "Barack Obama")yt_search(term = "Barack Obama", published_after = "2016-10-01T00:00:00Z")yt_search(term = "Barack Obama", published_before = "2016-09-01T00:00:00Z")yt_search(term = "Barack Obama", published_before = "2016-03-01T00:00:00Z",                               published_after = "2016-02-01T00:00:00Z")yt_search(term = "Barack Obama", published_before = "2016-02-10T00:00:00Z",                               published_after = "2016-01-01T00:00:00Z")# To check how many results were found vs. how many were returned:results <- yt_search(term = "drone videos")attr(results, "total_results")  # Total number reported by YouTubeattr(results, "actual_results") # Number actually returnedattr(results, "api_limit_reached") # Whether API limit was reached## End(Not run)

Set Quota Limit

Description

Set the daily quota limit (default is 10,000 units)

Usage

yt_set_quota_limit(limit)

Arguments

limit

Integer. Daily quota limit in units

Examples

## Not run: # If you have a higher quota limityt_set_quota_limit(50000)## End(Not run)

Check if authentication token is in options

Description

Check if authentication token is in options

Usage

yt_token()yt_authorized()yt_check_token()

Value

A Token2.0 class


Description

Search YouTube by TopicIt uses the Freebase list of topics

Usage

yt_topic_search(topic = NULL, ...)

Arguments

topic

topic being searched for; required; no default

...

Additional arguments passed totuber_GET.

Value

a list

Examples

 ## Not run: # Set API token via yt_oauth() firstyt_topic_search(topic = "Barack Obama")## End(Not run)

[8]ページ先頭

©2009-2025 Movatter.jp