get youtube videos listed in subsection of channel's 'videos' - youtube-data-api

How can I get videos listed in an item of the dropdown menu of a channel's 'videos' tab?
Is it a playlist with an ID? If I wanted to get all the uploaded videos, I could first query the id of playlist 'uploads' (here for channel UCj7IJ427cnavyq2ZOpSKYfA):
GET https://youtube.googleapis.com/youtube/v3/channels?part=contentDetails&id=UCj7IJ427cnavyq2ZOpSKYfA&key=[YOUR_API_KEY] HTTP/1.1
{
"kind": "youtube#channelListResponse",
...,
"items": [
{
"kind": "youtube#channel",
...,
"contentDetails": {
"relatedPlaylists": {
"likes": "",
"favorites": "",
"uploads": "UUj7IJ427cnavyq2ZOpSKYfA" # <- here it is!
}
}
}
]
}
and use it to run playlistItems. But what about that 'Upcoming livestreams' part only?

You should use the Search.list API endpoint, invoked with the request parameters channelId, type and eventType set accordingly:
GET https://www.googleapis.com/youtube/v3/search?key=${API_KEY}&type=video&eventType=upcoming&part=snippet&maxResults=50&channelId=${CHANNEL_ID},
where ${CHANNEL_ID} is the ID the the channel of your interest and ${API_KEY} is your API key.
For the channel you mentioned above -- that with ID UCj7IJ427cnavyq2ZOpSKYfA --, the JSON response looked like:
{
"kind": "youtube#searchListResponse",
"etag": "...",
"regionCode": "...",
"pageInfo": {
"totalResults": 4,
"resultsPerPage": 4
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "quPJtDE4C_PAgFJU9QIjA5d_C4k",
"id": {
"kind": "youtube#video",
"videoId": "JksecRTzbgo"
},
"snippet": {
"publishedAt": "2021-05-19T10:33:39Z",
"channelId": "UCj7IJ427cnavyq2ZOpSKYfA",
"title": "LIVE: Т. Владимиров, фортепиано. Бах, Рахманинов, Шуберт",
"description": "Тимофей ВЛАДИМИРОВ, фортепиано В программе: И.С. Бах. Шестиголосный ричеркар из цикла «Музыкальное приношение» Рамо – Годовский.",
"thumbnails": {
...
},
"channelTitle": "MOSCOW INTERNATIONAL PERFORMING ARTS CENTER",
"liveBroadcastContent": "upcoming",
"publishTime": "2021-05-19T10:33:39Z"
}
},
{
"kind": "youtube#searchResult",
"etag": "7LTWdzCS0NDFayU3zbfDcb3xky4",
"id": {
"kind": "youtube#video",
"videoId": "G85Prxi4Mr0"
},
"snippet": {
"publishedAt": "2021-05-25T12:28:10Z",
"channelId": "UCj7IJ427cnavyq2ZOpSKYfA",
"title": "LIVE: Лауреаты IV Конкурса пианистов В. Крайнева в возрастной категории от 16 до 22 лет",
"description": "В День защиты детей Концерт победителей и лауреатов IV Международного конкурса пианистов Владимира Крайнева в возрастной категории от 16 ...",
"thumbnails": {
...
},
"channelTitle": "MOSCOW INTERNATIONAL PERFORMING ARTS CENTER",
"liveBroadcastContent": "upcoming",
"publishTime": "2021-05-25T12:28:10Z"
}
},
{
"kind": "youtube#searchResult",
"etag": "I4FOz2ykBQviPr_7vdF87240iG8",
"id": {
"kind": "youtube#video",
"videoId": "tKDEjh37BrA"
},
"snippet": {
"publishedAt": "2021-05-25T12:01:48Z",
"channelId": "UCj7IJ427cnavyq2ZOpSKYfA",
"title": "LIVE: Лауреаты IV Конкурса пианистов В. Крайнева в возрастной категории от 7 до 12 лет",
"description": "В День защиты детей Концерт победителей и лауреатов IV Международного конкурса пианистов Владимира Крайнева в возрастной категории от 7 до ...",
"thumbnails": {
...
},
"channelTitle": "MOSCOW INTERNATIONAL PERFORMING ARTS CENTER",
"liveBroadcastContent": "upcoming",
"publishTime": "2021-05-25T12:01:48Z"
}
},
{
"kind": "youtube#searchResult",
"etag": "tpF_wpRF43W6fv1MGpNnCBSvCDU",
"id": {
"kind": "youtube#video",
"videoId": "R9Em6BJW0e0"
},
"snippet": {
"publishedAt": "2021-05-25T12:08:55Z",
"channelId": "UCj7IJ427cnavyq2ZOpSKYfA",
"title": "LIVE: Лауреаты IV Конкурса пианистов В. Крайнева в возрастной категории от 13 до 15 лет",
"description": "В День защиты детей Концерт победителей и лауреатов IV Международного конкурса пианистов Владимира Крайнева в возрастной категории от 13 ...",
"thumbnails": {
...
},
"channelTitle": "MOSCOW INTERNATIONAL PERFORMING ARTS CENTER",
"liveBroadcastContent": "upcoming",
"publishTime": "2021-05-25T12:08:55Z"
}
}
]
}
Do note that the Search.list endpoint is relatively expensive: each call of it will cost you 100 units of quota (accounted from your daily quota, which by default is 10000 units).

