gojiplus / tubern

R Client for the Youtube Analytics and Reporting API
https://soodoku.github.io/tubern/
Other
12 stars 2 forks source link

Filtering Video Stats #1

Open rkverma1974 opened 6 years ago

rkverma1974 commented 6 years ago

Hi - can you please confirm that filters can be used to narrow metrics to specific video IDs (e.g. "video==xxxx"). See below - if I run this code, the variable (tubern_stats) returns the same values as the channel. It doesn't filter on a specific video or set of videos. Can you confirm the syntax? Or should I try something different? Thanks in advance

############################R CODE######################

require(tubern) httr::set_config( config( ssl_verifypeer = 0L ) ) # = Fixes some certificate problems on linux = #

Authentication

yt_oauth("XXX", "XXX",token = "")

GET STATS VIA TUBERN

tubern_stats <- (get_report(ids = "channel==MINE", metrics = "views,likes,comments,shares", filters = "video==WfFAup0qXrU,4qtXtBc6Akc;country==US", start_date = "2010-04-01", end_date ="2017-01-01"))

dfx <- data.frame(NULL)

BEGIN DATA FRAME

metrics <- sapply(seq_along(tubern_stats$columnHeaders), function(i){ unlist(tubern_stats$columnHeaders[[i]]$name) })

data <- as.vector(sapply(seq_along(tubern_stats$rows), function(i){ unlist(tubern_stats$rows[[i]]) }))

youtube.df <- data.frame(metrics, data) youtube.df$video_id <- "WfFAup0qXrU"

END DATA #FRAME

soodoku commented 6 years ago

what you are doing seems to be fine. they have some sample python code that i cross-checked with so things seem to pan out: https://developers.google.com/youtube/reporting/v1/code_samples/python#retrieve_top_10_videos_by_viewcount

as to why it isn't working, not clear to me.

I am assuming you the channel on which the video is posted: https://www.youtube.com/watch?v=WfFAup0qXrU