Get next "premiere" on a Youtube channel - youtube-api

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.

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

Filtered Pubnub Twitter stream not returning results

I'm consuming the PubNub Twitter stream and getting data on the console successfully. What I'm having trouble with, though, is the number of results. This is the code:
PUBNUB({
subscribe_key: 'sub-c-78806dd4-42a6-11e4-aed8-02ee2ddab7fe'
}).subscribe({
channel : 'pubnub-twitter',
callback: processData
});
function processData(data) {
if(data.text.toLowerCase().indexOf("#brexit")>-1)
{
console.log(data.text);
}
}
I'm getting results on my console for this too, but they're really slow (I had to wait about seven minutes to get two tweets, while on the Twitter app, there are are at least 3-5 tweets with this hashtag every minute).
Is there a faster/more efficient way to filter the stream?
Are you using your own Twitter connection or the stream from this page?
https://www.pubnub.com/developers/realtime-data-streams/twitter-stream/
This stream represents only a small fraction of the entire Twitter firehose, so it is very possible that you'd only get a hashtag match every few minutes.
If you want a specific hashtag you should create your own Twitter to PubNub stream. I wrote this blog on how to do it with just a little bit of code.
https://www.pubnub.com/blog/2016-04-14-connect-twitter-and-pubnub-in-one-line-of-code-with-nodejs-streams/

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.

GET YouTube Video URL - Data API 3.0

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];

Resources