Related

YouTube Data API Channel.list function

For the channel.list function of the YouTube API are you able to call statistics for any channel on YouTube? Reviewing the below call parameters it seems all require you to be the owner of that channel to receive any information on that channel.
I've also tried the API test to see if I can receive data by username for the channel but doesn't seem to work. Beginner so if anyone could help out I'd much appreciate it!
https://developers.google.com/youtube/v3/docs/channels/list?apix_params=%7B%22forUsername%22%3A%22Peter%20McKinnon%22%7D
You do not need to be the owner of the channel you just need the channel Id. You can tests this using the try me on channel.list its a public api call.
request
GET https://www.googleapis.com/youtube/v3/channels?part=snippet%2CcontentDetails%2Cstatistics&id=UCeY0bbntWzzVIaj2z3QigXg&key=[YOUR_API_KEY] HTTP/1.1
Accept: application/json
response
{
"kind": "youtube#channelListResponse",
"etag": "y2BDT1Qkcr2Fm2FAHjDfG6Gn8Sc",
"pageInfo": {
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "VCwefXyl53bCqIREF0zJeTfxZXk",
"id": "UCeY0bbntWzzVIaj2z3QigXg",
"snippet": {
"title": "NBC News",
"description": "» Subscribe to NBC News:",
"customUrl": "nbcnews",
"publishedAt": "2006-07-19T20:46:03Z",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/a/AATXAJzjPejETKc2lrL43-9gFFWRL9WKwEmOIvtbWyait1c=s88-c-k-c0xffffffff-no-rj-mo",
"width": 88,
"height": 88
},
"medium": {
"url": "https://yt3.ggpht.com/a/AATXAJzjPejETKc2lrL43-9gFFWRL9WKwEmOIvtbWyait1c=s240-c-k-c0xffffffff-no-rj-mo",
"width": 240,
"height": 240
},
"high": {
"url": "https://yt3.ggpht.com/a/AATXAJzjPejETKc2lrL43-9gFFWRL9WKwEmOIvtbWyait1c=s800-c-k-c0xffffffff-no-rj-mo",
"width": 800,
"height": 800
}
},
"localized": {
"title": "NBC News",
"description": "» Subscribe to NBC News: "
}
},
"contentDetails": {
"relatedPlaylists": {
"likes": "",
"favorites": "",
"uploads": "UUeY0bbntWzzVIaj2z3QigXg",
"watchHistory": "HL",
"watchLater": "WL"
}
},
"statistics": {
"viewCount": "1942288925",
"commentCount": "0",
"subscriberCount": "3700000",
"hiddenSubscriberCount": false,
"videoCount": "25734"
}
}
]
}

Combine json response in nifi

