I'm trying to work with YouTube API V3 to extract the top 10 comments from a specific video. I'm currently using the below line to access the comments for a video. I have successfully grabbed comments from the video in question, but I have been unable to extract the TOP comments like the ones shown under the video on youtube.
https://www.googleapis.com/youtube/v3/commentThreads?key=**YOUTUBEAPIKEY**&textFormat=plainText&part=snippet&videoId=**YOUTUBEVIDEOID**&maxResults=50
I've looked through the documentation at:
https://developers.google.com/youtube/v3/docs/commentThreads/list
But I haven't been able find anything that mentions this. Does anyone know how I could go about doing this?
I think you can do that by using the snippet.viewerRating, if you base the rank of the comment per number of likes as discussed in this SO post. Then you can filter from the most number of like to the least. Placing the top comments at the top.
The rating the viewer has given to this comment. Note that this
property does not currently identify dislike ratings, though
this behavior is subject to change. In the meantime, the property
value is like if the viewer has rated the comment positively.
The value is none in all other cases, including the user having
given the comment a negative rating or not having rated the comment.
Valid values for this property are:
like
none
Here is the sample JSON structure for the comments resource format.
{
"kind": "youtube#comment",
"etag": etag,
"id": string,
"snippet": {
......
"authorChannelId": {
"value": string
},
......
"viewerRating": string,
"likeCount": unsigned integer,
......
}
}
Related
I'd like to find the specific podcast episode titled "#1: The Single White Guy Focus Group." According to the iTunes search API, I believe I should be able to find it with the following:
https://itunes.apple.com/search?term=%231:+The+Single+Straight+Guy+Focus+Group&entity=podcast&attribute=keywordsTerm
But that returns an empty JSON. I also tried
https://itunes.apple.com/search?term=The+Single+Straight+Guy+Focus+Group&entity=podcast
... and ...
https://itunes.apple.com/search?term=The+Single+Straight+Guy+Focus+Group
... but I always get the same result.
{
"resultCount":0,
"results": []
}
I'm baffled. I know the episode is in there - here it is.
https://itunes.apple.com/us/podcast/1-single-straight-guy-focus/id775053292?i=1000375469754&mt=2
(posting full url so deliberately, so you can see that indeed there is a url which does point to that specific episode)
So why can't I find it?
EDIT: Note that I am doing this in an Obj-C iOS app, in case that is relevant.
After a TON of hair-pulling, I've found that there is an undocumented entity (podcastEpisode) that does what we all want.
So, on the off-chance the original poster is still at this after 3 years (or more likely other frustrated folks like myself browsing) - try this (using the original example):
https://itunes.apple.com/search?term=The+Single+Straight+Guy+Focus+Group&entity=podcastEpisode
Unfortunately apple API searches only by the title of the podcast and not by the title of the episode. I'm trying to add a search by episode on my app but to no avail so far
Although the youtube-api, v3, allows you to make a request for videos that come from a particular area (for example, by specifying the location and the radius), it appears that the resulting information about the videos does not contain location information. That is, you can't get the reported lat/long of the video itself.
A query for a specific location would look like this:
https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&key=[key]&location=37,5%2C-120.5&locationRadius=2km&maxResults=5
Here's the description of the information returned.
https://developers.google.com/youtube/v3/docs/search#top_of_page
So, is that correct? Is there no longer any way to find out the lat/long information of a video that is returned in a query?
OK, I figured this out. The location query will only return the various snippets of information about the videos, that is true. However, you can then look at individual videos in more depth to find their locations. For example:
https://www.googleapis.com/youtube/v3/videos?part=recordingDetails&key=[key]&id=HiFnDoUiaqg
will return recording information including:
"recordingDetails": {
"location": {
"latitude": 37.50973,
"longitude": -120.49805,
"altitude": 0.0
},
So it's a 2-step process. You find the list of videos returned by the location query, and then you look at the detailed information for those videos.
There is no specification available for the possible values of the fields "type", "object_type" and "from_type" in the documentation of the Activity API.
I was hoping to retrieve activities for some events like:
Removing a video from a playlist
Adding a video to a playlist after having removed it from the same playlist (no activity in that case)
Adding a playlist
Editing a video (rename/change description or any other edit)
My question is :
Is there any way to retrieve those events with the Activity API? Is there any full specification for the "type" fields?
API types I know are for example :
user.addVideoToPlaylist
user.postVideo
user.startLiveStream
user.addComment
The documentation URL: http://www.dailymotion.com/doc/api/obj-activity.html
You are right by saying that the documentation is lacking on this front. We're going to remedy this situation in the near future. In the meantime, here is the current list of activity types available for you to use.
For users:
user.postVideo
user.addVideoToPlaylist
user.rateVideo
user.bookmarkVideo
user.addComment
user.joinGroup
user.addVideoToGroup
user.subscribeUser
user.likeVideo
user.startLiveStream
user.subscribeChannel
For groups:
group.memberJoin
group.videoAdd
group.noteAdd
For playlists:
playlist.videoAdd
For channels/categories:
channel.featuredVideo
So I am playing around with the YouTube API v3 for a web app I am building. I've got the basics down, but I am searching through documentation trying to find a way to filter a returned video list based on a channelID. However this doesn't seem to be possible. Is there way to write a request similar to this pseudocode below:
https://www.googleapis.com/youtube/v3/videos?part=snippet&
// and a second value that would imply with channelID=UCn8zNIfYAQNdrFRrr8oibKw
This seems like a logical function to have in the API. However, I can't seem to find any name/value pair in the documentation to support this theory.
The closest I can seem to find is the onBehalfOfContentOwner name/value pair for the video.list request (but it requires me to be the uploader of the video?) as outlined here
Anyways if someone can answer definitively if this is possible (if yes a link to docs or example I can use) as I've poured over docs looking for this functionality with no luck.
Any help would be much appreciated!
Your link refers to a video search.
1) First, you need to retrieve the channel info for the channelID (e.g. UCn8zNIfYAQNdrFRrr8oibKw).
See: https://developers.google.com/youtube/v3/docs/channels
Get the part:
"contentDetails": {
"relatedPlaylists": {
"likes": string,
"favorites": string,
"uploads": string,
"watchHistory": string,
"watchLater": string
}
2) Then use the "uploads": string, to retrieve the videos, being the user uploaded videos, which is a playlist.
For retrieving playlists see: https://developers.google.com/youtube/v3/docs/playlists .
Use the api call search.list, for example:
GET https://www.googleapis.com/youtube/v3/search?channelId=ASADKAHWSDA&type=video&key={YOUR_API_KEY}
in the query parameters specified the resource type = video because you want the videos of this channel. As cited here https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list
The type parameter restricts a search query to only retrieve a particular type of resource. The value is a comma-separated list of resource types. (string)
The resource can be anything a video, playlist, subscriber, etc. Hope this help.
When we view the YouTube page, and click Music, we are able to see them on different genre's like "Rap", "Rock", "Country", etc.
How can I retrieve this data (the genre-wise listing of videos) using the YouTube Apis.?
One way to do this is using the Topics API integration with V3 of the API. Take a look at the videos.list() API call. Plug in these values:
part: topicDetails
id: fWNaR-rxAic
fields: items/topicDetails/topicIds
The ID of that video corresponds to Carly Rae Jepsen's "Call Me Maybe". When you look at the JSON response, you'll see a list of topic IDs:
[ "/m/015f7",
"/m/0h55y27",
"/m/0gkxzs6",
"/m/064t9" ]
These are Freebase machine IDs. You would then make a Freebase API call to retrieve information about that particular topic. For instance, /m/064t9 corresponds to "Pop Music".
Thise method won't work for 100% of videos on YouTube; Metallica's "Whiskey in a Jar" only returns topics for the song and the band, however, Britney Spear's "I Want to Go" correctly returns a machine ID for "Pop Music".
The reason for this is that the Topic is often machine generated, not human curated (though we do quality checks). We did a Google I/O talk about how this works. The good news is that once you DO have a machine ID, it's very easy to find other videos by topic ID. Our samples demonstrate how to do this.
In freebase you can ask for music genre mids. For example in: http://www.freebase.com/search?query=rock you get that /m/06by7 = rock. With this id you do a query on youtube and get videos regarding this genre;
Try it https://developers.google.com/youtube/v3/docs/search/list#try-it with this conditions:
part: snippet
topicId: /m/06by7
For anyone wondering about this now (2017) freebase is deprecated and so instead you should use the list currently provided here: https://gist.github.com/stpe/2951130dfc8f1d0d1a2ad736bef3b703
Ikai Lan is still correct that the part is topicDetails to get this information from the API.