Title: | 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, see <https://developers.google.com/youtube/v3/>. |
Authors: | Gaurav Sood [aut, cre], Kate Lyons [ctb], John Muschelli [ctb] |
Maintainer: | Gaurav Sood <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.9.9 |
Built: | 2024-11-15 05:23:00 UTC |
Source: | https://github.com/gojiplus/tuber |
Add Video to Playlist
add_video_to_playlist(playlist_id, video_id, position = NULL, ...)
add_video_to_playlist(playlist_id, video_id, position = NULL, ...)
playlist_id |
string; Required. The ID of the playlist. |
video_id |
string; Required. The ID of the video to add. |
... |
Additional arguments passed to |
Details of the added video in the playlist.
https://developers.google.com/youtube/v3/docs/playlistItems/insert
## Not run: # Set API token via yt_oauth() first add_video_to_playlist(playlist_id = "YourPlaylistID", video_id = "2_gLD1jarfU") ## End(Not run)
## Not run: # Set API token via yt_oauth() first add_video_to_playlist(playlist_id = "YourPlaylistID", video_id = "2_gLD1jarfU") ## End(Not run)
This function updates the title of an existing YouTube playlist using the YouTube Data API.
change_playlist_title(playlist_id, new_title)
change_playlist_title(playlist_id, new_title)
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. |
A list containing the server response after the update attempt.
## Not run: change_playlist_title(playlist_id = "YourPlaylistID", new_title = "New Playlist Title") ## End(Not run)
## Not run: change_playlist_title(playlist_id = "YourPlaylistID", new_title = "New Playlist Title") ## End(Not run)
Create New Playlist
create_playlist(title, description, status, ...)
create_playlist(title, description, status, ...)
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 to |
The created playlist's details.
https://developers.google.com/youtube/v3/docs/playlists/insert
## Not run: # Set API token via yt_oauth() first create_playlist(title = "My New Playlist", description = "This is a test playlist.") ## End(Not run)
## Not run: # Set API token via yt_oauth() first create_playlist(title = "My New Playlist", description = "This is a test playlist.") ## End(Not run)
Delete a Channel Section
delete_channel_sections(id = NULL, ...)
delete_channel_sections(id = NULL, ...)
id |
Required. ID of the channel section. |
... |
Additional arguments passed to |
https://developers.google.com/youtube/v3/docs/channelSections/delete
## Not run: # Set API token via yt_oauth() first delete_channel_sections(c(channel_id = "UCRw8bIz2wMLmfgAgWm903cA")) ## End(Not run)
## Not run: # Set API token via yt_oauth() first delete_channel_sections(c(channel_id = "UCRw8bIz2wMLmfgAgWm903cA")) ## End(Not run)
Delete a Particular Comment
delete_comments(id = NULL, ...)
delete_comments(id = NULL, ...)
id |
String. Required. id of the comment being retrieved |
... |
Additional arguments passed to |
https://developers.google.com/youtube/v3/docs/comments/delete
## Not run: # Set API token via yt_oauth() first delete_comments(id = "y3ElXcEME3lSISz6izkWVT5GvxjPu8pA") ## End(Not run)
## Not run: # Set API token via yt_oauth() first delete_comments(id = "y3ElXcEME3lSISz6izkWVT5GvxjPu8pA") ## End(Not run)
Delete a Playlist Item
delete_playlist_items(id = NULL, ...)
delete_playlist_items(id = NULL, ...)
id |
String. Required. id of the playlist item that is to be deleted |
... |
Additional arguments passed to |
https://developers.google.com/youtube/v3/docs/playlistItems/delete
## Not run: # Set API token via yt_oauth() first delete_playlist_items(id = "YourPlaylistItemID") ## End(Not run)
## Not run: # Set API token via yt_oauth() first delete_playlist_items(id = "YourPlaylistItemID") ## End(Not run)
Delete a Playlist
delete_playlists(id = NULL, ...)
delete_playlists(id = NULL, ...)
id |
String. Required. id of the playlist that is to be deleted |
... |
Additional arguments passed to |
https://developers.google.com/youtube/v3/docs/playlists/delete
## Not run: # Set API token via yt_oauth() first delete_playlists(id = "y3ElXcEME3lSISz6izkWVT5GvxjPu8pA") ## End(Not run)
## Not run: # Set API token via yt_oauth() first delete_playlists(id = "y3ElXcEME3lSISz6izkWVT5GvxjPu8pA") ## End(Not run)
Delete a Video
delete_videos(id = NULL, ...)
delete_videos(id = NULL, ...)
id |
String. Required. id of the video that is to be deleted |
... |
Additional arguments passed to |
https://developers.google.com/youtube/v3/docs/playlistItems/delete
## Not run: # Set API token via yt_oauth() first delete_videos(id = "y3ElXcEME3lSISz6izkWVT5GvxjPu8pA") ## End(Not run)
## Not run: # Set API token via yt_oauth() first delete_videos(id = "y3ElXcEME3lSISz6izkWVT5GvxjPu8pA") ## End(Not run)
Get statistics on all the videos in a Channel
get_all_channel_video_stats(channel_id = NULL, mine = FALSE, ...)
get_all_channel_video_stats(channel_id = NULL, mine = FALSE, ...)
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 to |
nested named list with top element names:
kind, etag, id,
snippet (list of details of the channel including title)
, statistics (list of 5)
If the channel_id
is mistyped or there is no information, an empty list is returned
https://developers.google.com/youtube/v3/docs/channels/list
## Not run: # Set API token via yt_oauth() first get_all_channel_video_stats(channel_id="UCxOhDvtaoXDAB336AolWs3A") get_all_channel_video_stats(channel_id="UCMtFAi84ehTSYSE9Xo") # Incorrect channel ID ## End(Not run)
## Not run: # Set API token via yt_oauth() first get_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
get_all_comments(video_id = NULL, ...)
get_all_comments(video_id = NULL, ...)
video_id |
string; Required.
|
... |
Additional arguments passed to |
a data.frame
with the following columns:
authorDisplayName, authorProfileImageUrl, authorChannelUrl,
authorChannelId.value, videoId, textDisplay,
canRate, viewerRating, likeCount, publishedAt, updatedAt,
id, moderationStatus, parentId
https://developers.google.com/youtube/v3/docs/commentThreads/list
## Not run: # Set API token via yt_oauth() first get_all_comments(video_id = "a-UQz7fqR3w") ## End(Not run)
## Not run: # Set API token via yt_oauth() first get_all_comments(video_id = "a-UQz7fqR3w") ## End(Not run)
Get statistics of a Channel
get_channel_stats(channel_id = NULL, mine = NULL, ...) list_my_channel(...)
get_channel_stats(channel_id = NULL, mine = NULL, ...) list_my_channel(...)
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 to |
nested named list with top element names:
kind, etag, id, snippet (list of details of the channel
including title), statistics (list of 5)
If the channel_id
is mistyped or there is no information, an empty list is returned
https://developers.google.com/youtube/v3/docs/channels/list
## Not run: # Set API token via yt_oauth() first get_channel_stats(channel_id="UCMtFAi84ehTSYSE9XoHefig") get_channel_stats(channel_id="UCMtFAi84ehTSYSE9Xo") # Incorrect channel ID ## End(Not run)
## Not run: # Set API token via yt_oauth() first get_channel_stats(channel_id="UCMtFAi84ehTSYSE9XoHefig") get_channel_stats(channel_id="UCMtFAi84ehTSYSE9Xo") # Incorrect channel ID ## End(Not run)
Get Comments Threads
get_comment_threads( filter = NULL, part = "snippet", text_format = "html", simplify = TRUE, max_results = 100, page_token = NULL, ... )
get_comment_threads( filter = NULL, part = "snippet", text_format = "html", simplify = TRUE, max_results = 100, page_token = NULL, ... )
filter |
string; Required.
named vector of length 1
potential names of the entry in the vector:
|
part |
Comment resource requested. Required. Comma separated list
of one or more of the
following: |
text_format |
Data Type: Character. Default is |
simplify |
Data Type: Boolean. Default is |
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 the
results. The outcome is a simplified |
page_token |
Specific page in the result set that should be returned. Optional. |
... |
Additional arguments passed to |
Nested named list. The entry items
is a list of comments
along with meta information.
Within each of the items
is an item snippet
which
has an item topLevelComment$snippet$textDisplay
that contains the actual comment.
If simplify is TRUE
, a data.frame
with the following columns:
authorDisplayName, authorProfileImageUrl, authorChannelUrl,
authorChannelId.value, videoId, textDisplay,
canRate, viewerRating, likeCount, publishedAt, updatedAt
https://developers.google.com/youtube/v3/docs/commentThreads/list
## Not run: # Set API token via yt_oauth() first get_comment_threads(filter = c(video_id = "N708P-A45D0")) get_comment_threads(filter = c(video_id = "N708P-A45D0"), max_results = 101) ## End(Not run)
## Not run: # Set API token via yt_oauth() first get_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
get_comments( filter = NULL, part = "snippet", max_results = 100, text_format = "html", page_token = NULL, simplify = TRUE, ... )
get_comments( filter = NULL, part = "snippet", max_results = 100, text_format = "html", page_token = NULL, simplify = TRUE, ... )
filter |
string; Required.
named vector of length 1
potential names of the entry in the vector:
|
part |
Comment resource requested. Required. Comma separated list
of one or more of the
following: |
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 |
page_token |
Specific page in the result set that should be returned. Optional. |
simplify |
Data Type: Boolean. Default is TRUE. If TRUE, the function returns a data frame. Else a list with all the information returned. |
... |
Additional arguments passed to |
Nested named list. The entry items
is a list of comments along
with meta information.
Within each of the items
is an item snippet
which has an
item topLevelComment$snippet$textDisplay
that contains the actual comment.
When filter is comment_id
, and simplify
is TRUE
,
and there is a correct comment id,
it returns a data.frame
with the following cols:
id, authorDisplayName, authorProfileImageUrl, authorChannelUrl,
value, textDisplay, canRate, viewerRating, likeCount
publishedAt, updatedAt
https://developers.google.com/youtube/v3/docs/comments/list
## Not run: # Set API token via yt_oauth() first get_comments(filter = c(comment_id = "z13dh13j5rr0wbmzq04cifrhtuypwl4hsdk")) get_comments(filter = c(parent_id = "z13ds5yxjq3zzptyx04chlkbhx2yh3ezxtc0k")) get_comments(filter = c(comment_id = "z13dh13j5rr0wbmzq04cifrhtuypwl4hsdk, z13dh13j5rr0wbmzq04cifrhtuypwl4hsdk")) ## End(Not run)
## Not run: # Set API token via yt_oauth() first get_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
get_playlist_item_ids( filter = NULL, part = "contentDetails", max_results = 50, video_id = NULL, page_token = NULL, simplify = TRUE, ... )
get_playlist_item_ids( filter = NULL, part = "contentDetails", max_results = 50, video_id = NULL, page_token = NULL, simplify = TRUE, ... )
filter |
string; Required.
named vector of length 1
potential names of the entry in the vector:
|
part |
Required. Comma separated string including one or more of the
following: |
max_results |
Maximum number of items that should be returned. Integer. Optional. Default is 50. If over 50, all the results are returned. |
video_id |
Optional. request should return only the playlist items that contain the specified video. |
page_token |
specific page in the result set that should be returned, optional |
simplify |
returns a data.frame rather than a list. |
... |
Additional arguments passed to |
playlist items
https://developers.google.com/youtube/v3/docs/playlists/list
## Not run: # Set API token via yt_oauth() first get_playlist_items(filter = c(playlist_id = "PLrEnWoR732-CN09YykVof2lxdI3MLOZda")) get_playlist_items(filter = c(playlist_id = "PL0fOlXVeVW9QMO3GoESky4yDgQfK2SsXN"), max_results = 51) ## End(Not run)
## Not run: # Set API token via yt_oauth() first get_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
get_playlist_item_videoids( filter = NULL, part = "contentDetails", max_results = 50, video_id = NULL, page_token = NULL, simplify = TRUE, ... )
get_playlist_item_videoids( filter = NULL, part = "contentDetails", max_results = 50, video_id = NULL, page_token = NULL, simplify = TRUE, ... )
filter |
string; Required.
named vector of length 1
potential names of the entry in the vector:
|
part |
Required. Comma separated string including one or more of the
following: |
max_results |
Maximum number of items that should be returned. Integer. Optional. Default is 50. If over 50, all the results are returned. |
video_id |
Optional. request should return only the playlist items that contain the specified video. |
page_token |
specific page in the result set that should be returned, optional |
simplify |
returns a data.frame rather than a list. |
... |
Additional arguments passed to |
playlist items
https://developers.google.com/youtube/v3/docs/playlists/list
## Not run: # Set API token via yt_oauth() first get_playlist_items(filter = c(playlist_id = "YourPlaylistID")) get_playlist_items(filter = c(playlist_id = "YourPlaylistID"), max_results = 51) ## End(Not run)
## Not run: # Set API token via yt_oauth() first get_playlist_items(filter = c(playlist_id = "YourPlaylistID")) get_playlist_items(filter = c(playlist_id = "YourPlaylistID"), max_results = 51) ## End(Not run)
Get Playlist Items
get_playlist_items( filter = NULL, part = "contentDetails", max_results = 50, video_id = NULL, page_token = NULL, simplify = TRUE, ... )
get_playlist_items( filter = NULL, part = "contentDetails", max_results = 50, video_id = NULL, page_token = NULL, simplify = TRUE, ... )
filter |
string; Required.
named vector of length 1
potential names of the entry in the vector:
|
part |
Required. Comma separated string including one or more of the
following: |
max_results |
Maximum number of items that should be returned. Integer. Optional. Default is 50. If over 50, all the results are returned. |
video_id |
Optional. request should return only the playlist items that contain the specified video. |
page_token |
specific page in the result set that should be returned, optional |
simplify |
returns a data.frame rather than a list. |
... |
Additional arguments passed to |
playlist items
https://developers.google.com/youtube/v3/docs/playlists/list
## Not run: # Set API token via yt_oauth() first get_playlist_items(filter = c(playlist_id = "PLrEnWoR732-CN09YykVof2lxdI3MLOZda")) get_playlist_items(filter = c(playlist_id = "PL0fOlXVeVW9QMO3GoESky4yDgQfK2SsXN"), max_results = 51) ## End(Not run)
## Not run: # Set API token via yt_oauth() first get_playlist_items(filter = c(playlist_id = "PLrEnWoR732-CN09YykVof2lxdI3MLOZda")) get_playlist_items(filter = c(playlist_id = "PL0fOlXVeVW9QMO3GoESky4yDgQfK2SsXN"), max_results = 51) ## End(Not run)
Get Playlists
get_playlists( filter = NULL, part = "snippet", max_results = 50, hl = NULL, page_token = NULL, simplify = TRUE, ... )
get_playlists( filter = NULL, part = "snippet", max_results = 50, hl = NULL, page_token = NULL, simplify = TRUE, ... )
filter |
string; Required.
named vector of length 1
potential names of the entry in the vector:
|
part |
Required. One of the following: |
max_results |
Maximum number of items that should be returned. Integer. Optional. Can be between 0 and 50. Default is 50. |
hl |
Language used for text values. Optional. Default is |
page_token |
specific page in the result set that should be returned, optional |
simplify |
Data Type: Boolean. Default is |
... |
Additional arguments passed to |
playlists
When simplify
is TRUE
, a data.frame
with 4
columns is returned:
kind, etag, id, contentDetails.itemCount
https://developers.google.com/youtube/v3/docs/playlists/list
## Not run: # Set API token via yt_oauth() first get_playlists(filter=c(channel_id="UCMtFAi84ehTSYSE9XoHefig")) get_playlists(filter=c(channel_id="UCMtFAi84ehTSYSE9X")) # incorrect Channel ID ## End(Not run)
## Not run: # Set API token via yt_oauth() first get_playlists(filter=c(channel_id="UCMtFAi84ehTSYSE9XoHefig")) get_playlists(filter=c(channel_id="UCMtFAi84ehTSYSE9X")) # incorrect Channel ID ## End(Not run)
Get statistics of a Video
get_stats(video_id = NULL, ...)
get_stats(video_id = NULL, ...)
video_id |
Character. Id of the video. Required. |
... |
Additional arguments passed to |
list with 6 elements: id, viewCount, likeCount,
dislikeCount, favoriteCount, commentCount
https://developers.google.com/youtube/v3/docs/videos/list#parameters
## Not run: # Set API token via yt_oauth() first get_stats(video_id="N708P-A45D0") ## End(Not run)
## Not run: # Set API token via yt_oauth() first get_stats(video_id="N708P-A45D0") ## End(Not run)
Get Subscriptions
get_subscriptions( filter = NULL, part = "contentDetails", max_results = 50, for_channel_id = NULL, order = NULL, page_token = NULL, ... )
get_subscriptions( filter = NULL, part = "contentDetails", max_results = 50, for_channel_id = NULL, order = NULL, page_token = NULL, ... )
filter |
string; Required.
named vector of length 1
potential names of the entry in the vector:
|
part |
Part of the resource requested. Required. Character.
A comma separated list of one or more of the following:
|
max_results |
Maximum number of items that should be returned. Integer. Optional. Can be between 0 and 50. Default is 50. |
for_channel_id |
Optional. String. A comma-separated list of channel IDs. Limits response to subscriptions matching those channels. |
order |
method that will be used to sort resources in the API response. Takes one of the following: alphabetical, relevance, unread |
page_token |
Specific page in the result set that should be returned. Optional. String. |
... |
Additional arguments passed to |
named list of subscriptions
https://developers.google.com/youtube/v3/docs/subscriptions/list
## Not run: # Set API token via yt_oauth() first get_subscriptions(filter = c(channel_id = "UChTJTbr5kf3hYazJZO-euHg")) ## End(Not run)
## Not run: # Set API token via yt_oauth() first get_subscriptions(filter = c(channel_id = "UChTJTbr5kf3hYazJZO-euHg")) ## End(Not run)
Get details such as when the video was published, the title, description, thumbnails, category etc.
get_video_details( video_id = NULL, part = "snippet", as.data.frame = FALSE, ... )
get_video_details( video_id = NULL, part = "snippet", as.data.frame = FALSE, ... )
video_id |
Comma separated list of IDs of the videos for which details are requested. Required. |
part |
Comma-separated vector of video resource properties requested.
Options include:
|
as.data.frame |
Logical, returns the requested information as data.frame.
Does not work for:
|
... |
Additional arguments passed to |
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
https://developers.google.com/youtube/v3/docs/videos/list
## Not run: # Set API token via yt_oauth() first get_video_details(video_id = "yJXTXN4xrI8") get_video_details(video_id = "yJXTXN4xrI8", part = "contentDetails") # retrieve multiple parameters get_video_details(video_id = "yJXTXN4xrI8", part = c("contentDetails", "status")) # get details for multiple videos as data frame get_video_details(video_id = c("LDZX4ooRsWs", "yJXTXN4xrI8"), as.data.frame = TRUE) ## End(Not run)
## Not run: # Set API token via yt_oauth() first get_video_details(video_id = "yJXTXN4xrI8") get_video_details(video_id = "yJXTXN4xrI8", part = "contentDetails") # retrieve multiple parameters get_video_details(video_id = "yJXTXN4xrI8", part = c("contentDetails", "status")) # get details for multiple videos as data frame get_video_details(video_id = c("LDZX4ooRsWs", "yJXTXN4xrI8"), as.data.frame = TRUE) ## End(Not run)
List reasons that can be used to report abusive videos
list_abuse_report_reasons(part = "id, snippet", hl = "en-US", ...)
list_abuse_report_reasons(part = "id, snippet", hl = "en-US", ...)
part |
Caption resource requested. Required. Comma separated list of
one or more of the
following: |
hl |
Language used for text values. Optional. Default is |
... |
Additional arguments passed to |
If no results, empty data.frame returned
If part requested = "id, snippet" or "snippet",
data.frame
with 4 columns: etag, id, label, secReasons
If part requested = "id", data.frame with 2 columns: etag, id
https://developers.google.com/youtube/v3/docs/videoAbuseReportReasons/list
## Not run: # Set API token via yt_oauth() first list_abuse_report_reasons() list_abuse_report_reasons(part="id") list_abuse_report_reasons(part="snippet") ## End(Not run)
## Not run: # Set API token via yt_oauth() first list_abuse_report_reasons() list_abuse_report_reasons(part="id") list_abuse_report_reasons(part="snippet") ## End(Not run)
Returns a list of channel events that match the request criteria.
list_channel_activities( filter = NULL, part = "snippet", max_results = 50, page_token = NULL, published_after = NULL, published_before = NULL, region_code = NULL, simplify = TRUE, ... )
list_channel_activities( filter = NULL, part = "snippet", max_results = 50, page_token = NULL, published_after = NULL, published_before = NULL, region_code = NULL, simplify = TRUE, ... )
filter |
string; Required.
named vector of length 1
potential names of the entry in the vector:
|
part |
specify which part do you want. It can only be one of the three:
|
max_results |
Maximum number of items that should be returned. Integer. Optional. Can be between 0 and 50. Default is 50. |
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 also
|
simplify |
Data Type: Boolean. Default is |
... |
Additional arguments passed to |
named list
If simplify
is TRUE
, 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
https://developers.google.com/youtube/v3/docs/activities/list
## Not run: # Set API token via yt_oauth() first list_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)
## Not run: # Set API token via yt_oauth() first list_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
list_channel_resources( filter = NULL, part = "contentDetails", max_results = 50, page_token = NULL, hl = "en-US", ... )
list_channel_resources( filter = NULL, part = "contentDetails", max_results = 50, page_token = NULL, hl = "en-US", ... )
filter |
string; Required.
named vector of length 1
potential names of the entry in the vector:
|
part |
a comma separated list of channel resource properties that
response will include string. Required.
One of the following: |
max_results |
Maximum number of items that should be returned. Integer. Optional. Can be between 0 and 50. Default is 50. |
page_token |
specific page in the result set that should be returned, optional |
hl |
Language used for text values. Optional. Default is |
... |
Additional arguments passed to |
list
https://developers.google.com/youtube/v3/docs/channels/list
## Not run: # Set API token via yt_oauth() first list_channel_resources(filter = c(channel_id = "UCT5Cx1l4IS3wHkJXNyuj4TA")) list_channel_resources(filter = c(username = "latenight"), part = "id, contentDetails") list_channel_resources(filter = c(username = "latenight"), part = "id, contentDetails", max_results = 10) ## End(Not run)
## Not run: # Set API token via yt_oauth() first list_channel_resources(filter = c(channel_id = "UCT5Cx1l4IS3wHkJXNyuj4TA")) list_channel_resources(filter = c(username = "latenight"), part = "id, contentDetails") list_channel_resources(filter = c(username = "latenight"), part = "id, contentDetails", max_results = 10) ## End(Not run)
Returns list of channel sections that channel id belongs to.
list_channel_sections(filter = NULL, part = "snippet", hl = NULL, ...)
list_channel_sections(filter = NULL, part = "snippet", hl = NULL, ...)
filter |
string; Required.
named vector of length 1
potential names of the entry in the vector:
|
part |
specify which part do you want. It can only be one of the
following: |
hl |
language that will be used for text values, optional, default
is en-US. See also |
... |
Additional arguments passed to |
captions for the video from one of the first track
https://developers.google.com/youtube/v3/docs/activities/list
## Not run: # Set API token via yt_oauth() first list_channel_sections(c(channel_id = "UCRw8bIz2wMLmfgAgWm903cA")) ## End(Not run)
## Not run: # Set API token via yt_oauth() first list_channel_sections(c(channel_id = "UCRw8bIz2wMLmfgAgWm903cA")) ## End(Not run)
Iterate through the max_results
number of playlists in channel and get
the videos for each of the playlists.
list_channel_videos( channel_id = NULL, max_results = 50, page_token = NULL, hl = "en-US", ... )
list_channel_videos( channel_id = NULL, max_results = 50, page_token = NULL, hl = "en-US", ... )
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 is |
... |
Additional arguments passed to |
list of data.frame
with each list corresponding to a different
playlist
https://developers.google.com/youtube/v3/docs/channels/list
## Not run: # Set API token via yt_oauth() first list_channel_videos(channel_id = "UCXOKEdfOFxsHO_-Su3K8SHg") list_channel_videos(channel_id = "UCXOKEdfOFxsHO_-Su3K8SHg", max_results = 10) ## End(Not run)
## Not run: # Set API token via yt_oauth() first list_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
list_guidecats(filter = NULL, hl = NULL, ...)
list_guidecats(filter = NULL, hl = NULL, ...)
filter |
string; Required.
named vector of length 1
potential names of the entry in the vector:
|
hl |
Language used for text values. Optional. Default is |
... |
Additional arguments passed to |
data.frame with 5 columns: region_code, channelId, title,
etag, id
https://developers.google.com/youtube/v3/docs/guideCategories/list
## Not run: # Set API token via yt_oauth() first list_guidecats(c(region_code = "JP")) ## End(Not run)
## Not run: # Set API token via yt_oauth() first list_guidecats(c(region_code = "JP")) ## End(Not run)
List Languages That YouTube Currently Supports
list_langs(hl = NULL, ...)
list_langs(hl = NULL, ...)
hl |
Language used for text values. Optional. Default is |
... |
Additional arguments passed to |
data.frame with 3 columns: hl
(two letter abbreviation),
name
(of the language), etag
https://developers.google.com/youtube/v3/docs/i18nLanguages/list
## Not run: # Set API token via yt_oauth() first list_langs() ## End(Not run)
## Not run: # Set API token via yt_oauth() first list_langs() ## End(Not run)
List My videos
list_my_videos(...)
list_my_videos(...)
... |
additional arguments to pass to |
data.frame
with each list corresponding to a different
playlist
## Not run: list_my_videos() ## End(Not run)
## Not run: list_my_videos() ## End(Not run)
List Content Regions That YouTube Currently Supports
list_regions(hl = NULL, ...)
list_regions(hl = NULL, ...)
hl |
Language used for text values. Optional. Default is |
... |
Additional arguments passed to |
data.frame with 3 columns:
gl
(two letter abbreviation), name
(of the region), etag
https://developers.google.com/youtube/v3/docs/i18nRegions/list
## Not run: # Set API token via yt_oauth() first list_regions() ## End(Not run)
## Not run: # Set API token via yt_oauth() first list_regions() ## End(Not run)
List of Categories That Can be Associated with Videos
list_videocats(filter = NULL, ...)
list_videocats(filter = NULL, ...)
filter |
string; Required.
named vector of length 1
potential names of the entry in the vector:
|
... |
Additional arguments passed to |
data.frame with 6 columns: region_code, channelId, title, assignable, etag, id
https://developers.google.com/youtube/v3/docs/videoCategories/list
## Not run: # Set API token via yt_oauth() first list_videocats(c(region_code = "JP")) list_videocats() # Will throw an error asking for a valid filter with valid region_code ## End(Not run)
## Not run: # Set API token via yt_oauth() first list_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
list_videos( part = "contentDetails", max_results = 50, page_token = NULL, hl = NULL, region_code = NULL, video_category_id = NULL, ... )
list_videos( part = "contentDetails", max_results = 50, page_token = NULL, hl = NULL, region_code = NULL, video_category_id = NULL, ... )
part |
Required. Comma separated string including one or more of the
following: |
max_results |
Maximum number of items that should be returned. Integer. Optional. Can be between 0 and 50. Default is 50. |
page_token |
specific page in the result set that should be returned, optional |
hl |
Language used for text values. Optional. Default is |
region_code |
Character. Required. Has to be a ISO 3166-1 alpha-2 code (see https://www.iso.org/obp/ui/#search). |
video_category_id |
the video category for which the chart should be
retrieved. See also |
... |
Additional arguments passed to |
data.frame with 5 columns: channelId, title, assignable, etag, id
https://developers.google.com/youtube/v3/docs/search/list
## Not run: # Set API token via yt_oauth() first list_videos() ## End(Not run)
## Not run: # Set API token via yt_oauth() first list_videos() ## End(Not run)
Read SBV file
read_sbv(file)
read_sbv(file)
file |
The file name of the |
A data.frame
with start/stop times and the text
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) } }
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) } }
tuber provides access to the YouTube API V3 via RESTful calls.
Maintainer: Gaurav Sood [email protected]
Other contributors:
Kate Lyons [email protected] [contributor]
John Muschelli [email protected] [contributor]
Useful links:
Request Response Verification
tuber_check(req)
tuber_check(req)
req |
request |
in case of failure, a message
GET
tuber_GET(path, query, auth = "token", ...)
tuber_GET(path, query, auth = "token", ...)
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 to |
list
POST encoded in json
tuber_POST_json(path, query, body = "", ...)
tuber_POST_json(path, query, body = "", ...)
path |
path to specific API request URL |
query |
query list |
body |
passing image through body |
... |
Additional arguments passed to |
list
This function updates the metadata of an existing YouTube video using the YouTube Data API.
update_video_metadata( video_id, title, category_id, description, privacy_status, made_for_kids )
update_video_metadata( video_id, title, category_id, description, privacy_status, made_for_kids )
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. |
A list containing the server response after the update attempt.
## 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)
## 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 to Youtube
upload_video( file, snippet = NULL, status = list(privacyStatus = "public"), query = NULL, open_url = FALSE, ... )
upload_video( file, snippet = NULL, status = list(privacyStatus = "public"), query = NULL, open_url = FALSE, ... )
file |
Filename of the video locally |
snippet |
Additional fields for the video, including 'description' and 'title'. See https://developers.google.com/youtube/v3/docs/videos#resource for other fields. Coerced to a JSON object |
status |
Additional fields to be put into the |
query |
Fields for 'query' in 'POST' |
open_url |
Should the video be opened using |
... |
Additional arguments to send to |
A list of the response object from the POST
, content,
and the URL of the uploaded
The information for 'status' and 'snippet' are at https://developers.google.com/youtube/v3/docs/videos#resource but the subset of these fields to pass in are located at: https://developers.google.com/youtube/v3/docs/videos/insert The 'part“ parameter serves two purposes in this operation. It identifies the properties that the write operation will set, this will be automatically detected by the names of 'body'. See https://developers.google.com/youtube/v3/docs/videos/insert#usage
snippet = list( title = "Test Video", description = "This is just a random test.", tags = c("r language", "r programming", "data analysis") ) status = list(privacyStatus = "private")
snippet = list( title = "Test Video", description = "This is just a random test.", tags = c("r language", "r programming", "data analysis") ) status = list(privacyStatus = "private")
These functions manage your YouTube API key and package key in .Renviron
.
yt_get_key(decrypt = FALSE) yt_set_key(key, type)
yt_get_key(decrypt = FALSE) yt_set_key(key, type)
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. |
'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'.
## Not run: ## for interactive use yt_get_key() list_channel_videos( channel_id = "UCDgj5-mFohWZ5irWSFMFcng", max_results = 3, part = "snippet", auth = "key" ) ## for continuous integration and testing yt_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)
## Not run: ## for interactive use yt_get_key() list_channel_videos( channel_id = "UCDgj5-mFohWZ5irWSFMFcng", max_results = 3, part = "snippet", auth = "key" ) ## for continuous integration and testing yt_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)
The function looks for .httr-oauth
in the working directory. If it
doesn't find it, it expects an application ID and a secret.
If you want to remove the existing .httr-oauth
, set remove_old_oauth
to TRUE. By default, it is set to FALSE.
The function launches a browser to allow you to authorize the application
yt_oauth( app_id = NULL, app_secret = NULL, scope = "ssl", token = ".httr-oauth", ... )
yt_oauth( app_id = NULL, app_secret = NULL, scope = "ssl", token = ".httr-oauth", ... )
app_id |
client id; required; no default |
app_secret |
client secret; required; no default |
scope |
Character. |
token |
path to file containing the token. If a path is given,
the function will first try to read from it.
Default is |
... |
Additional arguments passed to |
sets the google_token option and also saves .httr_oauth
in the working directory (find out the working directory via getwd()
)
https://developers.google.com/youtube/v3/docs/
https://developers.google.com/youtube/v3/guides/auth/client-side-web-apps for different scopes
## Not run: yt_oauth(paste0("998136489867-5t3tq1g7hbovoj46dreqd6k5kd35ctjn", ".apps.googleusercontent.com"), "MbOSt6cQhhFkwETXKur-L9rN") ## End(Not run)
## Not run: yt_oauth(paste0("998136489867-5t3tq1g7hbovoj46dreqd6k5kd35ctjn", ".apps.googleusercontent.com"), "MbOSt6cQhhFkwETXKur-L9rN") ## End(Not run)
Search for videos, channels and playlists. (By default, the function searches for videos.)
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, ... )
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, ... )
term |
Character. Search term; required; no default For 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 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 q parameter value 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.
Integer. Optional. Can be between 0 and 50. Default is 50.
Search results are constrained to a maximum of 500 videos if type is
video and we have a value of |
channel_id |
Character. Only return search results from this channel; Optional. |
channel_type |
Character. Optional. Takes one of two values:
|
type |
Character. Optional. Takes one of three values:
|
event_type |
Character. Optional. Takes one of three values:
|
location |
Character. Optional. Latitude and Longitude within parentheses, 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: |
video_caption |
Character. Optional. Takes one of three values:
|
video_license |
Character. Optional.
Takes one of three values: |
video_syndicated |
Character. Optional. Takes one of two values:
|
region_code |
Character. Required. Has to be a ISO 3166-1 alpha-2 code (see https://www.iso.org/obp/ui/#search). |
relevance_language |
Character. Optional. The relevance_language argument 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. |
video_type |
Character. Optional. Takes one of three values:
|
simplify |
Boolean. Return a data.frame if |
get_all |
get all results, iterating through all the results
pages. Default is |
page_token |
specific page in the result set that should be returned, optional |
... |
Additional arguments passed to |
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, liveBroadcastContent
https://developers.google.com/youtube/v3/docs/search/list
## Not run: # Set API token via yt_oauth() first yt_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") ## End(Not run)
## Not run: # Set API token via yt_oauth() first yt_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") ## End(Not run)
Check if authentication token is in options
yt_token() yt_authorized() yt_check_token()
yt_token() yt_authorized() yt_check_token()
A Token2.0 class
Search YouTube by Topic It uses the Freebase list of topics
yt_topic_search(topic = NULL, ...)
yt_topic_search(topic = NULL, ...)
topic |
topic being searched for; required; no default |
... |
Additional arguments passed to |
a list
## Not run: # Set API token via yt_oauth() first yt_topic_search(topic = "Barack Obama") ## End(Not run)
## Not run: # Set API token via yt_oauth() first yt_topic_search(topic = "Barack Obama") ## End(Not run)