We are calling invokehttp processes and getting response which json. Example
{
"id": "h569gcjhcm",
"doi": {
"id": "10.17632/h569gcjhcm.1",
"status": "allocated",
"prefix": "10.17632"
},
"name": "Data for: Flooding of the Caspian Sea at the intensification of Northern Hemisphere Glaciations",
"description": "Supplementary data for the Jeirankechmez section in Azerbaijan.\n\n- Appendix A contains all paleomagnetic data and interpretations of the Jeirankechmez section. This .dir file can be imported into the paleomagnetism.org webportal under \"Interpretation Portal\", \"Advanced Options\", \"Import Application Save\". For further details on the use of paleomagnetism.org please refer to the article by Koymans et al. (2016) - https://doi.org/10.1016/j.cageo.2016.05.007.\n- Appendix B contains the magnetic susceptibility data for the analysed samples, including geographic coordinates and stratigraphic levels.\n- Appendix C contains the 40Ar/39Ar data for the three analysed volcanic ash layers. ",
"version": 1,
"publish_date": "2019-01-29T12:51:38.090Z",
"data_licence": {
"id": "01d9c749-3c4d-4431-9df3-620b2dcfe144",
"short_name": "CC BY 4.0",
"full_name": "Creative Commons Attribution 4.0 International",
"description": "This dataset is licensed under a Creative Commons Attribution 4.0 International licence.\n\nWhat does this mean?\nYou can share, copy and modify this dataset so long as you give appropriate credit, provide a link to the CC BY license, and indicate if changes were made, but you may not do so in a way that suggests the rights holder has endorsed you or your use of the dataset. Note that further permission may be required for any content within the dataset that is identified as belonging to a third party.",
"url": "http://creativecommons.org/licenses/by/4.0",
"category": "Creative"
},
"contributors": [
{
"first_name": "Christiaan",
"last_name": "van Baak"
},
{
"first_name": "Marius",
"last_name": "Stoica"
},
{
"first_name": "Arjen",
"last_name": "Grothe"
},
{
"first_name": "Gareth",
"last_name": "Davies"
},
{
"profile_id": "72970719-95c8-341b-80d2-afa9e7154baf",
"first_name": "Wout",
"last_name": "Krijgsman"
},
{
"profile_id": "3a4bfe2c-4098-3859-9b88-789fa993e05a",
"first_name": "Keith",
"last_name": "Richards"
},
{
"profile_id": "f1660f3c-ebbd-3289-8240-1f4ea7913df4",
"first_name": "Klaudia",
"last_name": "Kuiper"
},
{
"first_name": "Elmira",
"last_name": "Aliyeva"
}
],
"versions": [
{
"version": 1,
"publish_date": "2019-01-29T12:51:38.090Z",
"available": true
}
],
"files": [
{
"filename": "Appendix_A_Jeirankechmez_pmag_interpretations.dir",
"id": "f2f4cba7-2411-4737-a9b2-f094db30dca1",
"content_details": {
"id": "994bc865-5300-4d76-a373-e528ccd830e8",
"sha256_hash": "2427c4b077372760973ce8224694f2a2ee5383c7f022ad818164d847a20e27cc",
"sha1_hash": "73792dc6d6eb2c1de1e04926ba5d4420dd0aaece",
"content_type": "application/x-director",
"size": 917022,
"created_date": "2019-01-03T00:00:00.000Z"
"download_expiry_time": "2019-01-29T13:52:25.729Z"
},
"metrics": {
"downloads": 0,
"previews": 0
}
},
{
"filename": "Appendix_B_Sample_locations_susceptibility.xlsx",
"id": "64241bf0-5279-49e8-a505-be9075b910e1",
"content_details": {
"id": "af8809d0-8e63-4599-abaa-e7af9ad39959",
"sha256_hash": "0588f44a0cbd477aa2798323e57ce0b2d4a118e767c0b1ffdc9eb1017e4d23c2",
"sha1_hash": "02e89f6f197ebf495e1e2c3d1aab250efc7545e7",
"content_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"size": 24770,
"created_date": "2019-01-03T00:00:00.000Z"
,
"download_expiry_time": "2019-01-29T13:52:25.732Z"
},
"metrics": {
"downloads": 0,
"previews": 0
}
},
{
"filename": "Appendix_C_ArAr_data.xlsx",
"id": "2e912027-ff3f-48ad-98b9-b643b59ba0e3",
"content_details": {
"id": "4960377c-060d-41f6-b7af-150617d8ebeb",
"sha256_hash": "235dc32c1e99f350ee5c99908a5f5d72d1aeeab02f78c2e0181d585bd1880fa6",
"sha1_hash": "6483156e4577948cac5d2679eee862c76faed1c9",
"content_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"size": 18510,
"created_date": "2019-01-03T00:00:00.000Z"
},
"metrics": {
"downloads": 0,
"previews": 0
}
}
],
"articles": [
{
"id": "10.1016/j.gloplacha.2019.01.007",
"title": "Flooding of the Caspian Sea at the intensification of Northern Hemisphere Glaciations",
"doi": "10.1016/j.gloplacha.2019.01.007",
"journal": {
"issn": "0921-8181",
"name": "Global and Planetary Change",
"url": "http://www.sciencedirect.com/science/journal/09218181"
}
}
],
"categories": [
{
"id": "http://com/vocabulary/OmniScience/Concept-170590667",
"label": "Geology"
},
{
"id": "http://data.elsevier.com/vocabulary/OmniScience/Concept-473860195",
"label": "Strontium Isotope"
}
],
"institutions": [ ],
"metrics": {
},
"available": true,
"related_links": [ ]
}
I am using $contributors.profile_id from above json to call new endpoint(invokeshttp) (https://api.xxx.com/profile/$.profile_id)
Json response for this
"contributors": [
{
“profile_id”:”cedferfiherhforhforf”
"first_name": “xxx”,
"last_name": "van Baak”,
“other_ids”:[] ,
“Other info”: “deeded” }
I have to call this endpoint depending upon number of object in contributor(let say we have 5 object in contributor ,so I have to call this endpoint 5 time)and combine these 5 response together
Then I have to merge the response(above response to the main response )
just an example:
EvaluateJsonPath to extract "id" into attribute, later join by this attribute
SplitJson to split your json by "contributors"
call endpoint
MergeContent merge by "id" and with count after SplitJson

Botframework AdaptiveCard is losing the “actions” node over directline

I'm using the botframework C# with directlinejs to build my bot.
Recently I've noticed that my bot stoped working and I just find out that the problem is that the directline/botconnector or something in the middle is losing the "actions" node of my AdaptiveCard over directline. Here is the message that my bot (server) is sending to the client (botconnector and directlinejs).
{
"$type": "Microsoft.Bot.Connector.Activity, Microsoft.Bot.Connector",
"type": "message",
"timestamp": "2018-04-19T17:57:14.565727+00:00",
"serviceUrl": "https://directline.botframework.com/",
"channelId": "directline",
"from": {
"$type": "Microsoft.Bot.Connector.ChannelAccount, Microsoft.Bot.Connector",
"id": "Toro#Q7xWzEtd_lk",
"name": "Toro Assistant"
},
"conversation": {
"$type": "Microsoft.Bot.Connector.ConversationAccount, Microsoft.Bot.Connector",
"id": "CfAgYrLQOuv9fDMPnfINDG"
},
"recipient": {
"$type": "Microsoft.Bot.Connector.ChannelAccount, Microsoft.Bot.Connector",
"id": "anonymous",
"name": "anonymous"
},
"text": "",
"attachments": {
"$type": "System.Collections.Generic.List`1[[Microsoft.Bot.Connector.Attachment, Microsoft.Bot.Connector]], mscorlib",
"$values": [
{
"$type": "Microsoft.Bot.Connector.Attachment, Microsoft.Bot.Connector",
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"$type": "AdaptiveCards.AdaptiveCard, AdaptiveCards",
"type": "AdaptiveCard",
"version": "1.0",
"body": {
"$type": "System.Collections.Generic.List`1[[AdaptiveCards.AdaptiveElement, AdaptiveCards]], mscorlib",
"$values": [
{
"$type": "AdaptiveCards.AdaptiveTextBlock, AdaptiveCards",
"type": "TextBlock",
"text": "Não se preocupe, cadastrar um novo número é muito fácil. É só clicar no botão abaixo.\r\n\r\n"
}
]
},
"actions": {
"$type": "System.Collections.Generic.List`1[[AdaptiveCards.AdaptiveAction, AdaptiveCards]], mscorlib",
"$values": [
{
"$type": "AdaptiveCards.AdaptiveOpenUrlAction, AdaptiveCards",
"type": "imBack",
"url": "http://toroinvestimentos.com.br/minhaconta/emailecelular/edit?q=phone&token=token",
"title": "Falar com Assessor"
},
{
"$type": "AdaptiveCards.AdaptiveSubmitAction, AdaptiveCards",
"type": "imBack",
"data": "Mudar de assunto",
"title": "Mudar de assunto",
"image": "https://toro.azureedge.net/bot/icon_list_default.svg"
}
]
},
"style": "ToroCard1"
}
}
]
},
"entities": {
"$type": "System.Collections.Generic.List`1[[Microsoft.Bot.Connector.Entity, Microsoft.Bot.Connector]], mscorlib",
"$values": []
},
"replyToId": "CfAgYrLQOuv9fDMPnfINDG|0000011"
}
And here is the message that the botconnector/directlinejs is delivering to the client:
{
"type": "message",
"id": "CfAgYrLQOuv9fDMPnfINDG|0000012",
"timestamp": "2018-04-19T17:57:14.9161386Z",
"localTimestamp": "2018-04-19T17:57:14.6134302+00:00",
"channelId": "directline",
"from": {
"id": "Toro",
"name": "Toro Assistant"
},
"conversation": {
"id": "CfAgYrLQOuv9fDMPnfINDG"
},
"text": "",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "Não se preocupe, cadastrar um novo número é muito fácil. É só clicar no botão abaixo.\r\n\r\n"
}
],
"style": "ToroCard1"
}
}
],
"entities": [],
"replyToId": "CfAgYrLQOuv9fDMPnfINDG|0000011"
}
Note that the "Actions" node of my message was croped by something in the middle (botconnector or directlinejs, I don't know).
Could anyone help me ?
I'm using the following version o botframework libs:
Microsoft.Bot.Builder version="3.14.1.1"
Microsoft.Bot.Connector" version="3.14.1.1"
"type": "imBack" is not a valid AdaptiveAction type.
For AdaptiveOpenUrlAction it should be "Action.OpenUrl" https://github.com/Microsoft/AdaptiveCards/blob/6700649f154cf12da6d02e063325b396026993c6/source/dotnet/Library/AdaptiveCards/AdaptiveOpenUrlAction.cs#L24
For AdaptiveSubmitAction it should be “Action.Submit” https://github.com/Microsoft/AdaptiveCards/blob/6700649f154cf12da6d02e063325b396026993c6/source/dotnet/Library/AdaptiveCards/AdaptiveSubmitAction.cs#L22
I did a test with the following sample code to send AdaptiveCard, and in my directjs client, I can find the actions node in message entity. So I suggested for sharing your code in my earlier comment.
In my bot application:
var replymes = context.MakeMessage();
AdaptiveCard card = new AdaptiveCard();
// Add text to the card.
card.Body.Add(new TextBlock()
{
Text = "This is an Adaptive Card",
Size = TextSize.Large,
Weight = TextWeight.Bolder
});
// Add buttons to the card.
card.Actions.Add(new OpenUrlAction()
{
Url = "http://foo.com",
Title = "Link1"
});
// Create the attachment.
Attachment attachment = new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = card
};
replymes.Attachments.Add(attachment);
Console.WriteLine(card.ToString());
await context.PostAsync(replymes);
In directlinejs client, message entity contains actions node:
Besides, as Eric Dahlvang mentioned, "type": "imBack" is not a valid AdaptiveAction type. If we explicitly specify the type to "imBack", like below:
card.Actions.Add(new OpenUrlAction()
{
Url = "http://foo.com",
Title = "Link1",
Type= "imBack"
});
The actions node will miss in message entity:

