Youutbe api v3 save video to playlist - youtube-data-api

I am looking for a way to save video to a custom playlist on Youtube. Youtube offers this option in their browser, below the video you can click "save" button and popup will open where user can choose where to save a video. Is there an api equivalent of that?
I am searching their api documents but not sure where to look.
https://developers.google.com/youtube/v3/docs/videos

It seems you are looking for PlaylistItems: insert by specifying part=snippet and request body to:
{
"snippet": {
"playlistId": "YOUR_PLAYLIST_ID",
"position": 0,
"resourceId": {
"kind": "youtube#video",
"videoId": "YOUR_VIDEO_ID"
}
}
}

Related

Profile image is not displayed (error 403)

I'm using Google API (People) list and from returned JSON, I try to use image listed on "url" field:
"photos": [
{
"url": "https://lh3.googleusercontent.com/cm/AATWAfu9TeDbEEC2VEJqYuO1eGr1F7qRpGSvgKlsjMhny8UWSAB_STRGbHQYvwIQzgrp=s100",
"default": true,
"metadata": {
"source": {
"type": "CONTACT",
"id": "4da7eb9a8d9a19e5"
},
"primary": true
}
}
]
Problem is - not all images are displayed, like you can see here:
https://i.postimg.cc/BvPJLyD5/image-2023-01-11-172253699.png.
On console, I see error 403.
When I manually copy link (from "url" link above) and open it in browser, image is normally displayed. Also, when I reload page few times manually, some images are displayed and some other not (randomly).
Is there any solution for this?
It is related to logged status.
If I'm logged into Gmail or Drive, images are randomly displayed.
If I logout from Gmail and use API again, all images are always displayed. It is same for Google Drive, as you can see here: https://issuetracker.google.com/issues/229184403?pli=1

Closing the Microsoft Teams task module popup automatically

We are trying out messaging extensions capability in our Microsoft Teams App that has a command which fetch dynamic set of parameters from the bot when invoked from the compose box.
When the user clicks the messaging extension our app receives payload type 'invoke' and name as 'composeExtension/fetchTask'
Our app process the data and in return it responds with a Adaptive card in task with 'type':'continue' and the Adaptive card is having a link to open URL as below
"task": {
"type": "continue",
"value": {
"card": {
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.2",
"body": [{
"type": "ActionSet",
"actions": [{
"type": "Action.OpenUrl",
"title": "Open Facebook",
"url": <URL to open Facebook>
}],
}
]
}
}
}
}
MSTeams shows this card in a task module popup window. When the User click the Action button it open the Facebook page in a new browser tab but the task module popup window is not closed.
Is there anyway to close the task module popup window when the user clicks the Action button ?
Note : We are not using Bot Framework SDK and Microsoft Teams Javascript client SDK.
The only way I know of to do two things on one user action is by using a web based task module.
Do some simple layout with a button. In the click handler use window.open(, "_blank") and when that completes call the microsoftTeams.tasks.submitTask(...) method of the javascript SDK.
this might be late.
But the documentation is wrong try to call the submitTask(data) twice once with data and once without any params submitTask() to close the taskmodule.

How to get all uploads from official artist channels via the youtube data api

I am trying to query youtube for all uploads relating to a channel, but for official artist channels such as: https://www.youtube.com/channel/UC-jHioVmLr8Cb1lFBIZD2hQ/
When I try to make the API call to retrieve the "uploads" playlist, it succeeds, but returns an empty playlist.
Finding the uploads playlist via https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id=UC-jHioVmLr8Cb1lFBIZD2hQ (API key omitted) returns
{
"kind": "youtube#channelListResponse",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/SQbT6DxUQ-PRgTma_VN0xA8OmHE\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/m44G0g4BqX0Af7CaFKoFcqJDqm0\"",
"id": "UC-jHioVmLr8Cb1lFBIZD2hQ",
"contentDetails": {
"relatedPlaylists": {
"uploads": "UU-jHioVmLr8Cb1lFBIZD2hQ",
"watchHistory": "HL",
"watchLater": "WL"
}
}
}
]
}
but retrieving the items in the uploads playlist via https://www.googleapis.com/youtube/v3/playlistItems?playlistId=UU-jHioVmLr8Cb1lFBIZD2hQ&part=id,contentDetails&maxResults=50 returns
{
"kind": "youtube#playlistItemListResponse",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/E0c9LqWjuNHvL-UjCIKS4N9Fn5M\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 50
},
"items": []
}
I would like to be able to just pull the videos that show up from the videos tab, but cannot seem to do that with the api.
The reason why you don't have results is because that YouTube channel (i.e. HRVY) hasn't uploaded videos (yet).
You can check the uploaded videos page from HRVY channel.
There, you can see that no videos are uploaded, but you might wonder: how this is possible if I can see videos on this channel?
Unfortunately, I can't say for sure why this happened, but, if you still wants to retrieve the videos from that channel, retrieve videos from a specific playlist by using the playlistId and not the uploads id.
For example, the "Most Popular" playlist from that channel has its playlistId: PLtz80rG4U0K99mMxPLNFPhwBIKkvzx9x1.

