Youtube Data API V3 - 没有视频网址 [英] Youtube Data API V3 - No Video url

查看:33
本文介绍了Youtube Data API V3 - 没有视频网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 youtube 数据 api 版本 3,以获取热门 youtube 视频,我像这样调用 REST api:

I am using youtube data api version 3, to get the top youtube videos, i am calling the REST api like this:

https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?part=snippet&forMine=true&maxResults=10&order=viewCount&type=video&_h=6&

并得到这样的数据是json格式:

and get the data like this is json format:

"kind": "youtube#searchResult",
"etag": "adasdasdasdasdas",
"id": 
{
  "kind": "youtube#video",
  "videoId": "123123asdsad12"
},
"snippet": 
{
  "publishedAt": "date",
  "channelId": "Gasdqqweqweqwr123123",
  "title": "my tutle",
  "description": "xyz",
  "thumbnails": 
  {
    "default": 
    {
      "url": "......jpg",
      "width": 120,
      "height": 90
    },
    "medium": 
    {
      "url": "......jpg",
      "width": 320,
      "height": 180
    },
    "high": 
    {
      "url": "......jpg",
      "width": 480,
      "height": 360
    }
  },
  "liveBroadcastContent": "none"
}

但是这个数据不包含youtube视频网址,我如何从api获取它?

but this data do not contain youtube video url, how can i obtain it from the api?

推荐答案

您可以像这样设置视频网址:

You can have the video url like this :

结果出来了:

     "kind": "youtube#searchResult",
"etag": "\"adasdasdasdasdas"",
"id": {
"kind": "youtube#video",
"videoId": "123123asdsad12"
},
...

现在你得到字段 "videoId": "123123asdsad12"

您可以通过链接访问视频:

And you can acces to the video via the link:

https://www.youtube.com/watch?v=123123asdsad12

就是这样!

这篇关于Youtube Data API V3 - 没有视频网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