2019年6月4日 星期二

取得Youtube及Vimeo影片的縮圖


Youtube:
各種尺寸解析度的縮圖API (XXX為影片ID):
https://img.youtube.com/vi/XXX/0.jpg
https://img.youtube.com/vi/XXX/1.jpg
https://img.youtube.com/vi/XXX/2.jpg
https://img.youtube.com/vi/XXX/3.jpg
https://img.youtube.com/vi/XXX/default.jpg
https://img.youtube.com/vi/XXX/hqdefault.jpg
https://img.youtube.com/vi/XXX/mqdefault.jpg
https://img.youtube.com/vi/XXX/sddefault.jpg
https://img.youtube.com/vi/XXX/maxresdefault.jpg

回應都為縮圖的網址
--------------------------------------------------------------------------------------------------

Vimeo:
API為 (XXX為影片ID)
http://vimeo.com/api/v2/video/XXX.json

例如:
http://vimeo.com/api/v2/video/336638047.json
回應為

{
    "id": 336638047,
    "title": "Machine Learning",
    "description": "Commissioned piece <br />\nDirector's cut<br />\n<br />\nStarring Thi-Mai Nguyen<br />\n<br />\n<br />\n<br />\nDir: Luke White<br />\nProd: Lauren Tyson<br />\nDOP: Giuseppe Favale<br />\nEditor: Brendan Jenkins<br />\nSound & Music: Mutant Jukebox<br />\nPost: FreeFolk<br />\nArt Dir: James Hamilton",
    "url": "https://vimeo.com/336638047",
    "upload_date": "2019-05-16 13:33:33",
    "thumbnail_small": "http://i.vimeocdn.com/video/783713149_100x75.jpg",
    "thumbnail_medium": "http://i.vimeocdn.com/video/783713149_200x150.jpg",
    "thumbnail_large": "http://i.vimeocdn.com/video/783713149_640.jpg",
    "user_id": 581986,
    "user_name": "Luke White",
    "user_url": "https://vimeo.com/lukewhite",
    "user_portrait_small": "http://i.vimeocdn.com/portrait/31879108_30x30",
    "user_portrait_medium": "http://i.vimeocdn.com/portrait/31879108_75x75",
    "user_portrait_large": "http://i.vimeocdn.com/portrait/31879108_100x100",
    "user_portrait_huge": "http://i.vimeocdn.com/portrait/31879108_300x300",
    "stats_number_of_likes": 403,
    "stats_number_of_plays": 8057,
    "stats_number_of_comments": 20,
    "duration": 110,
    "width": 1920,
    "height": 1080,
    "tags": "dance, ai, robot, artificial intelligence, choreography, experiment, machine learning, mountain, TSO, elbows, technology, computer, limits, dead, falling, woman, playing",
    "embed_privacy": "anywhere"
}

其中的
thumbnail_small
thumbnail_medium
thumbnail_large
就是不同尺寸大小的縮圖網址

參考資料:

  1. How do I get a YouTube video thumbnail from the YouTube API?
  2. Get img thumbnails from Vimeo?

沒有留言 :

張貼留言