dongnai6973 2019-07-19 09:39
浏览 190

如何使用Youtube Go API获取视频信息?

I simply want to do something like:

curl "https://www.googleapis.com/youtube/v3/videos?id=${ID}&part=snippet&key=${KEY}"

With the Go API to figure out the date of an uploaded video. However after pouring over https://godoc.org/google.golang.org/api/youtube/v3 and the reference, I frustratingly can't figure out how to do this basic task.

I can see VideoSnippet in the godoc, but I don't know how to discover what call returns that.

  • 写回答

2条回答 默认 最新

  • douzhicui2209 2019-07-19 14:47
    关注

    Use /youtube/v3/videos (to search) with query parameter part=snippet. Each returned item will contain a snippet object with the publish date.

    {
        "kind": "youtube#videoListResponse",
        "etag": "\"Bdx4f4ps3xCOOo1WZ91nTLkRZ_c/Eemxf1NUP9tlqRv5dvxAjeicTjI\"",
        "pageInfo": {
            "totalResults": 1,
            "resultsPerPage": 1
        },
        "items": [{
    
                "kind": "youtube#video",
                "etag": "\"Bdx4f4ps3xCOOo1WZ91nTLkRZ_c/tq9JVgQy7-68z3ESgWpT0bHx5BE\"",
                "id": "9bZkp7q19f0",
                "snippet": {
                    "publishedAt": "2012-07-15T07:46:32.000Z",
                    ...
    

    Example with curl + jq ❤:

    $ curl "https://www.googleapis.com/youtube/v3/videos?part=snippet&id=9bZkp7q19f0&key=$KEY" -s | jq -r '.items[0].snippet.publishedAt'
    2012-07-15T07:46:32.000Z
    
    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)