mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-04-24 22:19:41 +08:00
✨ B站视频基本信息获取,支持分享图生成
This commit is contained in:
@@ -232,3 +232,20 @@ export function getZhElement(element: string): string {
|
||||
return "未知";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取视频时长
|
||||
* @since Beta v0.5.7
|
||||
* @param {number} duration - 视频时长(秒)
|
||||
* @returns {string} 视频时长
|
||||
*/
|
||||
export function getVideoDuration(duration: number): string {
|
||||
const seconds = duration % 60;
|
||||
const minutes = Math.floor(duration / 60) % 60;
|
||||
const hours = Math.floor(duration / 3600);
|
||||
let result = "";
|
||||
if (hours > 0) result += `${hours.toString().padStart(2, "0")}:`;
|
||||
result += `${minutes.toString().padStart(2, "0")}:`;
|
||||
result += `${seconds.toString().padStart(2, "0")}`;
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user