gojiplus / tuber

:sweet_potato: Access YouTube from R
http://gojiplus.github.io/tuber
Other
184 stars 55 forks source link

Why get_playlist doesn't allow me to set parts? #32

Closed event15 closed 7 years ago

event15 commented 7 years ago

Hey, I try to get playlists from YouTube channel with snippet and contentDetails:

playlists <- get_playlists(filter = c(channel_id = "channel_id"), part = "snippet,contentDetails")

or

playlists <- get_playlists(filter = c(channel_id = "channel_id"), part = c("snippet","contentDetails"))

But i see the error:

Error in match.arg(part) : 
  'arg' should be one of “contentDetails”, “id”, “localizations”, “player”, “snippet”, “status”

or

Error in match.arg(part) : 'arg' must be of length 1

In youtube API I can do this (from documentation):

# curl URL:
curl -i -G -d "maxResults=25&channelId=UC_x5XG1OV2P6uZZ5FSM9Ttw&part=snippet%2CcontentDetails&key={YOUR_API_KEY}"
              https://www.googleapis.com/youtube/v3/playlists

# HTTP URL:
GET https://www.googleapis.com/youtube/v3/playlists?maxResults=25
                                                   &channelId=UC_x5XG1OV2P6uZZ5FSM9Ttw
                                                   &part=snippet%2CcontentDetails
                                                   &key={YOUR_API_KEY}
event15 commented 7 years ago

https://github.com/soodoku/tuber/blob/9d9d18c3082d3b39296feff5c4af7672e939d568/R/get_playlists.R#L34

This line mayby should be look e.g.:

part = c("contentDetails", "id", "localizations","player", "snippet", "status", "contentDetails,snippet", "snippet,contentDetails"),

In my case, I often use contentDetails with snippet, because I can load all informations from requested playlist (title, ID, publishedAt) and I'm allow to see itemsCount in playlist with 1 request.

soodoku commented 7 years ago

Hey @event15,

seems like a bug. let me investigate and get back soon.

soodoku commented 7 years ago

Apologies for taking so long to respond.

playlists <- get_playlists(filter = c(channel_id = "UCMtFAi84ehTSYSE9XoHefig"), part = "snippet,contentDetails")
playlists[[4]]
$totalResults
[1] 435

$resultsPerPage
[1] 50
event15 commented 7 years ago

Super! Thank You for Your work :)