So I'm using the YouTube API to search for videos. With my search I'm including the following parameters: type = video, videoEmbeddable = true, videoSyndicated = true. But results that I'm getting can't be played on my site still. An example call I'm doing would be
https://www.googleapis.com/youtube/v3/search?part=snippet&q=Yellow+Claw&maxResults=25&type=video&videoSyndicated=true&videoEmbeddable=true&videoCategoryId=10&key=
But the results still give me an error when embedding stating that
This video contains content from ____. It is restricted from playback from certain sites or applications.
The part that really throws me off is that I've seen the exact same video embedded on another site.
Is there some sort of setting that I don't know about that needs to be changed? Is this call incorrect and is there something that I'm missing?
If you check this blog, it may help you identify which part of your code need to be fix or some changes.
There were 5 specified areas that you need to check, mainly
yt:accessControl
Geo Restrictions
yt:state
Rentals
Other Restrictions not Currently Exposed via the API
Check your codes base the restriction set by the YouTube API. For further reference, check this SO post.
Related
Getting video in the results even though it didn't match query parameter(q)
The parameter i passed didn't exists in body,title,tags, But the video is relavant. Is API looks any other metadata of video.
For Example: i have given parameter as "mobile", this video https://www.youtube.com/watch?v=j8UNo3vRIB0 is coming as result, here video title and description not contain mobile as parameter
Latest data not coming consistently in youtube api
Some times latest data not coming in youtube data api.
For Example: i have given rule as "amazon". This video https://www.youtube.com/watch?v=6zygd1iW-f4 is showing in youtube website's latest videos but not coming in youtube api result.
Example query: https://www.googleapis.com/youtube/v3/search?part=snippet&order=date&q=amazon&maxResults=50&type=video&key=xyz
W.r.t. point (1), Youtube is working OK, since the content of that video is related to the keyword mobile (please convince yourself by watching the first couple of minutes of that video).
For what concerns your point (2), I cannot in any way make the Youtube site to produce the video 6zygd1iW-f4 near the top of its search result set for the query term amazon.
All in all, I deem your claims above unsustainable.
Please note that one cannot expect crisp results from Youtube when queried with such general terms as yours is. One should not expect Youtube's searching feature to work similarly to say a full-text search in single computer-stored database. There will always be a degree of fuzziness associated to querying Youtube for broad terms.
You are actually stumbling on a very tricky scenario. Your goal is to get the same results via the API that you also see on YouTube’s website, right?
First, make sure that you configured the search endpoint as identical to your YouTube user account as possible:
order: relevance
relevanceLanguage: Same as the language that you set in the menu of YouTube’s website (Use a ISO 639-1 2-letter Code)
regionCode: Same as the country that you set in the menu of YouTube’s website (Use a ISO 3166-1 2-letter Code)
With these settings you will see that the results will be quite similar. But still not identical. Not because the API is not working or is still not properly configured but rather because YouTube’s search results change all the time. Just do the same exact search on YouTube’s website just 10 seconds apart. You’ll see that you get different search results.
I am trying to get the normalized game name using youtube API for a video if it is in Gaming category.
For example: https://www.youtube.com/watch?v=qIvWgSpy31k, for this video I can see its normalized game name is the description:
But when I use the videos.list method, I can not see this returned. After checking all the properties for the video, I can not find it either.
Is there any way to fetch the game name?
That information isn't exposed by the YouTube API. You can see that by checking the documentation for Videos.list which returns a list of videos resources this is the information available about a video.
You can request it as a new feature here gdata-issues why they are using a gdata forum for issues I have no idea.
I've encountered the same problem, so far in 2020 they haven't implemented it yet. It looks more like business issue. The only way to get game title bound to video is webscraping. I've used headless browser library for Java called HtmlUnit. When you go to the direct url of the video you want to scrape just get html from it and use the regex listed below to acquire game title.
(?<=,"title":\{"simpleText":").*?(?="},"subtitle")
Given a YouTube Video id, and using youtube/v3/videos?id=<> API call, how can we find that the video is monetized? Which param in response signifies that?
e.g. https://www.youtube.com/watch?v=E1iqGiX0lSg
Thanks,
Nimish
There is no way to determine whether or not a video is monetized with a call to the YouTube Data API (which appears to be what you mean by youtube/v3/videos?id).
Instead, you'll need the YouTube Content ID API. Keep in mind that you'll have to be a partner of the CMS, and have the authentication of the CMS, to get visibility to a video's policy this way. You'll probably want to determine a video's policyId, and then use the policies.list resource to determine the type of policy (I've never attempted this myself, though this is how I would start).
See this question for more info.
We've noticed the search results returned from the v3 search api are different depending on the location of the server. I've confirmed the code is exactly the same and when I run a test using the try-it section of the api documentary website on the different server the results are different as well. Does anyone know why?
https://developers.google.com/youtube/v3/docs/search/list#try-it
That's normal, just as you'd expect from YouTube's web search, depending on your login and location, it will find most relevant videos.
I was having the same problem. In my own computer (I'm in Brazil) the call would return 10 videos. When executed on Azure server (East-US) it would return no videos at all.
So I added the param regionCode=BR and it worked properly.
Though its very old thread, let me share my learning for others who face this.
So to keep api request generic within all servers you need to set few request parameters of youtubeapi.
RegionCode -- region to filter videos for that channel/user.
And sort result if desired.
I would like to check and see if a youtube video is age restricted. There are not many videos that are, but some are. I have been digging around in the youtube api documents and on the internet, but can't seem to find a way to detect this.
I am using the Youtube API V2 and only looking for one video at a time.
To check whether a video is (age) restricted in a given region, you can take a look at the media:rating attribute of the video entry, which is documented at
https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_media:rating
If you want to do a search and filter out videos that are age restricted, you can use the safeSearch=strict parameter:
https://developers.google.com/youtube/2.0/reference#safeSearchsp
I agree to Greg Schechter. The actual question was like if we have a video id (eg: In the link http://www.youtube.com/watch?v=RyDY0hiMZy8 the video id is RyDY0hiMZy8), how can we get the age restriction details based on that?
There is an API provided by Youtube to get the details based on the video id. For the above example the API link is:
http://gdata.youtube.com/feeds/api/videos/RyDY0hiMZy8?v=2&alt=json
But there is no information about the age restriction in the response.
Update on the above post:
In the API response from http://gdata.youtube.com/feeds/api/videos/tA4wytG3uh0?v=2&alt=json
we have a media$rating content coming and the data coming there can be compared with the rules mentioned in the link https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_media:rating
For non restricted videos, the media$rating value is not coming in the response. eg: in the link http://gdata.youtube.com/feeds/api/videos/RyDY0hiMZy8?v=2&alt=json
Any updates are welcome.
Age gating is not supported for embedded playbacks; so it's not something that is returned in the YouTube data api.
You can un-restrict those videos by following this link:
https://www.quora.com/How-do-you-change-the-settings-of-the-the-age-restrictrincts-on-my-YouTube-videos/answer/Doyle-Lorraine
Then your iframes should be back to normal.