From e7a574091efea3789d2d9e83524b41f56c0457a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Fri, 29 Jul 2022 21:39:49 +0800 Subject: [PATCH] =?UTF-8?q?B=E7=AB=99=E6=8E=92=E8=A1=8C=E6=A6=9C=20?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E5=AD=97=E6=AE=B5=E5=88=9D=E6=AD=A5=E5=A4=84?= =?UTF-8?q?=E7=90=86=E5=AE=8C=E6=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/bilibili_rank.html | 204 ++++++++++++++++++++++++++++------------ 1 file changed, 145 insertions(+), 59 deletions(-) diff --git a/html/bilibili_rank.html b/html/bilibili_rank.html index 2e81d9a..f9acf90 100644 --- a/html/bilibili_rank.html +++ b/html/bilibili_rank.html @@ -5,6 +5,8 @@ + + B站排行 @@ -271,32 +273,28 @@ 编号 - aid + 标题 + 时长 + 封面 + 第一帧 + 视频ID + 分类 + 发布时间 + 简介 + 作者(mid) + 统计 + 视频宽高 + 定位 + videos tid - tname copyright - pic - title - pubdate - ctime - desc state - duration - mission_id rights - owner - stat dynamic - cid - dimension - short_link - short_link_v2 - first_frame - pub_location - bvid score + mission_id season_id up_from_v2 others @@ -305,67 +303,155 @@ str.push(``); for (var i = 0; i < hotBandList.length; i++) { const hotBand = hotBandList[i]; - let hotDelta = hotBand.num - hotBand.raw_hot; + let link = hotBand.short_link == hotBand.short_link_v2 + ? hotBand.short_link + : `${hotBand.short_link}
${hotBand.short_link_v2}`; + + /** + * 视频总秒数转化为友好显示时间 + */ + // refer: https://blog.csdn.net/weixin_43838488/article/details/122337474 + function formatZero(num, len) { + if (String(num).length > len) { + return num; + } + return (Array(len).join(0) + num).slice(-len) + } + + let duration = hotBand.duration - 1; // 根据观测,基本上所有视频都是少1s(有些少了2s或者其他),所以这里减1 + let durationArr = [0, 0, 0]; + durationArr[0] = Math.floor(duration / (60 * 60)); + durationArr[1] = Math.floor((duration - durationArr[0] * 60 * 60) / 60); + durationArr[2] = Math.floor(duration - durationArr[0] * 60 * 60 - durationArr[1] * 60); + let durationStr = ""; + if (durationArr[0] === 0) { + // 小时为0 + durationStr = `${formatZero(durationArr[1], 2)}:${formatZero(durationArr[2], 2)}`; + } else { + // 小时不为0 + durationStr = `${formatZero(durationArr[0], 2)}:${formatZero(durationArr[1], 2)}:${formatZero(durationArr[2], 2)}`; + } + + //功能:求最大公约数 + //参数: x 、y number + //返回值: number + function gcd(x, y) { + if (isNaN(x) || isNaN(y)) return null; + + if (x % y === 0) { + return y; + } + return gcd(y, x % y) + //三目运算符写法: + //return x % y === 0 ? y : gcd(y , x % y) ; + } + let dimension_gcd = gcd(hotBand.dimension.width, hotBand.dimension.height); + str.push(` ${i + 1} + + + + ${hotBand.title} + + + + ${durationStr}
(${hotBand.duration}s) + + + + + + + + + + + - ${hotBand.aid} + + aid: ${hotBand.aid} + bvid: ${hotBand.bvid} + cid: ${hotBand.cid} + + + + ${hotBand.tname} + + + + pubdate: ${new Date(hotBand.pubdate * 1000).toLocaleString()} + ctime: ${new Date(hotBand.ctime * 1000).toLocaleString()} + + + + ${hotBand.desc} + + + +
+ ${hotBand.owner.name}
+ (${hotBand.owner.mid}) + + + + + + 播放: ${hotBand.stat.view} + 弹幕: ${hotBand.stat.danmaku} + 评论: ${hotBand.stat.reply} + 喜欢: ${hotBand.stat.favorite} + 投币: ${hotBand.stat.coin} + 分享: ${hotBand.stat.share} + + 历史排名: ${hotBand.stat.his_rank} + 喜欢数: ${hotBand.stat.like} + 不喜欢数: ${hotBand.stat.dislike} + + + + + + ${hotBand.dimension.width}:${hotBand.dimension.height}
+ (${hotBand.dimension.width / dimension_gcd}:${hotBand.dimension.height / dimension_gcd}) + + + + + + + ${hotBand.pub_location} + + + ${hotBand.videos} ${hotBand.tid} - - ${hotBand.tname} ${hotBand.copyright} - - ${hotBand.pic} - - ${hotBand.title} - - ${hotBand.pubdate} - - ${hotBand.ctime} - - ${hotBand.desc} ${hotBand.state} - - ${hotBand.duration} - - ${hotBand.mission_id} ${JSON.stringify(hotBand.rights)} - - ${JSON.stringify(hotBand.owner)} - - ${JSON.stringify(hotBand.stat)} ${hotBand.dynamic} - - ${hotBand.cid} - - ${JSON.stringify(hotBand.dimension)} - - ${hotBand.short_link} - - ${hotBand.short_link_v2} - - ${hotBand.first_frame} - - ${hotBand.pub_location} - - ${hotBand.bvid} ${hotBand.score} + + ${hotBand.mission_id ? hotBand.mission_id : ''} - ${hotBand.season_id} + ${hotBand.season_id ? hotBand.season_id : ''} - ${hotBand.up_from_v2} + ${hotBand.up_from_v2 ? hotBand.up_from_v2 : ''} -
${JSON.stringify(hotBand.others)}
+ + ${hotBand.others + ? `
${JSON.stringify(hotBand.others)}
` + : ''} + `); } str.push(``);