On YouTube API V3 search:list page, I try simple request with videoEmbeddable attribute to true.
It generates "Error 400, Invalid combination of search filters and/or restrictions.".
This parameter seems to be not supported and videoSyndicated too.
Is the API reference not up to date ?
URL: https://developers.google.com/youtube/v3/docs/search/list
Since the search is unified (returns videos, playlists, channels in response) you should filter type = video while using video filters like videoEmbeddable.
GET https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&videoEmbeddable=true&key={YOUR_API_KEY}
Related
In the Twilio documentation for the REST API for Media Streams, it says the Media Stream can be stopped with a name, but I can't quite figure out how or am I reading to much into the documentation.
Is it possible that the documentation is only relevant when using TwiML to stop the Media Stream and not the API and thus you have have use the Media Stream SID for the API?
<Stop>
<Stream name="my_first_stream" />
</Stop>
The example code in the docs is using the Media Steam SID only:
Stop Media Stream - Example in docs:
client.calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
.streams('MZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
.update({status: 'stopped'})
.then(stream => console.log(stream.name));
Works the same for interacting with Conference resource friendly names; use the resource URL; e.g.
https://api.twilio.com/2010-04-01/Accounts/{{account_sid}}/Calls/{{call_sid}}/Streams/{{stream_name}}.json
Where {{stream_name}} is the, well, stream name.
I am sure I have seen other APIs that allow you to specify a name or a SID when referring to the resource but I cannot find an example (so maybe I'm wrong).
This is a bit ambiguous here though. But, comments in the Node library suggest you can use a name or sid when constructing a stream:
#param {sid_like} sid - The SID of the Stream resource, or the `name`
And since those comments are derived from the API definitions, I believe that you can use the name in a REST API call too.
I'm trying to fetch YouTube videos for keyword 'Color&Co' but I'm unable to get similar response through YouTube API as compared to manually searching same keyword on youtube.com.
I have tried following encoding techniques to get response from YouTube API similar to manually searching on youtube.com:
keyword = 'Color&Co'
URI.encode(keyword)
CGI.escape(keyword)
ERB::Util.url_encode(keyword)
keyword.encode('iso-8859-1').encode('utf-8')
keyword.encode('iso-8859-1').force_encoding('utf-8')
keyword.force_encoding('iso-8859-1').encode('utf-8')
I'm expecting YouTube API to return response similar to searching same keywords with special characters on youtube.com.
Since it is a GET request to the endpoint documented here https://developers.google.com/youtube/v3/docs/search/list and the search term is passed as the q query string, you only need to use standard query string encoding as for any url. Even works with emojis.
Thus: ...?q=Color%26Co
The Youtube API document says that multiple keywords can be searched during video fetch as per the below link.
https://developers.google.com/youtube/2.0/reference#Searching_for_videos
The below link gives some examples for the same. The example provided for the "q" parameter says that we can use NOT (-) and OR (|) operator in the search:
https://developers.google.com/youtube/2.0/reference#qsp
Example: q=boating%7Csailing does a search for either boating or sailing.
I am able to understand these points. My question is I am using ZendGData library in Zend Framework 2 to search the videos. I am not sure how to provide multiple keywords for the search.
$yt = new ZendGData\YouTube();
$query = $yt->newVideoQuery();
All the combinations that I tried is provided below. None of them works.
$query->setQuery("french,tamil");
$query->setQuery("french|tamil");
$query->setQuery("french%7Ctamil");
$query->setQuery("french or tamil");
Note: The docs says to use url encode so that the pipe symbol is encoded. That's why I treid %7C in the search.
The URL generated by the ZendGData class is:
https://gdata.youtube.com/feeds/api/videos?q=french|tamil&start-index=58&max-results=50&safeSearch=none&orderby=viewCount&format=5&v=2
This does not fetch the videos with keyword "tamil". All the videos are from the first keyword only.
Please point me in the correct direction.
Or this with a simple space. Tested it and it found all the keywords https://gdata.youtube.com/feeds/api/videos?q=french%20tamil&start-index=1&max-results=50&safeSearch=none&orderby=viewCount&format=5&v=2
So try this $query->setQuery("french tamil"); or $query->setQuery(urlencode(("french tamil"));
Also your start-index looks strange and should that not be start-index=1
I am using "/reader/api/0/stream/items/ids" API to get the item ids for sources that I want.
I have quite a number of sources, so I repeated "s=" parameter to include in the api url.
However, google has given me an error of "URL is too long".
So the question is that How can I solve it so that I just use one time api call to get item ids for that many sources?
Thanks
It seems that /reader/api/0/stream/items/ids path supports a POST method. This means the amount of data you could pass by using POST verb is much more than by using a query string and a GET method.
So use https://www.google.com/reader/api/0/stream/items/ids URL for the post, and pass your query string as a post data. Don't forget to include an action token(T) which is required for POST requests.
The following query will return results, but some of them will contain a limitedSyndication restriction. This cannot be filtered out by format or by restriction parameters.
http://gdata.youtube.com/feeds/api/videos?alt=json-in-script&callback=jQuery.youtube.response&q=Madonna&v=2&format=5&start-index=11&max-results=10
restriction parameter is not used in the query above because YouTube Data API reference guide states the following:
By default, the API filters out videos
that cannot be played in the country
from which you send API requests.
Am I doing something wrong? (Besides searching for Madonna)
How can I get rid of limitedSyndication results, or is this a bug?
As stated in the GData docs, you can pass a "restriction" param that will filter out results that can't be played by the ip you pass, so you just need to get the user's IP and pass that to the request:
To request videos playable from a specific computer, include the restriction parameter in your request and set the parameter value to the IP address of the computer where the videos will be played – e.g. restriction=255.255.255.255.
To request videos that are playable in a specific country, include the restriction parameter in your request and set the parameter value to the ISO 3166 two-letter country code of the country where the videos will be played – e.g. restriction=DE.
You should include this parameter in any request to retrieve a list of videos, including search results, playlists, favorite videos, video responses and so forth. If a video in the API response is not playable in the location that you're using to restrict availability of the content, the <entry> for that tag will not contain a <media:content> tag. However, it will contain a <yt:state> tag that indicates that the video is restricted.