零零乙 2010-01-14 23:34 采纳率: 33.3%
浏览 595
已采纳

如何从 YouTube API 中获得 YouTube 视频的缩略图?

If I have a YouTube video URL, is there any way to use PHP and cURL to get the associated thumbnail from the YouTube API?

转载于:https://stackoverflow.com/questions/2068344/how-do-i-get-a-youtube-video-thumbnail-from-the-youtube-api

  • 写回答

30条回答 默认 最新

  • 10.24 2010-01-14 23:40
    关注

    Each YouTube video has 4 generated images. They are predictably formatted as follows:

    https://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
    https://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
    https://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
    https://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
    

    The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:

    https://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
    

    For the high quality version of the thumbnail use a url similar to this:

    https://img.youtube.com/vi/<insert-youtube-video-id-here>/hqdefault.jpg
    

    There is also a medium quality version of the thumbnail, using a url similar to the HQ:

    https://img.youtube.com/vi/<insert-youtube-video-id-here>/mqdefault.jpg
    

    For the standard definition version of the thumbnail, use a url similar to this:

    https://img.youtube.com/vi/<insert-youtube-video-id-here>/sddefault.jpg
    

    For the maximum resolution version of the thumbnail use a url similar to this:

    https://img.youtube.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg
    

    All of the above urls are available over http too. Additionally, the slightly shorter hostname i3.ytimg.com works in place of img.youtube.com in the example urls above.

    Alternatively, you can use the YouTube Data API (v3) to get thumbnail images.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(29条)

报告相同问题?

悬赏问题

  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择