Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
528 views
in Technique[技术] by (71.8m points)

javascript - How to retrieve a YouTube video's tags with YouTube v3 API?

I want to retrieve the tags for a specific YouTube video using v3 of the YouTube API.

I'm able to retrieve a video with this request to the search endpoint, https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=1&q=cats&type=video&key={YOUR_API_KEY}.

Now I hit the video endpoint trying to get the tags for the video from the above query. https://www.googleapis.com/youtube/v3/videos?id=IytNBm8WA1c&part=snippet&key={YOUR_API_KEY}

Response,

{
 "kind": "youtube#videoListResponse",
 "etag": ""PMn2rAVTRiZHkX45qiqfcLZoTXM/rYBuk4KeZFmSMoiSuaXfy6-Pm28"",
 "items": [
  {

   "id": "IytNBm8WA1c",
   "kind": "youtube#video",
   "etag": ""PMn2rAVTRiZHkX45qiqfcLZoTXM/_6K6Qz8rLYf0d5gUnucV1LwbwU4"",
   "snippet": {
    "publishedAt": "2007-07-09T14:02:03.000Z",
    "channelId": "UCFMV3DqmnaRc4oNGvi-3OvQ",
    "title": "Funny Cats",
    "description": "it's soo funny :D

audio content is licensed by UMG

Song 1: Gioachino Rossini - The Thieving Magpie  0:00 - 1:37
Song 2: The Presidents of the United States of America - Kitty  1:38 - 2:47
Song 3: The Nutcracker  2:48 - 3:51
Song 4: Smash Mouth - All Star  3:51 - 7:06
Song 5: The Wiseguys - Ooh La La  7:07 - 7:43

PS: i will ignore messages with the subject
"Business Proposal Regarding Your YouTube Videos"",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/IytNBm8WA1c/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/IytNBm8WA1c/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/IytNBm8WA1c/hqdefault.jpg"
     }
    },
    "channelTitle": "nguoap",
    "categoryId": "15"
   }
  }
 ]
}

API Explorer for this request - https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.videos.list?id=IytNBm8WA1c&part=snippet&_h=3&

Even if I authorize this request I get the same results. Although, if the account being authorized owns the video it returns the tags.

How can I get the tags for the videos I own without asking the end-user to authorize their accounts? This implementation is client side with JS.

UPDATE: GData Issue Link: https://code.google.com/p/gdata-issues/issues/detail?id=4513

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

According to https://developers.google.com/youtube/v3/docs/videos/list it appears that the latest version of the YouTube API now returns tags:

https://www.googleapis.com/youtube/v3/videos?key={API-key}&fields=items(snippet(title,description,tags))&part=snippet&id={video_id}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...