https://github.com/kevin-m-kent/youtubeR
https://github.com/kevin-m-kent/youtubeR
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/kevin-m-kent/youtubeR
- Owner: kevin-m-kent
- License: other
- Created: 2023-01-15T15:46:35.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-18T13:37:50.000Z (5 months ago)
- Last Synced: 2024-11-18T15:14:38.021Z (5 months ago)
- Language: R
- Homepage: https://kevin-m-kent.github.io/youtubeR/
- Size: 27.2 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 16
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - kevin-m-kent/youtubeR - (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
eval = FALSE
)
```# youtubeR
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[](https://CRAN.R-project.org/package=youtubeR)
[](https://app.codecov.io/gh/kevin-m-kent/youtubeR?branch=main)
[](https://github.com/kevin-m-kent/youtubeR/actions/workflows/R-CMD-check.yaml)A package for interacting with the Youtube Data API.
This package is being developed first to aid in the processing of [R4DS Online Learning Community](https://r4ds.io) book club videos.
As such, functionality will be focused where it is needed for that task.
Long-term, we hope to implement the entire YouTube API.## Installation
::: {.pkgdown-release}
Install the released version of youtubeR from [CRAN](https://cran.r-project.org/):``` r
# Not yet!
install.packages("youtubeR")
```
:::::: {.pkgdown-devel}
Install the development version of youtubeR from [GitHub](https://github.com/):``` r
# install.packages("pak")
pak::pak("kevin-m-kent/youtubeR")
```
:::## Setting up
### Step 1: Create an OAuth 2.0 client.
We'll add details here about the settings to apply in your client.
You'll need to enable the YouTube Data API v3.```{r browse}
library(youtubeR)browse_gc_credentials()
# Copy the client id and client secret.
```### Step 2: Set up environment variables
```{r env}
# Use the values copied above.
Sys.setenv(YOUTUBE_CLIENT_ID = "12345-ab12c.apps.googleusercontent.com")
Sys.setenv(YOUTUBE_CLIENT_SECRET = "ABCD-eFg_H")
# Ideally, set these in your .Renviron file.
```### Step 3: Use the package
You should now be set up to call functions in the package.
The first time you call a function interactively, you will be asked to authorize your client to act on your behalf (in your web browser).## Retrieving Video Status
The goal here is to get the video status (if it is finished processing) for
each video that has been uploaded.The workflow is as follows:
- Get the playlist ids
- For each playlist, get the video ids
- For each video, get the status```{r video-status}
my_playlist_id <- get_upload_playlist_id()
video_ids <- get_playlist_video_ids(my_playlist_id)
video_details <- get_video_processing_details(video_ids)
```## Uploading Videos
Following a similar workflow, we can also upload videos to youtube.
Assuming you already have created the client as above, you will need a snippet and a video path.
The snippet defines the title, description, and other metadata for the video.
The video path is the path to the video file on your local machine.```{r upload}
snippet <- yt_schema_video_snippet(
title = "video test",
description = "description of this test video",
tags = c("example tag", "another tag")
)
status <- yt_schema_video_status(
privacy_status = "private",
self_declared_made_for_kids = FALSE
)
video_path <- "path/to/video.mp4"yt_videos_insert(
video_path = video_path,
snippet = snippet,
status = status
)
```