Skip to contents

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 which details 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 to tuber_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

Examples

if (FALSE) { # \dontrun{

# 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)

# Extract specific fields (common use case):
details <- get_video_details(video_id = "yJXTXN4xrI8")
# Get video title:
video_title <- details$items[[1]]$snippet$title
# Get video description:  
video_desc <- details$items[[1]]$snippet$description
# Get channel ID:
channel_id <- details$items[[1]]$snippet$channelId

# For Shiny applications - extract title:
# output$videotitle <- renderText({ 
#   details <- get_video_details(input$video_id)
#   if (length(details$items) > 0) {
#     details$items[[1]]$snippet$title
#   } else {
#     "Video not found"
#   }
# })
} # }