YouTube API v3: Can't process file - youtube-api

When trying to upload mp4 video to YT using Data API I get success response (200 OK), but when I check it on YT video manager I see dummy thumbnail with the message: "Upload failed: Can't process file"
video url: http://media.gettyimages.com/videos/portrait-of-gloria-swanson-smoking-cigarette-lying-on-sofa-new-york-video-id95748490
YT API response:
{
"kind": "youtube#video",
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/4fCLHIOBuPZBsvDveLvdRGZ6dfk\"",
"id": "OxctctEBrZk",
"snippet": {
"publishedAt": "2017-05-15T15:16:14.000Z",
"channelId": "UCuHoiSfD2yC-4pKKq9aV0uA",
"title": "UPLOAD video_title",
"description": "yt_video_description",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/OxctctEBrZk/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/OxctctEBrZk/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/OxctctEBrZk/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "Test Social",
"categoryId": "22",
"liveBroadcastContent": "none",
"localized": {
"title": "UPLOAD video_title",
"description": "yt_video_description"
}
},
"contentDetails": {
"duration": "PT0S",
"dimension": "2d",
"definition": "sd",
"caption": "false",
"licensedContent": false,
"projection": "rectangular",
"hasCustomThumbnail": false
},
"status": {
"uploadStatus": "uploaded",
"privacyStatus": "public",
"license": "youtube",
"embeddable": true,
"publicStatsViewable": true
}
Am I missing something?

Related

YouTube Data API search results include videos outside the specified channel

I specified a certain channelId in the YouTube Data API query, but the results include videos from outside that channel:
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCVZyJ-yJ60EZyMXLnIs0_OA&maxResults=5&key={{your key}}
In the results there are items that are not from the channel specified by the parameter channelId in the request:
{
"kind": "youtube#searchListResponse",
"etag": "CqAEn3U3yOet5Dzo4akpnniRK58",
"nextPageToken": "CAUQAA",
"regionCode": "JP",
"pageInfo": {
"totalResults": 8,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "PzY2_uuWT5JXecEOIgv5a4H3RsE",
"id": {
"kind": "youtube#video",
"videoId": "820RgL1fc8g"
},
"snippet": {
"publishedAt": "2019-08-16T10:25:55Z",
"channelId": "UC9FTt8SigjBd2bzzH3QCCVQ",
"title": "薬師寺 新管主への継承法要",
"description": "2019/8/16.",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/820RgL1fc8g/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/820RgL1fc8g/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/820RgL1fc8g/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "奈良テレビチャンネル",
"liveBroadcastContent": "none",
"publishTime": "2019-08-16T10:25:55Z"
}
},
{
"kind": "youtube#searchResult",
"etag": "JIDp4JJTHmn1YL3QpbfG7ZkIhWg",
"id": {
"kind": "youtube#video",
"videoId": "qwmHF5kvfuk"
},
"snippet": {
"publishedAt": "2016-07-04T04:19:41Z",
"channelId": "UCHeX3CiVyozXzcYjLqmkXuQ",
"title": "落合西光寺双盤念仏~5分ver",
"description": "製作…平成27年度埼玉県民俗文化財を活かした地域活性化実行委員会30分verはこちら…https://youtu.be/QcJjlwqNRqk.",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/qwmHF5kvfuk/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/qwmHF5kvfuk/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/qwmHF5kvfuk/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "Hanno City",
"liveBroadcastContent": "none",
"publishTime": "2016-07-04T04:19:41Z"
}
},
{
"kind": "youtube#searchResult",
"etag": "WhRD0hdEdos_8_3sIMnSfKeBOos",
"id": {
"kind": "youtube#channel",
"channelId": "UCVZyJ-yJ60EZyMXLnIs0_OA"
},
"snippet": {
"publishedAt": "2019-03-15T07:18:32Z",
"channelId": "UCVZyJ-yJ60EZyMXLnIs0_OA",
"title": "世田谷デジタルミュージアム",
"description": "",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/ytc/AAUvwninEQgZmbCwRKlSlpaqXerK3i2pXTX2fw0ctyW5=s88-c-k-c0xffffffff-no-rj-mo"
},
"medium": {
"url": "https://yt3.ggpht.com/ytc/AAUvwninEQgZmbCwRKlSlpaqXerK3i2pXTX2fw0ctyW5=s240-c-k-c0xffffffff-no-rj-mo"
},
"high": {
"url": "https://yt3.ggpht.com/ytc/AAUvwninEQgZmbCwRKlSlpaqXerK3i2pXTX2fw0ctyW5=s800-c-k-c0xffffffff-no-rj-mo"
}
},
"channelTitle": "世田谷デジタルミュージアム",
"liveBroadcastContent": "none",
"publishTime": "2019-03-15T07:18:32Z"
}
},
{
"kind": "youtube#searchResult",
"etag": "mGoPgXXCpvtW28-eAzPkxjQ-goc",
"id": {
"kind": "youtube#video",
"videoId": "DgeWR7q2_V4"
},
"snippet": {
"publishedAt": "2014-08-22T05:32:22Z",
"channelId": "UC_kYlv-j7o3j1979t35htzQ",
"title": "双盤念仏(そうばんねんぶつ) 九品仏浄真寺 閻魔堂 平成26年",
"description": "東京都世田谷区にある九品仏浄真寺の閻魔堂で行われた双盤念仏(そうばんねんぶつ)です。 平成26年8月16日(土)撮影.",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/DgeWR7q2_V4/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/DgeWR7q2_V4/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/DgeWR7q2_V4/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "ヒコボン/ohiko2000",
"liveBroadcastContent": "none",
"publishTime": "2014-08-22T05:32:22Z"
}
},
{
"kind": "youtube#searchResult",
"etag": "f6Uukvz6P_iy8eqLdGrIckIzV6w",
"id": {
"kind": "youtube#video",
"videoId": "RPtB3ibF9Mg"
},
"snippet": {
"publishedAt": "2015-10-15T08:42:50Z",
"channelId": "UCH2rOy40BxSSfNZwcCuVGzg",
"title": "平成27年10月13日建長寺僧堂落慶法要",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/RPtB3ibF9Mg/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/RPtB3ibF9Mg/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/RPtB3ibF9Mg/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "建長寺",
"liveBroadcastContent": "none",
"publishTime": "2015-10-15T08:42:50Z"
}
}
]
}

YouTube API filter publishedAfter does not work

This very basic query is responding with wrong results:
https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=10&publishedAfter=2019-01-01T00:00:00Z&key={MY_KEY}
The result set includes items before 2019-01-01T00:00:00Z for the publishedAt field. My application is broken entirely because it relies on this filter. I'm facing the problem after 16 March 2019. Here is the query result:
{
"kind": "youtube#searchListResponse",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/WppcKwINdbdkHMpSM_vz32bjgA4\"",
"nextPageToken": "CAoQAA",
"regionCode": "DE",
"pageInfo": {
"totalResults": 1000000,
"resultsPerPage": 10
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/0LG4Jg0EV14c5UiMLdaaet_v2CM\"",
"id": {
"kind": "youtube#video",
"videoId": "UOxkGD8qRB4"
},
"snippet": {
"publishedAt": "2018-11-03T07:30:00.000Z",
"channelId": "UC2t5bjwHdUX4vM2g8TRDq5g",
"title": "K/DA - POP/STARS (ft Madison Beer, (G)I-DLE, Jaira Burns) | Official Music Video - League of Legends",
"description": "K/DA Ahri, K/DA Evelynn, K/DA Kai'Sa, and K/DA Akali take the world stage with their debut single. Keep the show going on the Rift with these new Epic skins.",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/UOxkGD8qRB4/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/UOxkGD8qRB4/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/UOxkGD8qRB4/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "League of Legends",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/pqPk68pyu4UN0ALIfeVVFhIvYQo\"",
"id": {
"kind": "youtube#video",
"videoId": "m7Bc3pLyij0"
},
"snippet": {
"publishedAt": "2018-09-24T13:58:16.000Z",
"channelId": "UCEdvpU2pFRCVqU6yIPyTpMQ",
"title": "Marshmello ft. Bastille - Happier (Official Music Video)",
"description": "Marshmello ft. Bastille - Happier (Official Music Video) Download / Stream Happier ▷ http://marshmello.lnk.to/happier NEW Mello™ by Marshmello gear SHOP ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/m7Bc3pLyij0/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/m7Bc3pLyij0/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/m7Bc3pLyij0/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "Marshmello",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/JHrxdxyihn5FHm1sbVQJxmw3cJY\"",
"id": {
"kind": "youtube#video",
"videoId": "56WBK4ZK_cw"
},
"snippet": {
"publishedAt": "2018-07-12T18:56:15.000Z",
"channelId": "UCqrBKQHQVEvD2Q9FP0DCP2g",
"title": "benny blanco, Halsey & Khalid – Eastside (official video)",
"description": "\"Eastside\" out now: http://smarturl.it/EastsideBB Directed by Jake Schreier Executive Producers: Jackie Kelman Bisbee, Alex Fisch Line Producer: Molly Gale ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/56WBK4ZK_cw/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/56WBK4ZK_cw/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/56WBK4ZK_cw/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "benny blanco",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/Cic0wO6Ki7l3BEeb2kx0VZtOQeA\"",
"id": {
"kind": "youtube#video",
"videoId": "hHW1oY26kxQ"
},
"snippet": {
"publishedAt": "2018-08-22T19:51:06.000Z",
"channelId": "UCSJ4gkVC6NrvII8umztf0Ow",
"title": "lofi hip hop radio - beats to relax/study to",
"description": "Thank you for listening, I hope you will have a good time here :) New merch available! → Listen to the sleepy lofi hip hop radio ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/hHW1oY26kxQ/default_live.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/hHW1oY26kxQ/mqdefault_live.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/hHW1oY26kxQ/hqdefault_live.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "ChilledCow",
"liveBroadcastContent": "live"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/l7d6Ky2ZMBiEckdYawqigvqGv4w\"",
"id": {
"kind": "youtube#video",
"videoId": "TcMBFSGVi1c"
},
"snippet": {
"publishedAt": "2019-03-14T12:05:18.000Z",
"channelId": "UCvC4D8onUfXzvjTOM-dBfEA",
"title": "Marvel Studios' Avengers: Endgame - Official Trailer",
"description": "Whatever it takes. Watch the brand-new trailer for Marvel Studios' Avengers: Endgame. In theaters April 26. ▻ Learn more: ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/TcMBFSGVi1c/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/TcMBFSGVi1c/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/TcMBFSGVi1c/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "Marvel Entertainment",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/id3uz64VI_Frb6lxlzAYDG8yCuw\"",
"id": {
"kind": "youtube#video",
"videoId": "A2FsgKoGD04"
},
"snippet": {
"publishedAt": "2017-05-25T21:58:58.000Z",
"channelId": "UCRijo3ddMTht_IHyNSNXpNQ",
"title": "Real Life Trick Shots | Dude Perfect",
"description": "Trick shots should be an everyday thing! Thanks to Kingsford for sponsoring this video! ▻ Click HERE to subscribe to Dude Perfect! ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/A2FsgKoGD04/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/A2FsgKoGD04/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/A2FsgKoGD04/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "Dude Perfect",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/1szGxIC2JpHOZayLDDyWY1wRMRg\"",
"id": {
"kind": "youtube#video",
"videoId": "VRJmcxCrAOA"
},
"snippet": {
"publishedAt": "2018-01-22T22:55:24.000Z",
"channelId": "UCRijo3ddMTht_IHyNSNXpNQ",
"title": "Real Life Trick Shots 2 | Dude Perfect",
"description": "Trick shots should be an everyday thing! Thanks to Kay Jewelers for sponsoring this video! Win Valentine's Day by going to http://dudeperfect.com/KayJewelers ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/VRJmcxCrAOA/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/VRJmcxCrAOA/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/VRJmcxCrAOA/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "Dude Perfect",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/KijOZnDfYz96dVXIA2q3FHlMi_E\"",
"id": {
"kind": "youtube#video",
"videoId": "WXBHCQYxwr0"
},
"snippet": {
"publishedAt": "2018-08-27T16:26:25.000Z",
"channelId": "UCOwgc8DswjoBMuuUU2ScPvQ",
"title": "Ava Max - Sweet but Psycho [Official Music Video]",
"description": "\"Sweet but Psycho\" Available Now Download/Stream: https://avamax.lnk.to/SweetButPsychoID Subscribe for more official content from Ava Max: ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/WXBHCQYxwr0/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/WXBHCQYxwr0/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/WXBHCQYxwr0/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "Ava Max",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/0O05twjfC6noThM59R5cemOe1pE\"",
"id": {
"kind": "youtube#video",
"videoId": "hA6hldpSTF8"
},
"snippet": {
"publishedAt": "2018-12-07T13:01:21.000Z",
"channelId": "UCvC4D8onUfXzvjTOM-dBfEA",
"title": "Marvel Studios' Avengers - Official Trailer",
"description": "Part of the journey is the end. ▻ Subscribe to Marvel: --- Follow Marvel on Twitter: ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/hA6hldpSTF8/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/hA6hldpSTF8/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/hA6hldpSTF8/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "Marvel Entertainment",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/_60iD_MRSuskBGiBD0PfKUvmK64\"",
"id": {
"kind": "youtube#video",
"videoId": "rlR4PJn8b8I"
},
"snippet": {
"publishedAt": "2019-03-05T16:00:06.000Z",
"channelId": "UCQzdMyuz0Lf4zo4uGcEujFw",
"title": "Game of Thrones | Season 8 | Official Trailer (HBO)",
"description": "The trailer is here. #GameofThrones The Final Season begins April 14 on HBO.",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/rlR4PJn8b8I/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/rlR4PJn8b8I/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/rlR4PJn8b8I/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "GameofThrones",
"liveBroadcastContent": "none"
}
}
]
}

EXC_BAD_INSTRUCTION on youtube api [duplicate]

This question already has answers here:
What does "Fatal error: Unexpectedly found nil while unwrapping an Optional value" mean?
(16 answers)
Closed 4 years ago.
am getting a playlist video from youtube's api like this:
this is the video class:
https://app.quicktype.io?share=aNLIT2lKl4ecggFJMRhY
and the parsing is like this:
let youtubeData = try JSONDecoder().decode(Video.self, from: data!)
for item in youtubeData.items{
print(item)
self.titles.append(item.snippet.title)
self.ids.append(item.contentDetails.videoID)
self.images.append((item.snippet.thumbnails.standard?.url)!)
}
and the link is:
let link: String = "https://www.googleapis.com/youtube/v3/playlistItems?key=AIzaSyCZD5QOrfmfKKeu2FbiTXzhEEr96Ky6tew&playlistId=PLbJRbIvdAVXRdkBSpA25hugmJy_rOKOYu&part=snippet,contentDetails&maxResults=20"
this what am getting in postman:
{
"kind": "youtube#playlistItemListResponse",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/rADsLSpprHJE-fPnym42pRX8eww\"",
"pageInfo": {
"totalResults": 4,
"resultsPerPage": 50
},
"items": [
{
"kind": "youtube#playlistItem",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/6yrUGyNtxoJ1dmT3Y8sRBJLBeXE\"",
"id": "UExiSlJiSXZkQVZYUmRrQlNwQTI1aHVnbUp5X3JPS09ZdS41NkI0NEY2RDEwNTU3Q0M2",
"snippet": {
"publishedAt": "2018-08-17T02:56:10.000Z",
"channelId": "UCqXAWrjSgLb0EPa_icPt-pw",
"title": "Interview",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/CjNr5Gpa4TE/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/CjNr5Gpa4TE/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/CjNr5Gpa4TE/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/CjNr5Gpa4TE/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/CjNr5Gpa4TE/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "الدوري السعودي للمحترفين Saudi Pro League",
"playlistId": "PLbJRbIvdAVXRdkBSpA25hugmJy_rOKOYu",
"position": 0,
"resourceId": {
"kind": "youtube#video",
"videoId": "CjNr5Gpa4TE"
}
},
"contentDetails": {
"videoId": "CjNr5Gpa4TE",
"videoPublishedAt": "2018-07-28T19:04:42.000Z"
}
},
{
"kind": "youtube#playlistItem",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/9bldgOrkQOmEy3P6x_T4pJiqAss\"",
"id": "UExiSlJiSXZkQVZYUmRrQlNwQTI1aHVnbUp5X3JPS09ZdS4yODlGNEE0NkRGMEEzMEQy",
"snippet": {
"publishedAt": "2018-08-17T02:59:16.000Z",
"channelId": "UCqXAWrjSgLb0EPa_icPt-pw",
"title": "ورشة عمل مراقبي ومنسقي المباريات - اليوم الختامي",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/t-sLCUA68R0/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/t-sLCUA68R0/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/t-sLCUA68R0/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "الدوري السعودي للمحترفين Saudi Pro League",
"playlistId": "PLbJRbIvdAVXRdkBSpA25hugmJy_rOKOYu",
"position": 1,
"resourceId": {
"kind": "youtube#video",
"videoId": "t-sLCUA68R0"
}
},
"contentDetails": {
"videoId": "t-sLCUA68R0",
"videoPublishedAt": "2018-07-28T17:01:42.000Z"
}
},
{
"kind": "youtube#playlistItem",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/Eue448TE2XiiTrzi8vuJICCFqwU\"",
"id": "UExiSlJiSXZkQVZYUmRrQlNwQTI1aHVnbUp5X3JPS09ZdS4wMTcyMDhGQUE4NTIzM0Y5",
"snippet": {
"publishedAt": "2018-08-17T02:59:24.000Z",
"channelId": "UCqXAWrjSgLb0EPa_icPt-pw",
"title": "ورشة عمل مراقبي ومنسقي المباريات - اليوم الأول",
"description": "ملخص اليوم الأول من ورشة عمل مراقبي ومنسقي المباريات والمنسقين الأمنيين والإعلاميين والتي تقيمها الرابطة بالتعاون مع الاتحاد السعودي والاتحاد الآسيوي لكرة القدم",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/tnUz7fLwEBM/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/tnUz7fLwEBM/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/tnUz7fLwEBM/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/tnUz7fLwEBM/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/tnUz7fLwEBM/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "الدوري السعودي للمحترفين Saudi Pro League",
"playlistId": "PLbJRbIvdAVXRdkBSpA25hugmJy_rOKOYu",
"position": 2,
"resourceId": {
"kind": "youtube#video",
"videoId": "tnUz7fLwEBM"
}
},
"contentDetails": {
"videoId": "tnUz7fLwEBM",
"videoPublishedAt": "2018-07-27T17:34:19.000Z"
}
},
{
"kind": "youtube#playlistItem",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/AjA_MynNqIpjpuSN8kJmW7zgDlk\"",
"id": "UExiSlJiSXZkQVZYUmRrQlNwQTI1aHVnbUp5X3JPS09ZdS41MjE1MkI0OTQ2QzJGNzNG",
"snippet": {
"publishedAt": "2018-08-17T02:59:33.000Z",
"channelId": "UCqXAWrjSgLb0EPa_icPt-pw",
"title": "حديث سلمان النمشان عن ورشة عمل مهام مراقبي ومنسقي المباريات والمنسقين الأمنيين والإعلاميين",
"description": "سلمان بن نمشان رئيس لجنة مراقبي ومنسقي المباريات في رابطة الدوري السعودي للمحترفين يتحدث عن أهمية ورشة عمل مراقبي ومنسقي المباريات والمنسقين الأمنيين والإعلاميين والتي تقيمها الرابطة بالتعاون مع الاتحاد السعودي والاتحاد الآسيوي لكرة القدم",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/wIIGgdEa9DU/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/wIIGgdEa9DU/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/wIIGgdEa9DU/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/wIIGgdEa9DU/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/wIIGgdEa9DU/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "الدوري السعودي للمحترفين Saudi Pro League",
"playlistId": "PLbJRbIvdAVXRdkBSpA25hugmJy_rOKOYu",
"position": 3,
"resourceId": {
"kind": "youtube#video",
"videoId": "wIIGgdEa9DU"
}
},
"contentDetails": {
"videoId": "wIIGgdEa9DU",
"videoPublishedAt": "2018-07-27T17:24:59.000Z"
}
}
]
}
but am getting this error:
Thread 2: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
in this line:
when the playlist id is this:
PLSmSEc8Z6liq82OteppRm-koytegaPX2C
.. it's working just fine!
what is the problem? and how to solve this?
In your response item id
"kind": "youtube#playlistItem",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/9bldgOrkQOmEy3P6x_T4pJiqAss\""
hasn't thumbnails>standrad->url path value ( No standrad key )

parse youtube data v3 api

i want to parse the response of youtube api data for v3
the JSON response i got is:
{
"kind": "youtube#playlistItemListResponse",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/l1epVamXLkcsfpr63PWaASmovg4\"",
"nextPageToken": "CAMQAA",
"pageInfo": {
"totalResults": 27,
"resultsPerPage": 3
},
"items": [
{
"kind": "youtube#playlistItem",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/KyN5GfWqc2WFc37j5GcuhThVXig\"",
"id": "UExTbVNFYzhaNmxpcTgyT3RlcHBSbS1rb3l0ZWdhUFgyQy41NkI0NEY2RDEwNTU3Q0M2",
"snippet": {
"publishedAt": "2017-10-03T17:59:36.000Z",
"channelId": "UCuv25YFiKY3NUnuG7q7F3ng",
"title": "أغرب الفرص الضائعة (الجولة 5) من الدوري السعودي",
"description": "تابع مباريات #دوري_جميل مباشرة و حصريا على موقع وتطبيق #دوري_بلس : \n\nhttp://www.dawriplus.com\n\nتويتر : https://twitter.com/dawriplusksa?s=09\n\nانستجرام :http://instagram.com/dawriplusksa\n\nفيس بوك : https://m.facebook.com/DawriPlusKSA/",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/Tdt06VCCko0/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/Tdt06VCCko0/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/Tdt06VCCko0/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/Tdt06VCCko0/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/Tdt06VCCko0/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "دوري بلس",
"playlistId": "PLSmSEc8Z6liq82OteppRm-koytegaPX2C",
"position": 0,
"resourceId": {
"kind": "youtube#video",
"videoId": "Tdt06VCCko0"
}
},
"contentDetails": {
"videoId": "Tdt06VCCko0",
"videoPublishedAt": "2017-10-03T13:32:19.000Z"
}
},
{
"kind": "youtube#playlistItem",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/QHbLatdcFE-i6Pxt5mku-QFX29c\"",
"id": "UExTbVNFYzhaNmxpcTgyT3RlcHBSbS1rb3l0ZWdhUFgyQy4yODlGNEE0NkRGMEEzMEQy",
"snippet": {
"publishedAt": "2018-05-07T17:24:35.000Z",
"channelId": "UCuv25YFiKY3NUnuG7q7F3ng",
"title": "أغرب الفرص الضائعة (الجولة 26) من الدوري السعودي",
"description": "أغرب الفرص الضائعة (الجولة 26) من الدوري السعودي\n\nتابع جميع مباريات الدوري السعودي للمحترفين فقط وحصرياً عبر تطبيق دوري بلس\nhttp://www.dawriplus.com\n\nتويتر : https://twitter.com/dawriplusksa\nانستجرام : http://instagram.com/dawriplusksa\nفيسبوك : https://m.facebook.com/DawriPlusKSA/",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/yegbCi2DcE4/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/yegbCi2DcE4/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/yegbCi2DcE4/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/yegbCi2DcE4/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/yegbCi2DcE4/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "دوري بلس",
"playlistId": "PLSmSEc8Z6liq82OteppRm-koytegaPX2C",
"position": 1,
"resourceId": {
"kind": "youtube#video",
"videoId": "yegbCi2DcE4"
}
},
"contentDetails": {
"videoId": "yegbCi2DcE4",
"videoPublishedAt": "2018-04-17T10:34:50.000Z"
}
},
{
"kind": "youtube#playlistItem",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/3PqM5VVO1MDpiMSOpiLQw3JCoLU\"",
"id": "UExTbVNFYzhaNmxpcTgyT3RlcHBSbS1rb3l0ZWdhUFgyQy4wMTcyMDhGQUE4NTIzM0Y5",
"snippet": {
"publishedAt": "2018-05-07T17:26:13.000Z",
"channelId": "UCuv25YFiKY3NUnuG7q7F3ng",
"title": "أغرب الفرص الضائعة (الجولة 25) من الدوري السعودي",
"description": "أغرب الفرص الضائعة (الجولة 25) من الدوري السعودي\n\nتابع جميع مباريات الدوري السعودي للمحترفين فقط وحصرياً عبر تطبيق دوري بلس\nhttp://www.dawriplus.com\n\nتويتر : https://twitter.com/dawriplusksa\nانستجرام : http://instagram.com/dawriplusksa\nفيسبوك : https://m.facebook.com/DawriPlusKSA/",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/KUzswfTBDBI/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/KUzswfTBDBI/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/KUzswfTBDBI/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/KUzswfTBDBI/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/KUzswfTBDBI/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "دوري بلس",
"playlistId": "PLSmSEc8Z6liq82OteppRm-koytegaPX2C",
"position": 2,
"resourceId": {
"kind": "youtube#video",
"videoId": "KUzswfTBDBI"
}
},
"contentDetails": {
"videoId": "KUzswfTBDBI",
"videoPublishedAt": "2018-04-12T12:13:21.000Z"
}
}
]
}
and i want to access all of the data .. for example how to get title inside the snippet? and the default url thumbnails .. and so on ..
if let videos = receivedResponse["items"] as? [[String: Any]] {
for video in videos{
print(video)
}
}
but i don't know how to get the dictionaries inside the array .. how to parse it further and get every and each element in the json?
Define structs that match the data you're getting (https://app.quicktype.io is a great way to jumpstart this), and then use JSONDecoder to parse the data:
struct YoutubeV3 { ... }
let youtubeData = try JSONDecoder().decode(YoutubeV3.self, from: data)

YouTube LiveBroadcast remove bound stream and transition lifeCycleStatus from "ready" to "live" or "created"

I have an issue with trying to transition a YouTube LiveBroadcast from ready to live. The liveBroadcast looks like this
{
"kind": "youtube#liveBroadcast",
"id": "VALID_ID",
"snippet": {
"publishedAt": "2018-03-12T13:11:52.000Z",
"channelId": "CHANNEL_ID",
"title": "Test",
"description": "Live stream",
"thumbnails": {
"default": {
"url": "URL",
"width": 120,
"height": 90
},
"medium": {
"url": "URL",
"width": 320,
"height": 180
},
"high": {
"url": "URL",
"width": 480,
"height": 360
},
"standard": {
"url": "URL",
"width": 640,
"height": 480
}
},
"scheduledStartTime": "2018-03-12T13:26:23.000Z",
"isDefaultBroadcast": false,
"liveChatId": "LIVE_CHAT_ID"
},
"status": {
"lifeCycleStatus": "ready",
"privacyStatus": "private",
"recordingStatus": "notRecording"
},
"contentDetails": {
"boundStreamId": "BOUND_STREAM_ID",
"boundStreamLastUpdateTimeMs": "2018-03-12T13:26:19.065Z",
"monitorStream": {
"enableMonitorStream": false
},
"enableEmbed": false,
"enableDvr": true,
"enableContentEncryption": false,
"startWithSlate": false,
"recordFromStart": true,
"enableClosedCaptions": false,
"closedCaptionsType": "closedCaptionsDisabled",
"enableLowLatency": true,
"latencyPreference": "low",
"projection": "rectangular",
"enableAutoStart": false
}
I have replaced some private details with constants (but they are all valid).
I want to transition from ready to live which seems simple enough. Unfortunately I receive an error invalidTransition
{
"code" : 403,
"errors" : [ {
"domain" : "youtube.liveBroadcast",
"message" : "Invalid transition",
"reason" : "invalidTransition",
"extendedHelp" : "https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/transition#params"
} ],
"message" : "Invalid transition"
}
This seems very odd and every time I encounter it I wonder why I cannot go from ready to live. At the same time I wonder why I cannot go back to the status created and remove a boundBroadcast.
Anyone know any way to transition to live from this state?

Resources