how to get youtube live api stream key - youtube

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()

Related

Python script end Youtube live stream

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

Live stream using Youtube's Livestreaming API to someone else's channel

I tried youtube's watchme app for live streaming and I understand the code fairly. In my use case the user needs to be able to live stream to another channel. I understand there is a need of Stream key here, but I need a rough guidance on where I need to change in the code. Any hints or a rough idea would do too. I just need headstart.
If you are using Youtube WatchMe app for Android, it will create live events on your Youtube account. If you want the user to type a Stream Key from a Live stream issued from another Youtube account you will have to create a function similar to the startStreaming method :
public void startStreaming(EventData event) {
//the event is already started on your external live stream
//String broadcastId = event.getId();
//new StartEventTask().execute(broadcastId);
Intent intent = new Intent(getApplicationContext(),
StreamerActivity.class);
intent.putExtra(YouTubeApi.RTMP_URL_KEY, event.getIngestionAddress());
// we don't need this since it's only used to end the live event
intent.putExtra(YouTubeApi.BROADCAST_ID_KEY, "");
startActivityForResult(intent, REQUEST_STREAMER);
}
Note that broadcast id is sent to StreamerActivity in order to be able to finish the event (endEvent) which you won't be able to do using an external live stream.
event.getIngestionAddress() is the Stream Key url eg :
rtmp://a.rtmp.youtube.com/live2/<Stream key>
So you can create a method like the following :
public void startStreaming(String streamKey) {
String url = "rtmp://a.rtmp.youtube.com/live2/" + streamKey;
Intent intent = new Intent(getApplicationContext(), StreamerActivity.class);
intent.putExtra(YouTubeApi.RTMP_URL_KEY, url);
intent.putExtra(YouTubeApi.BROADCAST_ID_KEY, "");
startActivityForResult(intent, REQUEST_STREAMER);
}

Twilio Chat getChannels order by most recent message

In twilio chat, is there a way to specify an order to the getChannels() method? Or is there a property on the Channel object that will tell me when the last message sent on that channel was? The dateUpdated property on Channel seems to be when properties on the channel were updated, not including messages sent/received.
I would like to order my channels list by the most recent messages. And I would like to do this without having to retrieve all the messages first.
You can add the attributes parameter upon updating a channel.
An optional string metadata field you can use to store any data you
wish.
You could track time/date info of messages here.
# Update the channel
service = client.services.get(sid="CHANNEL_SID")
channel = service.channels.create()
response = channel.update(friendly_name="NEW_FRIENDLY_NAME", attributes="ANY_DATA_YOU_WISH")
print(response)
You should then be able to subscribe to a channel event (JavaScript SDK example). As you did not specify what language you're using you will also find more details in the API Docs for iOS and Android SDKs as well.
// A channel's attributes or metadata have changed.
messagingClient.on('channelUpdated', function(channel) {
console.log('Channel updates: ' + channel.sid);
});

How can I get all my subscribed channel using youtube api v3

I'm new to youtube api v3, and I have a problem when get all my subscribed channel. I've subscribed 65 channel but I can only get 50 each api call. So, Is there any way to get all?
Another thing is, I have a channelID, is there any api to check this channel in a list of my subscribed channel?
Youtube API restricts 50 results per call. In case you were asking whether you can get all 65 in the same call, then the answer is no. However, if you meant whether all 65 can be retrieved then, yes. You'll need to use the nextPageToken paramter value and pass it to the pageToken parameter which will take you to the next page. In code, it can be handled in the following way(as shown in the documentation):
var nextPageToken = '';
// This loop retrieves a set of playlist items and checks the nextPageToken
// in the response to determine whether the list contains additional items.
// It repeats that process until it has retrieved all of the items in the list.
while (nextPageToken != null) {
var playlistResponse = YouTube.PlaylistItems.list('snippet', {
playlistId: playlistId,
maxResults: 25,
pageToken: nextPageToken
});
Regarding your ChannelID problem, from your description I understand you want to check whether you are subscribed to a particular channel in case you have it's ID. I believe the Activities method of Youtube API should be able to help you out. Look at contentDetails.subscription property. I hope that resolves your problem.

YouTube API Subscribe to Channel returns TooManyEntries when I have only a few subscriptions. Anyone know why?

I'm developing a YouTube client using the C# API library. On one account when I try to subscribe to a channel I get a TooManyEntries exception even though I only have 40 subscriptions. Anyone know why?
var subscription = new Subscription();
subscription.Type = SubscriptionEntry.SubscriptionType.channel;
subscription.UserName = youTubeId;
var response = _request.Insert(new Uri(YouTubeQuery.CreateSubscriptionUri(null)), subscription);
My guess would be that you're trying to subscribe twice to the same channel. Is that it?

Resources