Resolving a Video Resource given a YouTube URL - youtube-api

SoundCloud's API has a nice endpoint for submitting a permalink and getting back information about the media there.
Given the many YouTube URL variants (i.e. http://www.youtube.com/watch?v=-<someID>, http://youtu.be/-<someID>, http://www.youtube.com/v/-<someID>?version=3&autohide=1, etc...) is there a way to request a Video Resource given a URL?

You can use Videos: list which returns a list of videos that match the API request parameters.
HTTP request:
GET https://www.googleapis.com/youtube/v3/videos
You can also add query parameters and additional properties in your HTTP request for multiple video resources properties as given in the documentation.
Sample requests to the YouTube API are shown in Sample API Requests.

https://www.googleapis.com/youtube/v3/videos?part=snippet&id={VIDEO_ID}&key={YOUR_API_KEY}

Related

How to programmatically check if a live YouTube channel is streaming?

My company runs a live web stream and has started duplicating this to YouTube. Unfortunately the staff won't check if it's live and internet issues cause our web encoder to stop encoding at times.
Is there a programmatic way I can tell if a channel is ACTUALLY streaming? i.e. if live video is coming out the channel and not just that "the channel is live"?
You may use Search: list.
Using this request returns a collection of search results that match the query parameters that you have specified in the API request. Add part=snippet in your request since this is a required parameter. Then, you may add the following optional parameters with their corresponding values in your HTTP request:
channelId=[channelId] - to search resources created by a particular channel.
type=video - to retrieve a particular type of resource
eventType=live - to return only active broadcasts. Please note that if you use eventType, also set the type parameter's value to video.
Combining all of these parameters, you may send HTTP request using the following format:
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCXswCcAMb5bvEUIDEzXFGYg&type=video&eventType=live
To better filter your search, you may also opt to add more parameters that are listed in supported parameters.
Lastly, solution in this related SO post - How to check if YouTube channel is streaming live might also help.

get tweets using stream API twitter using 1.1

I found that we can use stream API to get the latest tweets based on hash tags or keywords.
It says you have to keep your http connection open. I am having a doubt regarding this.
Can anyone give me an example of stream API in php?
And other thing can I skip hashtag and keyword parameter is this API ? So I can all the statuses?
Can I pass a parameter like latitude and longitude to get tweets from the specific region?
You can request tweets by location, see their API documentation for specifying location boundaries:
https://dev.twitter.com/docs/streaming-apis/parameters#locations

How to get channel related data from youtube api

I need to get the video/playlists/show data from youtube.com.
Example :
http://www.youtube.com/channel/SWMb9NxQL9I6c
http://www.youtube.com/show/mtvroadies9/featured
Is there a way I can get the video details for the above URL using the youtube API?
Yes, using:
https://developers.google.com/youtube/v3/docs/channels
e.g.
https://www.googleapis.com/youtube/v3/channels?part=snippet&id=SWMb9NxQL9I6c&key={YOUR_API_KEY}
You need to look at the YouTube Data API. You will find there documentation about how the API can be accessed. You can also find client libraries.
You could also make the requests yourself. Here is an example URL that retrieves the latest videos from a channel :
https://www.googleapis.com/youtube/v3/search?key={your_key_here}&channelId={channel_id_here}&part=snippet,id&order=date&maxResults=20"

YouTube URL parameters issue. YouTube not using HTTP ranges

I want to understand all the parameters of a YouTube video as YouTube is now not using the HTTP range element but using its own range parameters inside its URL and thus I am not able to make a session using the Wireshark as i see so many HTTP 200 ok with video/x-flv and thus my player is not able to associate them as it reads the HTTP responses and its ranges. Here are the sample URLs what YouTube is sending for a single video. Is there any documetation available for this as well?
GET /videoplayback?algorithm=throttle-factor&burst=40&cp=U0hTTldOVF9FUUNOM19PSFhIOnBNNjJuUGVsZDZU&expire=1349736707&factor=1.25&fexp=922401%2C920704%2C912806%2C900711%2C913546%2C913556%2C925109%2C919003%2C920201%2C912706%2C900816&id=ee88421fc6a3f768&ip=90.84.144.49&ipbits=8&itag=34&keepalive=yes&key=yt1&ms=au&mt=1349713452&mv=m&newshard=yes&range=13-1781759&signature=84690C3B43F6FFBDD69E0E7009D0A6436946D642.904ADA59891696B5D1411665853784438D9E35D4&source=youtube&sparams=algorithm%2Cburst%2Ccp%2Cfactor%2Cid%2Cip%2Cipbits%2Citag%2Csource%2Cupn%2Cexpire&sver=3&upn=fc55lw1im0s HTTP/1.1
GET /videoplayback?algorithm=throttle-factor&burst=40&cp=U0hTTldOVF9FUUNOM19PSFhIOnBNNjJuUGVsZDZU&expire=1349736707&factor=1.25&fexp=922401%2C920704%2C912806%2C900711%2C913546%2C913556%2C925109%2C919003%2C920201%2C912706%2C900816&id=ee88421fc6a3f768&ip=90.84.144.49&ipbits=8&itag=34&keepalive=yes&key=yt1&ms=au&mt=1349713563&mv=m&newshard=yes&range=10690560-12472319&signature=84690C3B43F6FFBDD69E0E7009D0A6436946D642.904ADA59891696B5D1411665853784438D9E35D4&source=youtube&sparams=algorithm%2Cburst%2Ccp%2Cfactor%2Cid%2Cip%2Cipbits%2Citag%2Csource%2Cupn%2Cexpire&sver=3&upn=fc55lw1im0s&redirect_counter=1&cms_redirect=yes HTTP/1.1
GET /videoplayback?algorithm=throttle-factor&burst=40&cp=U0hTTldOVF9FUUNOM19PSFhIOnBNNjJuUGVsZDZU&expire=1349736707&factor=1.25&fexp=922401%2C920704%2C912806%2C900711%2C913546%2C913556%2C925109%2C919003%2C920201%2C912706%2C900816&id=ee88421fc6a3f768&ip=90.84.144.49&ipbits=8&itag=34&keepalive=yes&key=yt1&ms=au&mt=1349713452&mv=m&newshard=yes&range=12472320-14254079&signature=84690C3B43F6FFBDD69E0E7009D0A6436946D642.904ADA59891696B5D1411665853784438D9E35D4&source=youtube&sparams=algorithm%2Cburst%2Ccp%2Cfactor%2Cid%2Cip%2Cipbits%2Citag%2Csource%2Cupn%2Cexpire&sver=3&upn=fc55lw1im0s HTTP/1.1
There is no documentation for this sort of thing, and video streams are generally considered a "black box" from a developer's perspective.
For your question, see this thread.
Youtube streaming works providing 1.7MB chunk pieces controlled by range param, which indicate [start byte]-[end byte].
I'am also questioning similar issue here.

Twitter Streaming API - filtering by urls

I am trying to filter tweets from the Streaming API using a url in the track parameter. However I'm not getting the tweets I expect. My suspicion is that the filter doesn't apply to the expanded url and but to the automatically shortened url (t.co).
Can anyone confirm that this is the case? The Streaming Api docs don't even mention how the filtering is applied.
If this is the case does anyone have a workaround?
I'm using the extended URL with cURL. I get the live tweets on my terminal for a particular search parameter. You may like to look into this one.
curl https://stream.twitter.com/1/statuses/filter.json?track=SEARCH_PARAMETER -uUSERNAME:PASSWORD

Resources