Fetch YouTube highest thumbnail resolution

前端 未结 4 1022
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-01 20:36

I want to get youtube highest thumbnail \"maxresdefault.jpg\"

Like this one

http://i.ytimg.com/vi/Cj6ho1-G6tw/maxresdefault.jpg

I\'m using this simple ph

4条回答
  •  既然无缘
    2021-02-01 20:45

    Thanks to Ibrahim Ulukaya's answer I was able to understand why David Chen's previously correct answer no longer works; Google has deprecated that prior working API. (Wicked, bad, naughty, evil, Google.)

    The following URL will return a list of thumbnail objects using the Data API v3:

    https://www.googleapis.com/youtube/v3/videos?id={VIDEO_ID}&key={API_KEY}&part=snippet&fields=items/snippet/thumbnails
    

    The {VIDEO_ID} can be found as part of any YouTube video URL and the {API_KEY} requires you to:

    • First Create a Project
    • Then Enable YouTube's Data API v3 and
    • Finally Create an API key.

    Once you have the URL with your VIDEO_ID and API_KEY substituted for the placeholders you should get back JSON that looks something like this:

    {
     "items": [
      {
       "snippet": {
        "thumbnails": {
         "default": {
          "url": "https://i.ytimg.com/vi/7Ey-Xkwn1s0/default.jpg",
          "width": 120,
          "height": 90
         },
         "medium": {
          "url": "https://i.ytimg.com/vi/7Ey-Xkwn1s0/mqdefault.jpg",
          "width": 320,
          "height": 180
         },
         "high": {
          "url": "https://i.ytimg.com/vi/7Ey-Xkwn1s0/hqdefault.jpg",
          "width": 480,
          "height": 360
         },
         "standard": {
          "url": "https://i.ytimg.com/vi/7Ey-Xkwn1s0/sddefault.jpg",
          "width": 640,
          "height": 480
         },
         "maxres": {
          "url": "https://i.ytimg.com/vi/7Ey-Xkwn1s0/maxresdefault.jpg",
          "width": 1280,
          "height": 720
         }
        }
       }
      }
     ]
    }
    

    From there I am guessing you'll know what to do...?

    Hope this helps.

提交回复
热议问题