How to use YouTube API to check if a video is restricted?

When embedding this YouTube video for example, we get This video contains content from... who has blocked it from display on the website error message.
How can I use the API to find if a video is blocked or not?
The nearest parameters I found are status and contentDetails:
GET https://www.googleapis.com/youtube/v3/videos?part=status&id=dYQ2IyMuPes&key={YOUR_API_KEY}
Which returns no indication about the restriction:
"contentDetails": {
"duration": "PT2M",
"dimension": "2d",
"definition": "hd",
"caption": "false",
"licensedContent": true,
"projection": "rectangular"
},
"status": {
"uploadStatus": "processed",
"privacyStatus": "public",
"license": "youtube",
"embeddable": true,
"publicStatsViewable": false
}
Check if it is restricted in the region contentDetails.regionRestriction or age-restricted content contentDetails.contentRating or content claimed by partner contentDetails.licensedContent? I am just speculating here too.
Edit: You can use this to check if it is embeddable too status.embeddable.
Be sure to have the "part" set correctly. It's a required field and you probably have "snippet there" and you need "contentDetails". (or "snippet,contentDetails" for both)
Example:
GET https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=OoKpYXTmYak&key={YOUR_API_KEY}
{
"kind": "youtube#videoListResponse",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/Xn7P-qyclepPOIFp9Bn69FdtR-4\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/_vu8XkjotVqxtJKQ2peTcRK8TYE\"",
"id": "OoKpYXTmYak",
"contentDetails": {
"duration": "PT1M41S",
"dimension": "2d",
"definition": "hd",
"caption": "false",
"licensedContent": true,
"regionRestriction": {
"allowed": [
"ES",
"US"
]
},
"projection": "rectangular"
}
}
]
}
This is allowed in the US and Spain only

