tuber icon indicating copy to clipboard operation
tuber copied to clipboard

error in list_channel_videos function

Open sujinz opened this issue 5 years ago • 5 comments

I tried to get video stats using this code, and it worked until May 3rd. But, it does not work for now.

for(i in 1:length(chID)) ##chID=lists of channel IDs { chName <- sub$channelName[i] vl <- list_channel_videos(as.character(chID[i]), max_results = 50000) # {tuber}

tmp <- cbind(chName, vl) videoList.for <- rbind(videoList.for, tmp) # 26 channels

print(paste(i, "channel")) } videoList <- videoList.for names(videoList)

In the past, it appeared like this, [1] "chName" ".id" "kind" "etag"
[5] "id" "contentDetails.videoId" "kst"

But for now, "chName" ".id" "X[[i]]" in ".id " I can only see pageInfo.totalResults and pageInfo.resultsPerPage,

Is there any alternative codes to extract video ids and stats?

sujinz avatar Jun 03 '20 03:06 sujinz

I tried the way you suggested, but there's a limitation. yt_search's max results only takes the value between 0 to 50, but I want to bring all video stats in individual channels.

sujinz avatar Jun 04 '20 11:06 sujinz

I am sorry for having broken the discussion's history. When I realized shortly after posting that my and your, @sujinz, problem actually belong to different functions (get_all_channel_video_stats() versus list_channel_videos(), I deleted my reply and opened a separate issue #89 instead. I should have just edited my reply.

To at least add the missing core information: I had suggested to you, @sujinz, to consider yt_search(channel_id, type = "video") and to feed get_stats() as a workaround, but did so while thinking our issues belong to the same function. The purpose of list_channel_videos() is different, though, and my workaround does not apply.

Have you tried yt_search(channel_id, type = "playlist")? Then, the results limit should apply to 50 playlists instead of 50 videos, which should return more information about more videos. But I see that list_channel_videos(max_results) can be set to over 50 to include all videos from a playlist. I am not sure in how far my suggestion will work.

MaximilianKrauss avatar Jun 04 '20 15:06 MaximilianKrauss

thanks for your sincere responses! with yt_search function, I think it's not easy to find exact info that I want, but I will try it :) @Sasyriston

sujinz avatar Jun 04 '20 15:06 sujinz

@sujinz It seems the code changes of pull request #84 indirectly fixes your issue, because list_channel_videos() calls get_playlist_items(simplify = TRUE) internally. In the current release version of tuber being 0.9.8, its simplifying algorithm is outdated and produces the incomplete output you described. As a result, list_channel_videos() does not get the information it expects and returns the error when it tries to use the missing information. The function I used in my issue #89 likewise relies on the currently incomplete output of get_playlist_items(simplify = TRUE), which is why I thought at first that you and me have the same problem. :) The next release version will contain this fix, but you can install the GitHub version via devtools::install_github() (see Installation section on the repository's main page) right away for this issue to be resolved.

MaximilianKrauss avatar Jun 06 '20 02:06 MaximilianKrauss

Is there a fix yet to the list_channel_videos() function? As per the documentation, specifying a value >50 should return all videos of the channel but it still throws the Error in get_playlist_items(filter = c(playlist_id = playlist_id), max_results = max_results, : max_results must be a value between 0 and 50.

durraniu avatar Aug 11 '23 18:08 durraniu