Youtube Analytics API retrieve playlist views

I need to get the view count of a Youtube playlist, so I used this API call https://developers.google.com/youtube/analytics/v1/channel_reports#playlist-reports
I don't know what's the value to pass in filters. I tried isCurated==1;playlist==LLR14ObbzEt-fw00wGkxQznA, but it returned me this :
GET https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DUCR14ObbzEt-fw00wGkxQznA&start-date=2006-12-01&end-date=2015-10-22&metrics=views&filters=isCurated%3D%3D1%3Bplaylist%3D%3DPL7aghK2Vb4MGM1cC2mNLCwwai_uQ7vuyD
200 OK
- Show headers -
{
"kind": "youtubeAnalytics#resultTable",
"columnHeaders": [
{
"name": "views",
"columnType": "METRIC",
"dataType": "INTEGER"
}
]
}
What is wrong?
Perhaps your playlist did not receive any views during that time frame. Keep in mind YouTube analytics only has data starting from 2/1/2014, so it could be that your playlist did not have any views during your specified time frame. I've made similar calls, and it seems that if your playlist has no data for the specified metrics YouTube will simply return an empty row instead of returning 0's.
youtube_analytics = build('youtubeAnalytics','v1', http=http)
end_date=datetime.datetime.now().strftime("%Y-%m-%d")
analytics_query_response = youtube_analytics.reports().query(ids="channel==%s"%channel_id,metrics='views,estimatedMinutesWatched,averageViewDuration,playlistStarts,viewsPerPlaylistStart,averageTimeInPlaylist',start_date='2004-01-01',end_date=end_date,filters="isCurated==1").execute()

Pull public event data from Google Calendar

I may be over thinking this a bit. On my web site, I would like to user certain data from my public google calendar. My plan is to pull it on the server side so I can do things like process it, cache it and format it the way I want.
I've been looking at using the Google Api libraries, but I can't get past any of the authorization hurdles. A service account sounds like what I really want, but I'm having trouble wrapping my head around how that works in this situation.
The old GDATA apis would be ok, but I'm not very keen on using them because they look fairly deprecated at this point by the newer libraries.
Since it is all public data, I'm hoping there is a simpler way to get to the event data that I'm looking for.
In case it matters, my site is Asp.Net (MVC).
Update
Ok, I was definitely way over thinking it. See my answer.
Now that RSS has been removed from Google Calendar, I've been in search of an easy replacement. I dug around and found the following in the Google Calendar API that seems to do the trick: calendar.events.list
Calendar Events List in Google API Explorer is a good place to get started with the different parameters and options - and it'll build you an example request string. You can see that I specified a minimum time of 2/5/2016, sort it by the start time, and show deleted events.
GET https://www.googleapis.com/calendar/v3/calendars/[CALENDAR ID HERE]/events?
orderBy=startTime&showDeleted=true&singleEvents=true&
timeMin=2016-02-05T00%3A00%3A00Z&key={YOUR_API_KEY}
Results are in JSON so you can parse it in your favorite programming language, ASP.NET or whatever. Result looks like:
{
"kind": "calendar#events",
"etag": "\"123456789123456\"",
"summary": "My Public Calendar",
"updated": "2016-01-29T14:38:29.392Z",
"timeZone": "America/New_York",
"accessRole": "reader",
"defaultReminders": [ ],
"items": [ {
"kind": "calendar#event",
"etag": "\"9876543210987654\"",
"id": "sfdljgsdkjgheakrht4sfdjfscd",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=sdgtukhysrih489759sdkjfhwseihty7934hyt94hdorujt3q95uy689u9yhfdgnbiwe5hy",
"created": "2015-07-06T16:21:59.000Z",
"updated": "2015-07-06T16:21:59.329Z",
"summary": "In-Service Day",
"location": "Maui, HI",
"creator": {
"email": "abra#cadabra.com",
"displayName": "Joe Abra"
},
"organizer": {
"email": "cadabra.com_sejhrgtuiwerghwi4hruh#group.calendar.google.com",
"displayName": "My Public Calendar",
"self": true
},
"start": {
"date": "2016-02-08"
},
"end": {
"date": "2016-02-09"
},
"transparency": "transparent",
"iCalUID": "isdt56y784g78ty86tgsfdgh#google.com",
"sequence": 0
},
{
...
}]
}
One good answer to this (the one I'm going with) is to simply use the calendar's public address to get the data. This is an option that I had forgotten about and it works fine for this particular situation.
You can find the url for the data if you go to the settings for a particular calendar and pick the format you want (I went with xml for this situation.)
The data that you get out of this service is very human-reader optimized, but I can make it work for what I'm doing.

Resources