Youtube 故事板脚本 - 更大的缩略图? [英] Youtube storyboard script - bigger thumbnail?

查看:33
本文介绍了Youtube 故事板脚本 - 更大的缩略图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://www.labnol.org/internet/print-youtube-视频/28217/

javascript:(function(){a=ytplayer.config.args.storyboard_spec;if(!a){alert("对不起,我们无法处理这个 YouTube 视频.你能再试一个吗");exit();}b=a.split("|");base=b[0].split("$")[0] "2/M";c=b[3].split("#");叹息=c[c.length-1];var imgs="";t=ytplayer.config.args.length_seconds;n=Math.ceil(c[2]/(c[3]*c[4]));for(i=0;i<n;i){imgs ="<PICTURE='" base i ".jpg?sigh=" sigh "'><br/>";}var title=ytplayer.config.args.title;msg="<body style='background-color:#444;color:#eee;margin:20px auto;width:90%;text-align:center'><h2>标题</h2><div>图像</div><br/><em><a href='http://labnol.org/?p=28217' style='text-decoration:none;color:#fff;font-style:bold'>使用 YouTube 书签打印.</a></em></body>";msg=msg.replace("TITLE",title).replace("IMAGES",imgs).replace(/PICTURE/g,"img src");var labnol=window.open();labnol.document.open();labnol.document.write(msg);labnol.document.close();})();

1 - 我不知道如何使用此脚本获得更大的缩略图,可能是 youtube 有限的图像质量/分辨率框架,因此此代码无法获得更大的版本?

2 - 一些新视频 90-120 分钟 + 需要几天才能显示完整的视频缩略图,这是真的吗?

谢谢

解决方案

这是书签的美化版:

(function() {a = ytplayer.config.args.storyboard_spec;如果一个) {alert("抱歉,我们无法处理此 YouTube 视频.请您尝试另一个视频");出口();}b = a.split("|");base = b[0].split("$")[0] + "2/M";c = b[3].split("#");叹息 = c[c.length - 1];var imgs = "";t = ytplayer.config.args.length_seconds;n = Math.ceil(c[2]/(c[3] * c[4]));for (i = 0; i 

这个页面(部分是中文)似乎已经解开了我们可以用来计算 labnol 数学的计算方案:http://rplus.github.io/blog/2014/04/26/youtube-storyboard/

$L 确定故事板的大小以及每个精灵"表的帧数.

据此,这些计算公式为:

L=1

100(10*10),共135(35多一个)

L=2

25(5*5),共135(10个多5个)

L=3

9 (3 * 3), 共 135 (仅 15)

对于假设视频:

b 变量包含两个小尺寸的工作表 (10x10) 和两个较大尺寸的工作表

console.log(b)["https://i.ytimg.com/sb/xxx/storyboard3_L$L/$N.jpg","48#27#100#10#10#0#default#XX-LJCqt8cvoKdNR-LktzyCucWU","80#45#242#10#10#10000#M$M#XXtyvKla08ayOvovocCEGBGtgfM","160#90#242#5#5#10000#M$M#XXNLRJzk9xaC36siHPgNM_ZsIlQ","320#180#242#3#3#10000#M$M#XXYfUj9jA3iVRkZk4QpfYICc53A"]

在计算 c 时,书签作者扔掉了其他三个尺寸,只留下了 160px (5x5) 尺寸.

c = b[3].split("#");console.log(c[2], c[3], c[4], c[2]/(c[3]*c[4]));242 5 5 9.68

9.68 的上限 = 10.

如果我们将 b[3] 替换为 b[4],并修复附加到URL 到 '3/M',我们得到更高分辨率的图像.

用更大的版本简单替换(有些视频没有最大版本,会失败):

javascript:(function()%7Ba%3Dytplayer.config.args.storyboard_spec%3Bif(!a)%7Balert("抱歉,我们无法处理这个 YouTube 视频.你能再试一个吗")%3Bexit()%3B%7Db%3Da.split("%7C")%3Bbase%3Db%5B0%5D.split("%24")%5B0%5D%2B"3/M"%3Bc%3Db%5B4%5D.split("%23")%3Bsigh%3Dc%5Bc.length-1%5D%3Bvar imgs%3D""%3Bt%3Dytplayer.config.args.length_seconds%3Bn%3DMath.ceil(c%5B2%5D/(c%5B3%5D*c%5B4%5D))%3Bfor(i%3D0%3Bi
"%3B%7Dvar title%3Dytplayer.config.args.title%3Bmsg%3D"

TITLE

IMAGES

<br/><em><a href%3D%27http://labnol.org/%3Fp%3D28217%27 style%3D%27text-decoration:none%3Bcolor:%23fff%3Bfont-style:粗体%27>使用 YouTube 书签打印.</a></em></body>"%3Bmsg%3Dmsg.replace("TITLE",title).replace("IMAGES",imgs).replace(/PICTURE/g,"img src")%3Bvar labnol%3Dwindow.open()%3Blabnol.document.open()%3Blabnol.document.write(msg)%3Blabnol.document.close()%3B%7D)()%3B

使用最大的可用缩略图制作工作表:

javascript:void%20function(){a=ytplayer.config.args.storyboard_spec,a||(alert(%22Sorry%20we%20cannot%20process%20this%20YouTube%20video.%20Could%20you%20please%20try%20another%20one%22),exit()),b=a.split(%22|%22),sz=b.length-1,base=b[0].split(%22$%22)[0]+(sz-1)+%22/M%22,c=b[sz].split(%22%23%22),sigh=c[c.length-1];var%20e=%22%22;for(t=ytplayer.config.args.length_seconds,n=Math.ceil(c[2]/(c[3]*c[4])),i=0;i%3Cn;i++)e+=%22%3CPICTURE='%22+base+i+%22.jpg%3Fsigh=%22+sigh+%22'%3E%3Cbr/%3E%22;var%20o=ytplayer.config.args.title;msg=%22%3Cbody%20style='background-color:%23444;color:%23eee;margin:20px%20auto;width:90%25;text-align:center'%3E%3Ch2%3ETITLE%3C/h2%3E%3Cdiv%3EIMAGES%3C/div%3E%3Cbr/%3E%3Cem%3E%3Ca%20href='http://labnol.org/%3Fp=28217'%20style='text-decoration:none;color:%23fff;font-style:bold'%3EPrinted%20using%20the%20YouTube%20bookmarklet.%3C/a%3E%3C/em%3E%3C/body%3E%22,msg=msg.replace(%22TITLE%22,o).replace(%22IMAGES%22,e).replace(/PICTURE/g,%22img%20src%22);var%20r=window.open();r.document.open(),r.document.write(msg),r.document.close()}();

更新这不在书签中,但实时环聊视频故事板藏在其中ytplayer.config.args.live_storyboard_spec 例如

"https://i.ytimg.com/sb/xx/storyboard_live_60_3x3_b1/M$M.jpg?sigh=xx3f9uQQKI3j8yTiD2qO7_GynM8#106#60#3#3"

http://www.labnol.org/internet/print-youtube-video/28217/

javascript:(function(){a=ytplayer.config.args.storyboard_spec;if(!a){alert("Sorry we cannot process this YouTube video. Could you please try another one");exit();}b=a.split("|");base=b[0].split("$")[0] "2/M";c=b[3].split("#");sigh=c[c.length-1];var imgs="";t=ytplayer.config.args.length_seconds;n=Math.ceil(c[2]/(c[3]*c[4]));for(i=0;i<n;i  ){imgs ="<PICTURE='" base i ".jpg?sigh=" sigh "'><br/>";}var title=ytplayer.config.args.title;msg="<body style='background-color:#444;color:#eee;margin:20px auto;width:90%;text-align:center'><h2>TITLE</h2><div>IMAGES</div><br/><em><a href='http://labnol.org/?p=28217' style='text-decoration:none;color:#fff;font-style:bold'>Printed using the YouTube bookmarklet.</a></em></body>";msg=msg.replace("TITLE",title).replace("IMAGES",imgs).replace(/PICTURE/g,"img src");var labnol=window.open();labnol.document.open();labnol.document.write(msg);labnol.document.close();})();

1 - I don't know how to get bigger thumbnail with this script, maybe youtube limited image quality/resolution frame so this code can't get bigger version ?

2 - Some new video 90-120 minutes + need several days to display full video thumbnail, it's true ?

Thank

解决方案

Here is the beautified version of the bookmarklet:

(function() {
  a = ytplayer.config.args.storyboard_spec;
  if (!a) {
    alert("Sorry we cannot process this YouTube video. Could you please try another one");
    exit();
  }
  b = a.split("|");
  base = b[0].split("$")[0] + "2/M";
  c = b[3].split("#");
  sigh = c[c.length - 1];
  var imgs = "";
  t = ytplayer.config.args.length_seconds;
  n = Math.ceil(c[2] / (c[3] * c[4]));
  for (i = 0; i < n; i++) {
    imgs += "<PICTURE='" + base + i + ".jpg?sigh=" + sigh + "'><br/>";
  }
  var title = ytplayer.config.args.title;
  msg = "<body style='background-color:#444;color:#eee;margin:20px auto;width:90%;text-align:center'><h2>TITLE</h2><div>IMAGES</div><br/><em><a href='http://labnol.org/?p=28217' style='text-decoration:none;color:#fff;font-style:bold'>Printed using the YouTube bookmarklet.</a></em></body>";
  msg = msg.replace("TITLE", title).replace("IMAGES", imgs).replace(/PICTURE/g, "img src");
  var labnol = window.open();
  labnol.document.open();
  labnol.document.write(msg);
  labnol.document.close();
})();

This page (partly in Chinese) appears to have disentangled the calculation scheme which we can use to figure out the labnol math: http://rplus.github.io/blog/2014/04/26/youtube-storyboard/

$L determines the size of storyboards and how few frames there are per "sprite" sheet.

According to that, these are calculated by:

L=1

100 (10 * 10), a total of 135 (one more than 35)

L=2

25 (5 * 5), a total of 135 (five more than 10)

L=3

9 (3 * 3), a total of 135 (just 15)

For a hypothetical video:

b variable contains two tiny size sheets (10x10) and two larger sized sheets

console.log(b)
["https://i.ytimg.com/sb/xxx/storyboard3_L$L/$N.jpg",
 "48#27#100#10#10#0#default#XX-LJCqt8cvoKdNR-LktzyCucWU",
 "80#45#242#10#10#10000#M$M#XXtyvKla08ayOvovocCEGBGtgfM", 
 "160#90#242#5#5#10000#M$M#XXNLRJzk9xaC36siHPgNM_ZsIlQ", 
 "320#180#242#3#3#10000#M$M#XXYfUj9jA3iVRkZk4QpfYICc53A"]

When calculating c, the bookmarklet author throws away the other three sizes, leaving only the 160px (5x5) size.

c = b[3].split("#");
console.log(c[2], c[3], c[4], c[2]/(c[3]*c[4]));
242 5 5 9.68

Ceil of 9.68 = 10.

If we replace b[3] with b[4], and fix the '2/M' that gets appended to the URL to '3/M', we get higher resolution images.

Simple replacement with larger version (some videos don't have largest version and will fail):

javascript:(function()%7Ba%3Dytplayer.config.args.storyboard_spec%3Bif(!a)%7Balert("Sorry we cannot process this YouTube video. Could you please try another one")%3Bexit()%3B%7Db%3Da.split("%7C")%3Bbase%3Db%5B0%5D.split("%24")%5B0%5D%2B"3/M"%3Bc%3Db%5B4%5D.split("%23")%3Bsigh%3Dc%5Bc.length-1%5D%3Bvar imgs%3D""%3Bt%3Dytplayer.config.args.length_seconds%3Bn%3DMath.ceil(c%5B2%5D/(c%5B3%5D*c%5B4%5D))%3Bfor(i%3D0%3Bi<n%3Bi%2B%2B)%7Bimgs%2B%3D"<PICTURE%3D%27"%2Bbase%2Bi%2B".jpg%3Fsigh%3D"%2Bsigh%2B"%27><br/>"%3B%7Dvar title%3Dytplayer.config.args.title%3Bmsg%3D"<body style%3D%27background-color:%23444%3Bcolor:%23eee%3Bmargin:20px auto%3Bwidth:90%25%3Btext-align:center%27><h2>TITLE</h2><div>IMAGES</div><br/><em><a href%3D%27http://labnol.org/%3Fp%3D28217%27 style%3D%27text-decoration:none%3Bcolor:%23fff%3Bfont-style:bold%27>Printed using the YouTube bookmarklet.</a></em></body>"%3Bmsg%3Dmsg.replace("TITLE",title).replace("IMAGES",imgs).replace(/PICTURE/g,"img src")%3Bvar labnol%3Dwindow.open()%3Blabnol.document.open()%3Blabnol.document.write(msg)%3Blabnol.document.close()%3B%7D)()%3B

Use the largest available thumbnail to make the sheet:

javascript:void%20function(){a=ytplayer.config.args.storyboard_spec,a||(alert(%22Sorry%20we%20cannot%20process%20this%20YouTube%20video.%20Could%20you%20please%20try%20another%20one%22),exit()),b=a.split(%22|%22),sz=b.length-1,base=b[0].split(%22$%22)[0]+(sz-1)+%22/M%22,c=b[sz].split(%22%23%22),sigh=c[c.length-1];var%20e=%22%22;for(t=ytplayer.config.args.length_seconds,n=Math.ceil(c[2]/(c[3]*c[4])),i=0;i%3Cn;i++)e+=%22%3CPICTURE='%22+base+i+%22.jpg%3Fsigh=%22+sigh+%22'%3E%3Cbr/%3E%22;var%20o=ytplayer.config.args.title;msg=%22%3Cbody%20style='background-color:%23444;color:%23eee;margin:20px%20auto;width:90%25;text-align:center'%3E%3Ch2%3ETITLE%3C/h2%3E%3Cdiv%3EIMAGES%3C/div%3E%3Cbr/%3E%3Cem%3E%3Ca%20href='http://labnol.org/%3Fp=28217'%20style='text-decoration:none;color:%23fff;font-style:bold'%3EPrinted%20using%20the%20YouTube%20bookmarklet.%3C/a%3E%3C/em%3E%3C/body%3E%22,msg=msg.replace(%22TITLE%22,o).replace(%22IMAGES%22,e).replace(/PICTURE/g,%22img%20src%22);var%20r=window.open();r.document.open(),r.document.write(msg),r.document.close()}();

Update This isn't in the bookmarklet but live Hangouts video storyboards are stashed in ytplayer.config.args.live_storyboard_spec e.g.

"https://i.ytimg.com/sb/xx/storyboard_live_60_3x3_b1/M$M.jpg?sigh=xx3f9uQQKI3j8yTiD2qO7_GynM8#106#60#3#3"

这篇关于Youtube 故事板脚本 - 更大的缩略图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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