获取 youtube 动画缩略图

编程入门 行业动态 更新时间:2024-10-22 15:38:09
本文介绍了获取 youtube 动画缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

解决方案

截至 2019 年 6 月:

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

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

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

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

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

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

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

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

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

    i.ytimg/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:

    i.ytimg/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:

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

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

    i.ytimg/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 动画缩略图

本文发布于:2023-06-04 19:11:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/503381.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缩略图   动画   youtube

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!