I want to get all video comments of a channel. At the moment I'm proceeding like this:
1.) Getting all video ids of a channel (1 quota)
2.) Sending new request with "part: statistics" and getting the total comment count to a youtube video (2 Quota)
It's polling in 30 seconds intervall and I wanted to reduce the quota. Therefore is there a possibility to query whether there are any new comments for a channel videos (Total amount of comments for a channel including channel comments would be fine too)? Like saving the old value of total amount of comments and comparing it with the new amount of the query?
No, from my experience.
I would not use video's commentCount.
- you can pull over 260 comments from a video whose comment count is only 243. https://www.youtube.com/watch?v=87xYGDR_eME
I would not try optimizing by stopping at recent comments.
- this would work for threads, but each thread has replies. So you have to check each thread anyways just to see if they have new replies.
- note: it's dangerous to use commentThreads' reply mode, as it may only return a subset of replies. Instead get a comment list using parentId.
Perhaps, if you sort by time and save the id of comments you've collected, you can use cheap requests like id to figure out which comments are new and pull them with snippet.
- stop when you get to an id you've already gathered.
This may not be simple though because publishedAt or updatedAt leave two questions:
will an old comment be bumped to the top if it's edited? If so, you can't stop once you recognize a comment id, because it might have jumped ahead of new comments (unless the change the id when it's edited).
will the old comment not be bumped if edited? If this is the case, you need to check snippet for each comment as the textDisplay may be different. In this case I can see no optimizations.
Related
By reading the docs : https://developers.google.com/youtube/v3/docs/commentThreads/list when listing the commenthreads related to a channel, by default, I get the last 20 comment threads ordered by "time". IMHO this is not accurate : is it the time of creation or update or ... ?
While using the API, I found that it was the last 20 created threads. Am I right ?
Considering that, I would like to get the last 20 updated threads. Is it possible ? (to get the last comments on this channel which are not necessarily part of the last comment threads)
Thanks in advance,
I'm trying to get a number of comments and replies for a video from Youtube Data Api v3. It looks like sometimes the statistics.commentCount property of video resource and the snippet.totalReplyCount property of comment thread resource contain imprecise numbers. It's interesting that for example statistics.viewCount property, which contains much higher numbers, seems to be precise. Is there any caching involved or something like this?
Thank you.
The reason is from this SO post.
Youtube API v3 says that "commentCount is the number of comment for
the channel". This means that commentCount is not the total number of
comment for all of channel's videos but for comment for channel. As we
know, we can comment for a specific channel in the discussion part of
the channel like here.
You can also check this documentation for the further details about Channels.
I've stumbled upon a similar case. I was able to come to a conclusion that - statistics.commentCount returned on the videoResource gives the total count of comments + replies to that comment together.
I've tried a couple of videos and found this to be the case. Let me know if this helps.
I'm using YouTube Data v3 in order to get statistics of a certain channel. To be precise I'm following this documentation.
I can get all data properly except for commentCount property. For example GET request:
https://www.googleapis.com/youtube/v3/channels?part=statistics&forUsername=Kurzgesagt&key={YOUR_API_KEY}
Which results in commentCount = 23
This is obviously not correct as this channel has much more than that.
Same thing happens to almost all other channels (not all of them). Is there any particular reason for this behaviour? Why does it return this number?
I've been monitoring this value for more than a week and it hasn't changed once in that time period.
Edit: I know that commentCount property should return number of comments on that channel (not sum of all videos), but for some reason this doesn't really match. You can compare the commentCount I mentioned with real comments for Kurzgesagt channel on YT directly.
CommentCount returns the number of comments in the channel, not the sum of all comments in the channel's videos, this has already been answered here Youtube Data Api has commentCount field and is this the number of comments on channel?
There seems to be more than one channels for that user, so is the link that you provided actually supposed to bring back the expected feedback ? There is no specified channel id on your URL.
Try the following:
GET https://www.googleapis.com/youtube/v3/commentThreads?part=snippet%2Creplies&allThreadsRelatedToChannelId=ChannelId&key={YOUR_API_KEY}
Is there anyway to find the last 10 JIRAs I have worked on - irrespective of time period? By worked on, I mean any thing I have updated. Thanks.
You could query the activity stream.
For example here are my last (up to) 10 issues on jira.atlassian.com in ATOM format:
https://jira.atlassian.com/activity?provider=jira&maxResults=10&streams=user+IS+david#davidsimpson.me
If you want authenticated, try appending parameters &os_username=a.n.other&os_password=abc123 (or similar) to the URL.
Incidentally, an activity stream similar to this is present in your JIRA profile, e.g. https://jira.atlassian.com/secure/ViewProfile.jspa?name=david%40davidsimpson.me
I have made an internal movie site in .Net.
I play the movie trailers using jw player. Now I want to know how to calculate the number of views for a video?
Is it possible through code?
PLease help.
NBL I dont have any database. I add the videos through an xml and the code reads the xml.
A simple approach is to tally the number of pageloads for the page that contains the video, rather than the number of times the video itself is played. First, create a table in your database that contains these fields:
DateTime date // date of pageloads -- we'll get to this in a minute
int videoID // Unique Identifier for the video loaded
int count // Number of pageloads
When I tally pageloads, I do them by day so I can compile statistics over time. Of course, you can use a different granularity depending on your particular needs.
Additionally, I don't particularly like writing to the database with each pageload, so I have a class I've written that caches the hits, then writes them after every hundred hits or so.
In this class, I also retain each user's IP address. This allows me to ferret out duplicate pageloads. A subsequent task, which I'm working through in my own hitcounter, is to triage humans, legitimate spiders and unwelcome bots.
Not sure exactly what you need.. but you can handle the play command (button or loading... however your videos are played), and attach that to a counter that you save in your database.
We would need a lot more (code set, video codec and such) before giving more.
You can also create a separate table with these columns :
VideoId
IP adress
And add a row each times an user watch a video...
Then you will calculate unique watch and not duplicate
(Instead of ip adress you can store userId if your users are registered)
The database would have a table for videos, including a Hits column.
When you request the page from the server, the server would execute a stored procedure that adds +1 to the 'Hits' column.
If you are embedding videos on your page, it's worth being aware of YouTube's policy on the question of autoplaying those videos, in relation to the official viewcount. If in the player you set autoplay = true, or equivalent, then the YouTube view count doesn't increase. This is to counter spammy viewcount auto-augmentation pages. The user has to click on the play button, and watch all, or at least most, of the video to count as a view.