Search in Youtube API by videoCategoryId - youtube

I am trying to run the following call of the Youtube search API:
GET https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=10&order=relevance&relatedToVideoId=_CgRVkydY6Q&type=video&videoCategoryId=2&key={YOUR_API_KEY}
It returns 10 results, but some of them are not in category 2. For example, it gave me a result (ID: TG5e9Px3h-M) with videoCategoryId 22. I assume it does the search in the category ID with LIKE, not exact match.
How can I make this search with exact match for videoCategoryId?

I think you cannot use relatedToVideoId and videoCategoryId at same time. Related videos list for a particular video is fixed in youtube. I have tried with 1,10,22,33,32 and 44 category id. But I got same result has I do not give videoCategoryId parameter. videoCategoryId is works when you search keyword and just give type parameter in api url.

Related

Finding random youtube videos of a specific language with subtitles

i would like to crawl Youtube for videos of a specific language that contains subtitles/closed-captions(CC).
For example,
I want to crawl for 200 random English videos with English subtitles/(CC).
I want to crawl for 300 random Chinese videos with Chinese subtitles/(CC).
I want to crawl for 550 random Malay videos with Malay subtitles/(CC).
There's an api here that helps to extract transcripts, but the main bottleneck right now is that i have to go youtube to search for these videos and watch one by one to find out if they are indeed in the correct language, and if they really contain subtitles/CC.
An option is:
Use YouTube Data API - search request for search videos that contains subtitles; for that, use videoCaption parameter with value: closedCaption.
You might need use another parameters for reduce the search terms to specific topics or get certain desired results; for example, for the q parameter, use a search term that retrieves the desired results; also all parameters like: videoDuration, type = video, relevanceLanguage.
Once you got such results, copy/paste the videoId you got from the results of the request and use your web-crawler for get more videos and the related ones.
For anyone still struggling with this, and as per the YouTube Data API for videoCaption to work, you need to also set the type parameter's value to video:
If you specify a value for this parameter, you must also set the type
parameter's value to video.

Youtube data API, query within channel lead to unexcpected results

I'm trying to use Youtube Data API for a project, the goal is seeking for a keyword in a channel and show the response to the user. I used the Search for "snippet" part and launched it querying for a specific keyword and specifing the channel id but the response didn't include all the videos that I was expecting. For instance, let's say that the channel has 10 videos with "c" charachter in the title, setting the q field with "c" value will return only one video.
On the other side, if I search for a whole word it returns some videos with that word on title and some other videos that doesn't have it, neither in description. The order criteria in this case seems to be ok (from the strongest match to the most weak), but I don't know if all of this is working fine.
Is this a normal behaviour or am I doing something wrong?
Setting an order on the search, the issue seems to be solved.

How to get latitude and longitude of youtube video from videoid?

hello friends i am using youtube search api
https://www.googleapis.com/youtube/v3/search?pageToken=CDIQAA&part=snippet&location=40.748817%2C-73.985428&locationRadius=1km&maxResults=50&type=video
but in response i am not getting location attributes . I have only channel Id and video id and i want posted location .
Tested your search query, it returned a 200 OK but with no results and when I changed the query to 10KM radius, I got 23 results. Anyhow, the location details you are searching are a part of recordingDetails as shown here. Scroll down to Resource Representation on that page. This is an optional parameter and does not necessarily have to be included. However, recordingDetails are a part of the Videos List and Search endpoint doesn't allow you to query those. So you might have a better chance querying the Videos List endpoint.
Scroll down to the bottom of Videos List link and enter the following value to see what I mean:
part - snippet,recordingDetails
chart - mostPopular
maxResults - 50
This endpoint accepts Video ID as an input and would allow you to search for a video using it's ID.
As you can also see in the Videos Insert endpoint, these are optional parameters left for the uploader to define. Hence, if you're not getting any results it probably means they were not defined for that video.

Top 100 youtube videos

Is there any way to have updated lists of top 100 videos of youtube by genre and/or by country!
Any kind of resources like json files or xml.
You'll want to use the chart parameter of the videos.list endpoint. Set the chart to mostPopular, and then include a regionCode parameter and videoCategoryId parameter for further narrowing down. For example,
GET https://www.googleapis.com/youtube/v3/videos?part=snippet&chart=mostPopular&regionCode=UA&key={YOUR_API_KEY}
Will retrieve the 5 most popular videos in the Ukraine.
GET https://www.googleapis.com/youtube/v3/videos?part=snippet&chart=mostPopular&maxResults=25&regionCode=DE&videoCategoryId=1&key={YOUR_API_KEY}
Will retrieve the 25 most popular videos in Germany that relate to Film/Animation. And so on.
Note that if you don't include a videoCategoryId parameter, it will return results from all categories. If you don't include a regionCode, it returns the most popular videos across all regions. You can only set videoCategoryId to a value that's valid in the region you're searching in (you can use the videoCategories.list endpoint to find valid categories for regions, languages, etc.)

Delay and Inconsistent results using Twitter search API when using "since_id" parameter

We've noticed what seems to be a delay and/or inconsistent results using the Twitter Search API when specifying a sinceid in the param clause. For example:
http://search.twitter.com/search?ors=%23b4esummit+#b4esummit+b4esummit&q=&result_type=recent&rpp=100&show_user=true&since_id=
Will give the most recent Tweets, but:
http://search.twitter.com/search?ors=%23b4esummit+#b4esummit+b4esummit&q=&result_type=recent&rpp=100&show_user=true&since_id= 12642940173
will often not give tweets that are after that ID for several hours (even though they're visible in the first query)...
anyone have similar problems?
First off, those are not Twitter search API URLs. You should be querying the API like this:
http://search.twitter.com/search.json?q=%23b4esummit%20OR%20#b4esummit%20OR%20b4esummit&result_type=recent&rpp=100&show_user=true
Second, since_id cuts off from the bottom of the list. You can see the behavior illustrated in this documentation: https://dev.twitter.com/docs/working-with-timelines
For an example, at the time of this writing, the above URL returns 31 entries. Picking the ID of a Tweet in the middle of that list, I constructed:
http://search.twitter.com/search.json?q=%23b4esummit%20OR%20#b4esummit%20OR%20b4esummit&result_type=recent&rpp=100&show_user=true&since_id=178065448397574144
Which only returns 12 entries, which match the top 12 entries of the first URL.

Resources