How to get filtered activity stream using Yammer API?

Yammer Activity Stream is available at:
https://www.yammer.com/api/v1/streams/activities.json?access_token=
This successfully results in all the recent activities like:
{
"items": [
{
"id": "/users/www.yammer.com-341514-1508953644/rollups/45191477209921-45191477209921",
"unseen": true,
"icon": "/images/notifications/page_add.png",
"icon_name": null,
"category": "file-create",
"message": "[[user:1508783078]] uploaded [[uploaded_file:24511980]].",
"heading": "",
"created_at": "2014/10/02 07:07:42 +0000",
"objects": [],
"actions": [],
"subject": {
"type": "uploaded_file",
"id": 24511980
},
"meta": null,
"client_type": "unknown",
"client_url": "https://www.yammer.com",
"client_icon": "https://mug0.assets-yammer.com/mugshot/images/16x16/3rd_party.png",
"client_large_icon": "https://mug0.assets-yammer.com/mugshot/images/75x75/3rd_party.png",
"image": "https://mug0.assets-yammer.com/mugshot/images/48x48/no_photo.png",
"third_party": false
},
{
"id": "/users/www.yammer.com-341514-1508953644/rollups/45191475863746-45191475863746",
"unseen": true,
"icon": "/images/notifications/page_add.png",
"icon_name": "page",
"category": "file-download",
"message": "[[user:1508783078]] downloaded [[uploaded_file:24373320]] from the [[group:3455089]] group.",
"heading": "",
"created_at": "2014/10/02 07:07:00 +0000",
"objects": [
{
"id": 24373320,
"type": "uploaded_file"
}
],
"actions": [],
"subject": {
"type": "uploaded_file",
"id": 24373320
},
"meta": null,
"client_type": "unknown",
"client_url": "https://www.yammer.com",
"client_icon": "https://mug0.assets-yammer.com/mugshot/images/16x16/3rd_party.png",
"client_large_icon": "https://mug0.assets-yammer.com/mugshot/images/75x75/3rd_party.png",
"image": "https://mug0.assets-yammer.com/mugshot/images/48x48/no_photo.png",
"third_party": false
},
]}
QUESTION:
I am trying to get all the recent activities after a certain time-stamp or after a certain offset. Is there any query parameter for that?
this is
older_than="/users/www.yammer.com-341514-1508953644/rollups/45191475863746-45191475863746"
that would return all the activities older than the last activities you shew in your sample return value

Resources