mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): danmaku add video time (#13379)
This commit is contained in:
@@ -3,6 +3,14 @@ const cache = require('./cache');
|
||||
const got = require('@/utils/got');
|
||||
const zlib = require('zlib');
|
||||
|
||||
const processFloatTime = (time) => {
|
||||
const totalSeconds = parseInt(time);
|
||||
const seconds = totalSeconds % 60;
|
||||
const minutes = ((totalSeconds - seconds) / 60) % 60;
|
||||
const hours = (totalSeconds - seconds - 60 * minutes) / 3600;
|
||||
return `${hours}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
let bvid = ctx.params.bvid;
|
||||
let aid;
|
||||
@@ -46,8 +54,7 @@ module.exports = async (ctx) => {
|
||||
link,
|
||||
description: `${videoName} 的 弹幕动态`,
|
||||
item: danmakuList.map((item) => ({
|
||||
title: item.text,
|
||||
description: item.text,
|
||||
title: `[${processFloatTime(item.p.split(',')[0])}] ${item.text}`,
|
||||
pubDate: new Date(item.p.split(',')[4] * 1000).toUTCString(),
|
||||
guid: `${cid}-${item.p.split(',')[4]}-${item.p.split(',')[7]}`,
|
||||
link,
|
||||
|
||||
Reference in New Issue
Block a user