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
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.
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()
TL;DR: Via the Slack APIs, how can I differentiate between a message in a channel vs a direct message?
I have a working Slack bot using the RTM API, let's call it Edi. And it works great as long as all commands start with "#edi"; e.g. "#edi help". It currently responses to any channel it's a member of and direct messages. However, I'd like to update the bot so that when it's a direct message, there won't be a need to start a command with "#edi"; e.g. "#edi help" in a channel, but "help" in a direct message. I don't see anything specific to differentiate between the two, but I did try using the channel.info endpoint and counting the number of people in "members"; however, this method only works on public channel. For private channels and direct messages, the endpoint returns an "channel_not_found" error.
Thanks in advance.
I talked to James at Slack and he gave me a simply way to determine if a message is a DM or not; if a channel ID begins with a:
C, it's a public channel
D, it's a DM with the user
G, it's either a private channel or multi-person DM
However, these values aren't set in stone and could change at some point, or be added to.
So if that syntax goes away, another way to detect a DM to use both channels.info and groups.info. If they both return “false” for the “ok” field, then you know it’s a DM.
Note:
channels.info is for public channels only
groups.info is for private channels and multi-person DMs only
Bonus info:
Once you detect a that a message is a DM, use either the user ID or channel ID and search for it in the results of im.list; if you find it, then you’ll know it’s a DM to the bot.
“id” from im.list is the channel ID
“user” from im.list is the user ID from the person DM’ing with the bot
You don’t pass in the bot’s user ID, because it’s extracted from the token
FYI as of July 2017, for "message.im" events (via your app's Event Subscriptions), the event payload seems to now return additional fields to detect if the message is coming from your own bot (pasted in here from my logs):
INFO[0012] got Slack message: (bot.SlackMessage) {
SlackEvent: (bot.SlackEvent) {
Type: (string) (len=7) "message",
EventTs: (string) (len=17) "1501076832.063834",
User: (string) ""
},
SubType: (string) (len=11) "bot_message",
Channel: (string) (len=9) "D6CJWD132",
Text: (string) (len=20) "this is my bot reply",
Username: (string) (len=15) "Myapp Local",
BotID: (string) (len=9) "B6DAZKTGG",
Ts: (string) (len=17) "1501076832.063834"
}
Slack have added Conversations API some time ago. You should use it to differentiate between PM/channel instead of relying on prefix.
From Conversations API documentation:
Each channel has a unique-to-the-team ID that begins with a single letter prefix, either C, G, or D. When a channel is shared across teams (see Developing for Shared Channels), the prefix of the channel ID may be changed, e.g. a private channel with ID G0987654321 may become ID C0987654321.
This is one reason you should use the conversations methods instead of the previous API methods! You cannot rely on a private shared channel's unique ID remaining constant during its entire lifetime.
Get conversation info using conversations.info method and check is_im flag. is_im == true means that the conversation is a direct message between two distinguished individuals or a user and a bot.
The info function is also available for private channels with the Slack API method groups.info. This works also for direct message channels with multiple participants, since they are a special form of private channels.
You can use groups.list to get the IDs of all private channels incl. direct message channels with multiple participants.
Note that groups.list will only return private channels, that the user or bot that the access token belongs to has been invited to.
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.
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];