From 774a6f28a1695d9ea2c6931e19ace8e99c0f32d3 Mon Sep 17 00:00:00 2001 From: Daniel Thiele Date: Wed, 10 Apr 2024 21:50:38 +0200 Subject: [PATCH] fix get_playlist_items (#133) --- R/get_playlist_items.R | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/R/get_playlist_items.R b/R/get_playlist_items.R index fa8ceb3..be56c7e 100644 --- a/R/get_playlist_items.R +++ b/R/get_playlist_items.R @@ -61,17 +61,21 @@ get_playlist_items <- function(filter = NULL, part = "contentDetails", pageToken = page_token, videoId = video_id) querylist <- c(querylist, filter) - res <- tuber_GET("playlistItems", querylist, ...) + res <- tuber_GET(path = "playlistItems", + query = querylist, + ...) if (max_results > 50) { page_token <- res$nextPageToken while (is.character(page_token)) { - a_res <- tuber_GET("playlistItems", list( - part = part, - playlistId = unname(filter["playlistId"]), - maxResults = 50, - pageToken = page_token - )) + a_res <- tuber_GET(path = "playlistItems", + query = list( + part = part, + playlistId = unname(filter[["playlistId"]]), ## <--- double brackets + maxResults = 50, + pageToken = page_token + ), + ...) ## <--- pass arguments to tuber_GET res <- c(res, a_res) page_token <- a_res$nextPageToken } @@ -82,7 +86,7 @@ get_playlist_items <- function(filter = NULL, part = "contentDetails", allResultsList <- lapply(allResultsList, unlist) res <- do.call( - rbind.fill, + plyr::rbind.fill, lapply( allResultsList, function(x) as.data.frame(t(x), stringsAsFactors = FALSE) @@ -90,6 +94,6 @@ get_playlist_items <- function(filter = NULL, part = "contentDetails", ) } - res + return(res) }