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,
Related
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've got rooms that hold sub-rooms that users can post to. I want to only show user-posts that are less than 24 hours old to my users.
For example :
Cats
kittens
users : 10
posts :
ksjdflkjaslkdjf
userUID : 123
postCaption : "I like kittens"
postTimestamp : 203940340930
So here, if a user went into the Cats room, into the subroom of kittens, and wanted to see posts that have been posted about kittens, I'd only want to return back the posts whose timestamp was less than 24 hours old.
Im not sure about is the most effective way to structure the database. The problem with the way it's set up now is that if there have been 10 million kitten posts, every time the user wants to load up posts firebase would have to go through each post and check the timestamp to see if it's valid or not.
An alternative option might be :
Rooms:
Cats
kittens
users : 10
posts :
post1UID : 209384938942024234 //The value here would be the timestamp
post2UID : 309238942024234
Posts :
209384938942024234
userUID: 123
postCaption : "....."
postTimestamp : 209384938942024234
and I'd query for posts with only a valid timestamp and use the post UID to go grab the posts.
Any advice on the best way to do this before I get started?
Thanks in advance.
You could simply query the list of posts to only request the posts from the last 24 hours. While you can't enforce this with security rules, you can at least make your code do the right thing.
But it's quite wasteful: after your app has been live for more than 24 hours, you're querying data that you already know will never be matched.
To prevent this: in NoSQL databases such as Firebase, you often model your data for the specific use-cases of your app. So if you want your users to see a list of post from the last 24 hours, you should model your database to have a list of the posts from the last 24 hours.
You can do this in two ways:
Only keep the most recent 24 hours of posts for each room. So just delete the data that is older than 24 hours, e.g. when a new post is added, or with a cron-triggered Cloud Function. Alternatively you could move the older post to a separate node, or to a system like BigQuery, which is better suited to handling such historical data.
Keep your current structure, but add a secondary index: a list of post IDs for the last day's worth of posts. A simple way to do this is to keep the ID of each post as the key, and its timestamp as the value:
roomId1:
post1UID: timestamp
post2UID: timestamp
The differene with your approach (at least as far as I saw in my quick scan) is that the index would only have post of the most recent 24 hours, so you wouldn't have to query at all to read the posts (only to clean them up).
When I try and send the following request:
GET https://www.googleapis.com/youtube/v3/liveChat/messages?liveChatId={..}&part=snippet&maxResults=250key={...}
I only get a max of 75 results returned even though there are more than 75 comments in my livestream. These 75 comments returned are also the 75 newest comments. Setting the nextPageToken with the value in the response above returns an empty set of comments. It's almost like I need a way to view previous pages. Setting maxResults, as I have in the url above does nothing as well. When I add a new comment to the livestream, the first entry of the 75 disappears and the new comment shows up at the bottom of the list.
I am perplexed over why I cannot receive more than 75 comments and why the number 75 as this is not mentioned anywhere in the documentation. Do you guys have any idea whats going on here? I can provide more information as needed.
Having testing the liveChatMessages google youtube-api with the most active rooms I could find and reviewing the documentation I have concluded that when you query the the liveChatMessages api you get the 75 most recent messages ordered from oldest to newest, and the nextTokenId given if added to the next query will return any more recent messages which have been gathered by Google's servers since your first query. I am not sure how to get older messages, it does not seem possible.
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.
List item
each day I want to find the "most popular" post on the website and feature it on the home page.
For each post, I'm keeping track of how many times it has been "liked", "disliked", "favorited" and "viewed".
I would like to run a daily cron job where I do something like:
post = Post.order("popularity_score DESC").first
post.feature!
My question is, how should I compute the value of popularity_score?
Is there a formula that takes into consideration "statistical significance"? Meaning, a post which has 1 "like" vote and nothing else, although having a 100% approval rating, it shouldn't mean much because only one person voted on it.
In general I have these loose ideas off the top of my head:
a post with 10 likes and no other votes is more popular than a
post with 1 like vote.
a post post with more "dislikes" than
"likes" should have a lower score than a post with more "likes" than
"dislikes"
a post with 20 views and no other votes is more
popular than a post with 3 views.
I've punched in some arbitrary formulas to try to satisfy this goal, but there are exactly that, arbitrary and I don't really know if there is a better way to go about this?
Suggestions?
Maybe you could just take the SO approach? it seems rather decent.
+ gives 10 points
- substracts 2 points
view add a low number, like 0.01 point
comment add 2 points
One suggestion is to not reset your counter each day (that leaves the "most popular" open to a single vote).
Instead, weight the votes by their age -- newer votes count more than older votes. This will give you gradual and meaningful rerankings over time.