How to get error responses from YouTube v3 API :YoutubeService - google-api

I am currently using the Google YouTube V3 API to get view counts for few videos on You Tube.
I would like to parse the response to get results when view counts cannot be retrieved. Example “This video is private” or “The uploader has not made this video available”
I need to retrieve this part “This video is private”.
Here is a snippet of my code
Using Google.Apis.Youtube.v3.YoutubeService
private YoutubeService youtube;
var YTVideo = youtube.Videos.List(ytidobj.ToString(), "statistics");
var ViewCountResponse = YTVideo.Fetch()
I am able to get view counts from this call without any issues but I can’t seem to get the error responses?
How can get the error responses back from the the call : var ViewCountResponse = YTVideo.Fetch()

I tried to access the details of my private YouTube video from two accounts, one of which is the owner of the video, via YouTube Data API v3. The owner of the video received the full properties (including "privacyStatus": "private" with no issues, but the other account received a 200 OK response without any properties or details.
It seems like only the owners of the private videos are given a response, while other users will receive an empty response as though no such videos exist. YouTube Data API - Errors does not seem to include error responses for private videos either.
If you need to inform the user should there be an empty response, I suggest a message of "This video does not exist or is made private by the uploader" or something similar.
If you need to know if a video exists but is private, without being its owner, I don't think the v3 API is capable of that.

Which is making sense. The "private" state would not be private, if anyone could see there is a video.

Related

Live streams health status polling in YouTube v3 API

I have multiple live streams to YouTube being pushed 24/7 from IP cameras. In YouTube studio live stream interface, there is a column per live stream showing health of inbound connection & data.
(see snip below).
This shows for each currently 'live' live stream if the inbound data rate is 'excellent', 'good', 'poor', or 'no data'. I have to believe if the YouTube studio live interface is able to poll and display this, it should be available in the YouTube live v3 API.
However, I can't find anything on it. My need is I want to create automation to query status every 15 min or so and alert me if one of my camera sources goes down. Does anyone have insights on where to get this from the YouTube v3 API?
The answer to your question is straightforward:
Use the LiveStreams.list API endpoint, queried with the request parameter mine set to true and look for the following property of the JSON response:
status.healthStatus (string)
The status code of this stream.
Valid values for this property are:
good – There are no configuration issues for which the severity is warning or worse.
ok – There are no configuration issues for which the severity is error.
bad – The stream has some issues for which the severity is error.
noData – YouTube's live streaming backend servers do not have any information about the stream's health status.
Also, don't forget to pass status to the request parameter part too.

How to capture user_country/city in botframework web channel?

I would like to capture end-user location (country/city) in Application insights form azure botframework chatbot running on web chat channel. App insights instrumentation is already in place page view and custom events being collected, but it seems that the client_City and client_CountryOrRegion are not populated correctly. Is there a specific channel or webservice configuration?
Geolocation data can be accessed using the below method. This will provide you with the longitude and latitude providing the user grants access to this data.
You will then need another process or library to convert the location data to a physical location in the real world.
navigator.geolocation.getCurrentPosition( async (position) => {
const { latitude, longitude } = position.coords;
console.log(latitude, longitude)
})
There are some NPM packages that can do some of this for you, as well.
If you look at my posted answer here, you can see an example I provided on how to get location data for use in generating and displaying a map as a feature of the bot.
Please note that, in the above answer, the bot is responding to a request to display a map, is sending the activity which is then picked up by Web Chat. Web Chat, upon receiving the request, is then getting the location data and displaying the map.
In your case, you will want to send the data back to the bot for the bot to then do something with. You can refer to Web Chat's b.piggyback-on-outgoing-activities sample on how to do this.
Hope of help!

Google Meet integration api (like Hangouts app for Slack)

I want to utilise Google Meet api, which is used in Hangouts integration for Slack, description follows
TL;DR:
Links such as https://meet.google.com/new?gid=123&gd=qwe987 can be generated, so a modal is shown which can ask user's confirmation and then some request is sent from user's browser (where the Google Meet page is opened) to some endpoint (probably it is determined from gid which seems to be google application id). Is there a way to configure my application to have a webhook, so I can generate these custom links?
There's Google+ Hangouts app for Slack. Here's how it works (after you add the app in your workspace):
you send /hangout command in any Slack channel
slackbot sends an "Only visible to you" message in this channel with a link to start a new hangout. it looks smth like this (I changed data in the link): https://meet.google.com/new?gid=691521906844&gd=THTJ30X6W%7CU01113BD13M%7CD01113BDB5Z%7Csuren%7C%7C1846381238693%7C1%7CB01QFGG5GJF%7CE1MDm4DWcuVa0RbN5ZT9o5KF
when you visit the link, a new meeting is started instantly, and the page shows modal with text "To bring others into this video call, post a link it to your Slack channel" with buttons 'Cancel' and 'Post'.
when you click 'Post', a new message is sent to the Slack channel, where the command was sent. Text is "#Suren Khorenyan has started a Google+ Hangout and would like you to join. Join Hangout." and contains a link to the meet, which was created previously
How can I utilise this integration for another app, like Mattermost (or anything else like Telegram chats via bots)?
As I see, data in the url slightly changes. Probably it's payload for Google Meet to trigger Slack to send a message with link to the channel.
gid seems to be something like google app id
gd seems to be something like google data. If I url-decode it, it becomes THTJ30X6W|U01113BD13M|D01113BDB5Z|suren||1846381238693|1|B01QFGG5GJF|E1MDm4DWcuVa0RbN5ZT9o5KF. This is some kind of payload, separated by pipes (obviously), but I don't know what any part of this means (suren is my username in the Slack workspace, probably this is used for creating an invitation message).
When I click Post, this happens:
a new POST request to https://hooks.slack.com/services/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 is sent with form-data
hangout_id: 1812381238693
hangout_url: https://meet.google.com//abc-iuqx-def
a new message is posted to the Slack channel
Google meet somehow knows where to post back! Is this configured at the Google application (application id is provided via gid)? How can I configure my application for such behaviour? Where can I setup webhook url?
If we breakdown the request, we can see that url contains some parts of the gd payload:
THTJ27X6W - this is the first part of the gd payload
B01ABCD5GJF - last but one
E1MDm4DWcuVa0RbK5ZT9o5KD - the last part of the gd payload
and form-data contains:
hangout_id - this is in the gd payload after my name
hangout_url - obviously, this is the url for the new created meeting
How can I change it for my needs?
I created a new application at Google APIs dashboard (here console.developers.google.com/apis), but can't find any docs for this integration. There's Google+ Hangouts API in API Library, but it says Apps will continue to function until April 25, 2017..
I tried to approach it from another side:
In the API Library there's Google Calendar. I found mattermost-hangout app on GitHub (had to update it a bit, so it works with updated api). Here's how it works:
oauth2 for authorising at google (single account)
it handles POST request, which is meant to be received from Mattermost (triggered by a slash command),
creates a new calendar event using Google Calendar API (with conference),
takes hangouts url from the response and sends a new message in the Mattermost channel with invitation to join the meeting.
But it has some downsides:
you have to use one account to authorise all event creation events (yeah, it can be upgraded to authorise any number of users, but it'll be inconvenient. why to force anyone to provide access to their Google Account, when Google Meet authorisation just happens in browser, we don't need to create events)
account, used for auth, now has events in his calendar. of course, events can be deleted, but it's not the way.
Is there any documentation on utilising gid and gd params?
Generally, I want to find a way to configure a webhook in my app, so when Google Meet finds my application's ID in the gid query param, it looks at the app's config and sends a request to my app (previously configured endpoint (I assume it works this way)).
Of course there's a chance that it's some kind of internal API and it cannot be used by everyone, but I could not find any information on this.

Why insert request got an error response via Youtube API?

I request an insert api via Youtube API for starting live streaming and I got an error such as below image.
I knew that it's available live streaming with other tools.(refer to https://support.google.com/youtube/answer/2853834)
I have submitted their review request for using a scopes, and our project was accepted by them.
Same request with other client ID is working, but my clientId not working.
Can you explain why it happens?
To be able to live stream on mobile, your channel will need to have at least 1,000 subscribers.
link

Google places, with different api keys getting "You have exceeded your daily request quota for this API."

With google places API, autocomplete.
I'm getting the same response even when I create a new project, and put new API key in fetch.
Example:
mykey = different keys
https://maps.googleapis.com/maps/api/place/autocomplete/json?types=(cities)&key=mykey&language=en&components=country:us
Any ideas why is google always responding with status OVER_QUERY_LIMIT?

Resources