How to get a youtube playlist thumbnail?

后端 未结 3 1850
梦如初夏
梦如初夏 2021-02-20 00:09

Is there a way to get youtube playlist thumbnail like how you can get a thumbnail of a video, explained here: How do I get a YouTube video thumbnail from the YouTube API?

3条回答
  •  广开言路
    2021-02-20 00:28

    With the YouTube API v3, you can get the playlist thumbnail using their v3/playlists endpoint and drilling down to items.snippet.thumbnails.high.url

    For the following playlist:

    https://www.youtube.com/playlist?list=PL50C17441DA8A565D

    YouTube's API explorer has a playlist endpoint:

    https://developers.google.com/youtube/v3/docs/playlists/list

    This is the API call:

    GET https://www.googleapis.com/youtube/v3/playlists?part=snippet&id=PL50C17441DA8A565D&key={YOUR_API_KEY}

    And here is the response:

        {
         "kind": "youtube#playlistListResponse",
         "items": [
          {
           "kind": "youtube#playlist",
           "id": "PL50C17441DA8A565D",
           "snippet": {
            "title": "Jay Chou Playlist",
            "thumbnails": {
             "default": {
              "url": "https://i.ytimg.com/vi/kGbDymJ75PU/default.jpg",
              "width": 120,
              "height": 90
             },
             "medium": {
              "url": "https://i.ytimg.com/vi/kGbDymJ75PU/mqdefault.jpg",
              "width": 320,
              "height": 180
             },
             "high": {
              "url": "https://i.ytimg.com/vi/kGbDymJ75PU/hqdefault.jpg",
              "width": 480,
              "height": 360
             }
            },
            "channelTitle": "it23"
           }
          }
         ]
        }
    

提交回复
热议问题