Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination error in get_playlist_items #130

Closed
thieled opened this issue Apr 2, 2024 · 0 comments · Fixed by #131
Closed

Pagination error in get_playlist_items #130

thieled opened this issue Apr 2, 2024 · 0 comments · Fixed by #131

Comments

@thieled
Copy link
Contributor

thieled commented Apr 2, 2024

Problem

When max_results is set > 50 in get_playlist_items, tuber returns an error, even though pagination-handling is implemented in the function.

Repex

Assumes a valid yt_oauth:

channel_res <- list_channel_resources(filter = list(channel_id = "UCRWBzDUKfaNmK_FwtDMgyqg"), part="contentDetails")

# Uploaded playlists:
playlist_id <- channel_res $items[[1]]$contentDetails$relatedPlaylists$uploads

# Get videos on the playlist
vids <- get_playlist_items(filter= list(playlist_id=playlist_id), max_results = 51, simplify = T) 

Error in get_playlist_items(filter = list(playlist_id = playlist_id), :
max_results must be a value between 0 and 50.

Solution

The solution to fix this is to disable the stop error within get_playlist_items

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

### DISABLE THIS ---> 
#  if (max_results < 0 || max_results > 50) {
#    stop("max_results must be a value between 0 and 50.")
#  }

  valid_filters <- c("item_id", "playlist_id")
  if (!(names(filter) %in% valid_filters)) {
    stop("filter can only take one of the following values: item_id, playlist_id.")
  }

# [...]

I'll send a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant