이 답변이
YouTube 동영상 ID에서 비디오 타이틀을 얻을 12 월 2015 년 현재 정확한, 당신은 (당신이 API 키를 사용하는 데 필요한 유튜브 데이터 API를 사용하여 다음 URL을 구성해야합니다
https://www.googleapis.com/youtube/v3/videos?part=snippet&id={YOUTUBE_VIDEO_ID}&fields=items(id%2Csnippet)&key={YOUR_API_KEY}
는 GET 요청을 수행하고 아래의 덩어리와 유사한 JSON 응답을 얻을 것이다, 그렇지 않으면 요청이) 실패합니다. 제목은 snippet/title
키에 있습니다.
{
"items":[
{
"id":"Jglv0A0qLI8",
"snippet":{
"publishedAt":"2014-06-30T03:42:20.000Z",
"channelId":"UCdTU5vd37FlTZ-xoB0xzRDA",
"title":"AIA Malaysia - A-Plus Venus Plan - Comprehensive Female Protection and Insurance Plan",
"description":"A comprehensive female protection plan for the modern women\n\nFor more information visit: http://www.aia.com.my/en/individuals/products-and-services/health/a-plus-venus-a-plus-venus-extra.html\n\nFor more products, visit AIA Malaysia's Products and Services playlist:\nhttps://www.youtube.com/playlist?list=PLSrgVT3aQ1fZ3SCe-dEVnFJDApBYkqolP\n\nFor more videos. subscribe to AIA Malaysia's YouTube channel:\nhttps://www.youtube.com/channel/UCdTU5vd37FlTZ-xoB0xzRDA",
"thumbnails":{
"default":{
"url":"https://i.ytimg.com/vi/Jglv0A0qLI8/default.jpg",
"width":120,
"height":90
},
"medium":{
"url":"https://i.ytimg.com/vi/Jglv0A0qLI8/mqdefault.jpg",
"width":320,
"height":180
},
"high":{
"url":"https://i.ytimg.com/vi/Jglv0A0qLI8/hqdefault.jpg",
"width":480,
"height":360
},
"standard":{
"url":"https://i.ytimg.com/vi/Jglv0A0qLI8/sddefault.jpg",
"width":640,
"height":480
},
"maxres":{
"url":"https://i.ytimg.com/vi/Jglv0A0qLI8/maxresdefault.jpg",
"width":1280,
"height":720
}
},
"channelTitle":"AIA Malaysia",
"tags":[
"aia",
"aia malaysia",
"a-plus venus",
"female health insurance",
"female life insurance",
"female insurance",
"female medical insurance"
],
"categoryId":"27",
"liveBroadcastContent":"none",
"localized":{
"title":"AIA Malaysia - A-Plus Venus Plan - Comprehensive Female Protection and Insurance Plan",
"description":"A comprehensive female protection plan for the modern women\n\nFor more information visit: http://www.aia.com.my/en/individuals/products-and-services/health/a-plus-venus-a-plus-venus-extra.html\n\nFor more products, visit AIA Malaysia's Products and Services playlist:\nhttps://www.youtube.com/playlist?list=PLSrgVT3aQ1fZ3SCe-dEVnFJDApBYkqolP\n\nFor more videos. subscribe to AIA Malaysia's YouTube channel:\nhttps://www.youtube.com/channel/UCdTU5vd37FlTZ-xoB0xzRDA"
}
}
}
]
}
자세한 내용은 the API documentation page을 참조하십시오.
https://www.googleapis.com/youtube/v3/videos?part=snippet&id={YOUTUBE_VIDEO_ID}&fields=items(id,snippet)&key={YOUR_API_KEY}
이것에 대해 약간의 사양 : 로버트 심과 cbaigorri의
RegEx 또는 스크린 스크랩을 사용하지 마십시오! API가 모든 것을 처리합니다. – philfreo