我想嵌入国内主流视频网站如 youku,tudou 等的视频,如何得到视频的缩略图?我觉得这应该是一个挺普遍的问题吧。
不要那种扒视频网址页面代码的方法,谢谢!
#1 楼 @loveky 谢谢!你可以在 youku 视频页面里查看转发到百度贴吧的代码,里面有包含缩略图的地址,比如&pic=http://g1.image....
但是我不喜欢这种临时做法,难道只有通过申请网站 API 这个唯一办法?
http://v.youku.com/player/getPlayList/VideoIDS/#sid}{ 这样就能获取优酷视频各种信息,包括视频缩略图,还不用申请 api,具体的可以看https://github.com/soimort/you-get 这个项目包含大部分视频网站
6 楼说的是那个 API,比如http://v.youku.com/player/getPlayList/VideoIDS/XNTgxNzIyOTky (XNTgxNzIyOTky 为视频 id)
{"data":[{"ct":"a","cs":"2148","logo":"http:\/\/g3.ykimg.com\/1100401F4651DE818EEAE209581D74681469E5-BF66-C21C-01BD-593A395FA8DB","seed":9195,"tags":["\u5e38\u56de\u5bb6\u770b\u770b","\u7ed3\u5a5a","\u538b\u529b\u5927","\u8857\u8bbf","\u7ed3\u5a5a\u96be","\u4e09\u5341\u4e0d\u5a5a","\u6124\u6012\u8001\u5927\u7237","\u8be5\u5224\u5211\uff01","\u5f97\u7ed9\u5047"],"categories":"91","videoid":"145430748","vidEncoded":"XNTgxNzIyOTky","username":"\u8857\u8bbf\u5fae\u8c03\u67e5","userid":"156769652","title":"\u201c\u4e09\u5341\u4e0d\u5a5a \u8be5\u5224\u5211\u201d\uff0c\u201c\u6cd5\u5f8b\u201d\u7816\u5bb6\u5927\u653e\u53a5\u8bcd","up":0,"down":0,"ts":"qmGG5jLvnoE4tanfAdKzVZs","tsup":"qmGCjjHvnoE4tanfArq3VZs","preview":{"thumbs":["0521000151DE94AE6A07CB7FF80C452D"],"sectiontime":"6000","host":"http:\/\/g3.ykimg.com\/"},"key1":"bd7264e4","key2":"a92a41f0b448fe90","tt":"0","videoSource":"1","seconds":"175.96","streamfileids":{"hd2":"3*35*3*3*3*16*3*16*3*3*53*16*11*17*52*32*55*16*16*52*28*17*3*52*53*55*16*11*62*32*6*35*16*66*35*38*32*32*45*16*11*62*35*45*35*38*16*35*45*17*16*55*39*45*66*6*32*46*32*53*46*46*11*6*55*53*","mp4":"3*35*3*3*3*55*3*16*3*3*53*16*11*17*52*35*3*55*16*52*28*17*3*52*53*55*16*11*62*32*6*35*16*66*35*38*32*32*45*16*11*62*35*45*35*38*16*35*45*17*16*55*39*45*66*6*32*46*32*53*46*46*11*6*55*53*","flv":"3*35*3*3*3*28*3*16*3*3*53*16*11*17*62*39*11*38*16*52*28*17*3*52*53*55*16*11*62*32*6*35*16*66*35*38*32*32*45*16*11*62*35*45*35*38*16*35*45*17*16*55*39*45*66*6*32*46*32*53*46*46*11*6*55*53*"},"segs":{"hd2":[{"no":0,"size":"26167788","seconds":"176","k":"1a5c8211996631f42828c141","k2":"1010fa52c98c99519"}],"mp4":[{"no":0,"size":"11979964","seconds":"176","k":"6efdddcb93d53c11261d1c53","k2":"1568d05b751a68a65"}],"flv":[{"no":0,"size":"6223618","seconds":"176","k":"a8a75b5f8ebd386524117765","k2":"171fd540f2774a670"}]},"streamsizes":{"hd2":"26167788","mp4":"11979964","flv":"6223618"},"stream_ids":{"hd2":"146412688","mp4":"146411457","flv":"146392350"},"streamlogos":{"hd2":"1","mp4":"1","flv":"1"},"streamtypes":["hd2","mp4","flv"],"streamtypes_o":["hd2","flvhd","mp4"]}],"user":{"id":"87006333"},"controller":{"search_count":true,"mp4_restrict":1,"stream_mode":1,"video_capture":true,"hd3_enabled":false,"area_code":"","dma_code":"","continuous":0,"playmode":"normal","circle":false,"tsflag":true,"other_disable":false,"share_disabled":false,"download_disabled":false,"pc_disabled":false,"pad_disabled":false,"mobile_disabled":false,"tv_disabled":false}}
里边的 logo 就可以作为缩略图
"logo":"http:\/\/g3.ykimg.com\/1100401F4651DE818EEAE209581D74681469E5-BF66-C21C-01BD-593A395FA8DB"
继续查看一下其他网站如何拿到缩略图,比如新浪视频
#10 楼 @cameo https://github.com/yeeli/getvideo 以前根据 you-get 改成 ruby 的有包含获取缩略图
#12 楼 @ono_li 靠……早没发现啊。我还几乎自己写了一个,get Youku ID 的 这几天正好又在这个问题上弄。也是一样的,大的缩略图的话,调用 logo 那个应该是最棒的了 可以看看这个 php 的源码。我大概看了一下上面的源码,好像就是从这改过去的: http://www.hdj.me/demos/vediourlparser/
另外一个小 tips,也是我今天上午才刚刚使用成功了 可以考虑调用 userscrpits 来去除广告: http://userscripts.org/scripts/show/162286