Youtube video comment retrieval - youtube-api

For getting video comments I use this example:
https://www.googleapis.com/youtube/v3/commentThreads?part=snippet,replies&' .
'videoId=' . $video->id . '&maxResults=100&' .
'key=' . $ytApp->apiKey;
My question is: are there other filters except maxResults so I can get only the last comments of a video filter it by a date, or another filter that I can get only last comments not all comments or 100 comments per page?

order string
The order parameter specifies the order in which the API response should list comment threads. Valid values are:
time - Comment threads are ordered by time. This is the default behavior.
relevance - Comment threads are ordered by relevance.

Related

Difference between comments shown in YouTube and actual comment list

I am noticing a difference between the number of comments shown in YouTube for a specified Video and the number of comments that actually appear after the comments are loaded.
Example: https://www.youtube.com/watch?v=aD1VmjGOb_g
This Video shows 21 comments just below the Video description, but if you count the comments it only has 13! The total shown won't get to 21 even if you sum the amount of replies!
You'll see all 21 comments if you choose the "Newest first" sorting option:
When using YouTube data API you should use order: 'time' when calling the commentThreads

Youtube API : CommentThreads.list how to get last comments?

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,

Imprecise number of comments and replies in Youtube Data Api

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.

Youtube API V3: Total comments count [Videos]

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.

Retrieve most retweeted tweets for a given hashtag

I'd like to retrieve the tweets for given a hashtag and sort them from the most retweeted to the less retweeted.
The closest thing I've found is using the search call and use the type tag:
E.g.: http://search.twitter.com/search.json?q=TheHashTagHere&result_type=popular
However, I'm not sure on how "popular" option works.
For instance, if it finds 100 tweets with that hashtag I believe it should show the X most retweeted tweets, and if none of those tweets have been retweeted then it should show X of them randomly (or sorted in some other way like the most recent).
Unfortunately, if follows some kind of unknown rule to identify what's popular and what not and even hashtags with thousands of tweets might return only one or two results.
I hope I made myself clear. Thanks in advance :)
PS: I'll use PHP but I think that shouldn't affect the question?
Results will sometimes contain a
result_type field into the metadata
with a value of either "recent" or
"popular". Popular results are derived
by an algorithm that Twitter computes,
and up to 3 will appear in the default
mixed mode that the Search API
operates under. Popular results
include another node in the metadata
called recent_retweets. This field
indicates how many retweets the Tweet
has had.
Source (Emphasis are mine)
Just call with result_type=popular and check the recent_retweets node to see how popular it is. result_type=popular will become the default in an upcome release so beware if you omit this parameter.
Results with popular tweets aren't ordered chronologically. *
If you would like to always have results to show, use result_type=mixed: they will have the result_type in the "metadata" section with a value of "recent", and popular results will have "popular". A small reference about result_types:
mixed: Include both popular and real time results in the response.
recent: return only the most recent results in the response
popular: return only the most popular results in the response.
If a search query has any popular results, those will be returned at the top, even if they are older than the other results. *
*[Twitter API Announcements]
This isn't a programmatic method but rather works in the browser with a chrome extension (HackyBird) :
Install the extension
Search for a phrase e.g. #Social (twitter.com/search?q=%23Social)
Click the extension to sort it (you can adjust the ratio of retweets/likes used for sorting in extension options).
P.S. It'll also sort your or any other user's timeline.

Resources