Files
danmaku/routes/api/utils.js
2023-09-10 15:46:55 +00:00

23 lines
664 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const content_template = {
timepoint: 0, // 弹幕发送时间(秒)
ct: 1, // 弹幕类型1-3 为滚动弹幕、4 为底部、5 为顶端、6 为逆向、7 为精确、8 为高级
size: 25, //字体大小25 为中18 为小
color: 16777215, //弹幕颜色RGB 颜色转为十进制后的值16777215 为白色
unixtime: Math.floor(Date.now() / 1000), //Unix 时间戳格式
uid: 0, //发送人的 id
content: "",
};
function time_to_second(time) {
const t = time.split(":");
let s = 0;
let m = 1;
while (t.length > 0) {
s += m * parseInt(t.pop(), 10);
m *= 60;
}
return s;
}
module.exports = {time_to_second, content_template};