I have been looking through the Google docs on how to get a JSON list of videos for a channel. And I figured out how to get the videos list with thumbnails and title and so on..... but nowhere can I find how to get a VIDEO MP4 (or whatever other format) URL's.
You see I need to play the videos in a iOS app and my app needs the actual VIDEO URL not some annoying url which just returns a list of thumbnails or playlists...
I found these instructions online and they work apart from the last part:
You have to get the upload playlist id to get each videos uploaded. To get that, you need to get the channel id. After you have the playlist id from the channel id, it is pretty simple. I have written out the steps for all three below.
Also, we offer PubSubHubBub which allows you to be alerted every time
a new video is added to a channel, or you could use SUP (V2) to see
which resources have changed before making the calls.
Instructions to get video ids for all uploaded videos for a channel in
V3
Get the channel id for the channel you want (you probably only need to
do this once, then you can save it)
Use search.list Set type to channel Set q to the name of the channel
you want Grab the channel id (something like this: "channelId":
"UC0X2VuXXXXXXXXXXXXXXXX") Get the playlist id for the channel uploads
using the channel id from step 1 (you probably only need to do this
once, then you can save it)
Use channels.list Set id to UC0X2VuXXXXXXXXXXXXXXXX from step 2 Grab
the uploads key from contentDetails (something like this: "uploads":
"UU0XXXXXXXXXXXXXXXXXXXX") Get the videos via the playlistitems in the
playlist using the playlist id from step 2
Use playlistItems.list Set playlistId to UU0XXXXXXXXXXXXXXXXXXXX from
step 2 Go through each PlaylistItem and pull out the video id
As you can see the very LAST part says to go through thr playlistitem and pull out the video id. I have done that, but what do I need to do with the video id in order to get the video URL???
Can anyone help me?
Thanks, Dan.
NSString *youtubeHTML = [[NSString alloc] initWithFormat:#"\
<html><head>\
<style type=\"text/css\">\
body { background-color: transparent;\
color: white; \
}\
</style>\
</head><body style=\"margin:0\">\
<iframe class=\"youtube-player\" width=\"280\" height=\"210\" src=\"http://www.youtube.com/embed/%#?\" frameborder=\"0\" allowfullscreen=\"true\"></iframe>\
</body></html>", videoID];
You can also use the URL to show/hide stuff, hd, start at a certain time.
youTubeView = [[UIWebView alloc] initWithFrame:CGRectMake(yourframe)];
[youTubeView loadHTMLString:youtubeHTML baseURL:nil];
Related
I have read all the Youtube api doc but I haven't find this answer. Is there an API to know the date and time of next premiere video of a selected channel?
One more time YouTube APIs doesn't provide a basic feature.
I recommend you to try my open-source YouTube operational API.
Indeed by fetching https://yt.lemnoslife.com/channels?part=upcomingEvents&id=CHANNEL_ID you will retrieve all upcoming events of the given YouTube channel.
Especially may interest you about the upcoming event:
id: item["videoId"] (example: yVVQai84NrI)
upcoming event date and time: item["upcomingEventData"]["startTime"] (example: 1717106417)
title: item["title"]["simpleText"] (example: Another "Premiere" video)
thumbnails: item["thumbnail"]["thumbnails"] (example: url, width, height)
Channels to test:
Premieres UCv_LqFI-0vMVYgNR3TeB3zQ (should at least return BvVOl19eo1o)
Upcoming live streams UCv_LqFI-0vMVYgNR3TeB3zQ (should at least return oXqOdmXu6ic)
Note: youtube-data-api and youtube-livestreaming-api tags would be appropriate for your question.
i have an AJA HELO media streaming device and from time to time it stops streaming. What i want to do it automate some kind of streaming reset. I am able to issue command to the AJA to stop and start streaming, but i need help figuring out how to "End Stream" on my current Youtube Live stream. Just doing so on the AJA does nothing since Youtube still thinks the stream will be back shortly.
Does anyone know of a way to achieve this?
P.S. i am able to retrieve the exact stream identifier via a Python script, as i am monitoring the state in an NMS.
Thanks
I'm not sure if this is directly related, but to end a livestream using the Python google-api-python-client library:
youtube = build("youtube", "v3", credentials = [YOUR CREDENTIALS])
request = youtube.liveBroadcasts().transition(
part = 'snippet',
id = [VIDEO ID OF THE LIVESTREAM],
broadcastStatus = 'complete'
#Setting the 'broadcastStatus' to 'complete' ends the stream
)
response = request.execute()
You can find more details about this in the docs here (including POST): https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/transition
How can I bind my YouTube stream key to match previous video.
I'm trying to use java to do it but getting no where.
I'm looking at the example given to create the broadcast stream but it doesn't have the keeping same key.
I've gotten help on this before. Please try do some research on Google and then ask the question. You can see How can I change the stream my event uses via the YouTube live api?. Which will help you as it did me.
In short this was the code i received for help.
Credit to #M. Prokhorov
YouTube yt = ... // your reference to YouTube
String broadcastId = ... // your broadcast Id
String newStreamId = ... // identifier of stream you want to bind
String apiKEy = ... // your API key
// you can define other response parts if you want more or don't want some of these
String responseParts = "id,status,contentDetails.boundStreamId";
yt.liveBroadcasts().bind(broadcastId, responseParts)
.setApiKey(apiKey)
.setStreamId(streamId)
// other data you might want in request
.execute()
I'm running a service where people can connect their Google account using oauth 2.0, and with YouTube permissions I can manage their channels/access their YouTube Channel ID.
However, my question is whether or not you can go backwards. i.e. How can you determine the Google Account Owner from a given YouTube channel ID?
googlePlusUserId is now deprecated from
https://developers.google.com/youtube/v3/docs/channels#properties
contentDetails.googlePlusUserId no longer exists as part of the contentDetails part.
Based on this excerpt from their change-log
June 13, 2016
This update contains the following changes:
The channel resource's contentDetails.googlePlusUserId property has
been deprecated. Previously, the property was only present if the
channel was associated with a Google+ profile. Following the
deprecation, the property will no longer be included in any channel
resources.
The comment resource's snippet.authorGoogleplusProfileUrl
property has been deprecated. Previously, the property was only
present if the channel was associated with a Google+ profile.
Following the deprecation, the property will no longer be included in
any comment resources.
Since neither of these properties will be
returned following the deprecation, both properties have been removed
from the corresponding resource documentation.
Probably people can not get Google+ ID from YouTube API(v3). But even the channel owner did not create google plus account, you can know it in advance on the channel HTML document by using XHR or curl.
visit channel page.
https://www.youtube.com/channel/UCL8ZULXASCc1I_oaOT0NaOQ
Catch Javascript object from Developer tool on browser at the page.
ytInitialData.metadata.channelMetadataRenderer.ownerUrls
[ "http://www.youtube.com/user/googlechrome",
"https://plus.google.com/100585555255542998765" ]
Second one is always google plus address and the number is Google+ ID. You can get more info from ytInitialData at the channel page if necessary.
One example.
https://www.youtube.com/channel/UCiQPrVjbUlZBWY0fVtvpoKg
About that channel id(UCiQPrVjbUlZBWY0fVtvpoKg) You can not get Google+ ID from YouTube API(v3), but you can get Google+ ID at the channel directly when you can access html document or read it. Even if the channel owner did not create google plus account, the Youtube already made Google+ ID together.
You can get user Google+ ID through a YouTube API(v3) request, e.g.:
https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id={CHANNEL_ID}&key={YOUR_API_KEY}
Will return:
{
"kind": "youtube#channelListResponse",
"etag": "fooHash",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [{
"kind": "youtube#channel",
"etag": "fooHash",
"id": "fooHash",
"contentDetails": {
"relatedPlaylists": {
"likes": "fooHash",
"favorites": "fooHash",
"uploads": "fooHash"
},
}
"googlePlusUserId": "{ID}"
}]
}
I am trying to get channel's videos using,
https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId=UC6-F5tO8uklgE9Zy8IvbdFw&type=video&maxResults=50&key={YOUR_API_KEY}
It is working. Now i want show channel video for that i am using show channel id in this api like,
https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId=SW0ORvMZrxEHM&type=video&maxResults=50&key={YOUR_API_KEY}
but it returns whole search result. I want only that shows videos.
Can anyone facing same issue?
The channelId "SWfds0ORvMZrxEHM" is an invalid ChannelId with an invalid ChannelId format. As you can see, the first's request ChannelId starts with UC, like each valid channelId has to (there are some exceptions, but channelIds always starts with a two letter code).
If you replace the channelId of the second request with any other random string, you always get totalResults: 1000000
If you replace the channelId with a string that starts with "UC[random string]" you will get totalResults: 0