获取 youtube 动画缩略图 [英] Get youtube animated thumbnail

查看:41
本文介绍了获取 youtube 动画缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将来自 youtube 的动画缩略图嵌入我的网站?我说的不是静态缩略图,而是看起来像大约 3 秒的动画 .gif 的缩略图.

解决方案

截至 2019 年 6 月:

1.获取静态缩略图很简单

  • 它们通过 YouTube API 公开,更棒的是,它们遵循非常简单和统一的 URL 结构(更多详细信息

    动画缩略图的网址如下所示:

    https://i.ytimg.com/an_webp/zdOmNiXvM3w/mqdefault_6s.webp?du=3000&sqp=CPDloOgF&rs=AOn4CLD9rYflZAMK6qBIbYJDoQZLk9UARw

    4.据我所知,目前无法以编程方式(无需网页抓取)获取动画缩略图

    • 换句话说,给定一个视频 ID,目前无法通过 API 或定义的 URL 模式获取动画缩略图 URL.
    <小时>

    PS.:希望有人能证明我在第 4 点上是错的,以下是这些 URL 的一些示例:

    https://i.ytimg.com/an_webp/zdOmNiXvM3w/mqdefault_6s.webp?du=3000&sqp=CPDloOgF&rs=AOn4CLD9rYflZAMK6qBIbYJDoQZLk9UARw

    https://i.ytimg.com/an_webp/oIIDZq4nZpo/mqdefault_6s.webp?du=3000&sqp=CLyqoegF&rs=AOn4CLD9DyqMoxBTiOPTUX8FQJmUfiu8NA

    https://i.ytimg.com/an_webp/X9tU8ybzcFs/mqdefault_6s.webp?du=3000&sqp=CLHroOgF&rs=AOn4CLAX8j6uWUko_54aPJLwkbAe_cUR3w

    更改视频 ID 或其他参数不会返回有效的缩略图.

    Is there a way to embed the animated thumbnail from youtube in my website? I am not talking about the static thumbnail but the one that looks like an animated .gif of about 3 seconds.

    解决方案

    As of June 2019:

    1. Getting static thumbnail images is straightforward

    • They're exposed through the YouTube API and, even better, they follow a very simple and uniform URL structure (more details here).

    2. Youtube's animated thumbnails are supported in a limited number of browsers.

    • Apparently, desktop browsers Chrome and Opera (source)
    • The thumbnails, btw, are in WebP image format, which has a wider browser support.

    3. Getting animated thumbails for a limited number of videos is relatively easy.

    You can, for example, inspect the network activity in your browser dev tools (more details for Chrome).

    With the network panel open, visit a page listing that includes the desired video, clear the network activity (you can also select 'Img' to display only activity related to images) and hover the desired video. Then just right click on the desired resource and copy the url.

    In case an image helps...

    The urls of the animated thumbnails look like the following:

    https://i.ytimg.com/an_webp/zdOmNiXvM3w/mqdefault_6s.webp?du=3000&sqp=CPDloOgF&rs=AOn4CLD9rYflZAMK6qBIbYJDoQZLk9UARw

    4. As far as I know, it is currently not possible to get the animated thumbnails programmatically (without webscraping)

    • In other words, given a video ID, it is currently not possible to get the animated thumbnail URL through the API or a defined URL pattern.

    PS.: Hoping that somebody can prove me wrong on point #4, here are a few examples of those URLs:

    https://i.ytimg.com/an_webp/zdOmNiXvM3w/mqdefault_6s.webp?du=3000&sqp=CPDloOgF&rs=AOn4CLD9rYflZAMK6qBIbYJDoQZLk9UARw

    https://i.ytimg.com/an_webp/oIIDZq4nZpo/mqdefault_6s.webp?du=3000&sqp=CLyqoegF&rs=AOn4CLD9DyqMoxBTiOPTUX8FQJmUfiu8NA

    https://i.ytimg.com/an_webp/X9tU8ybzcFs/mqdefault_6s.webp?du=3000&sqp=CLHroOgF&rs=AOn4CLAX8j6uWUko_54aPJLwkbAe_cUR3w

    Changing the video ID or other parameters does not return a valid thumbnail.

    这篇关于获取 youtube 动画缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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