added some new properties

This commit is contained in:
killer069 2021-08-23 13:05:40 +05:30
parent f674b07e22
commit 497b1aa61d
2 changed files with 18 additions and 5 deletions

View File

@ -6,8 +6,8 @@ interface VideoOptions {
url? : string;
title?: string;
description?: string;
duration_formatted: string;
duration: number;
durationRaw: string;
durationInSec: number;
uploadedAt?: string;
views: number;
thumbnail?: {
@ -84,8 +84,8 @@ export class Video {
url: this.url,
title: this.title,
description: this.description,
duration: this.duration,
duration_formatted: this.durationFormatted,
durationInSec: this.duration,
durationRaw: this.durationFormatted,
uploadedAt: this.uploadedAt,
thumbnail: this.thumbnail?.toJSON(),
channel: {

View File

@ -23,7 +23,8 @@ export async function video_basic_info(url : string){
url : 'https://www.youtube.com/watch?v=' + vid.videoId,
title : vid.title,
description : vid.shortDescription,
duration : vid.lengthSeconds,
durationInSec : vid.lengthSeconds,
durationRaw : parseSeconds(vid.lengthSeconds),
uploadedDate : microformat.publishDate,
thumbnail : {
width : vid.thumbnail.thumbnails[vid.thumbnail.thumbnails.length - 1].width,
@ -56,6 +57,18 @@ export async function video_basic_info(url : string){
}
}
function parseSeconds(seconds : number): string {
let d = Number(seconds);
var h = Math.floor(d / 3600);
var m = Math.floor(d % 3600 / 60);
var s = Math.floor(d % 3600 % 60);
var hDisplay = h > 0 ? (h < 10 ? `0${h}` : h) + ':' : "";
var mDisplay = m > 0 ? (m < 10 ? `0${m}` : m) + ':' : "00:";
var sDisplay = s > 0 ? (s < 10 ? `0${s}` : s) : "00";
return hDisplay + mDisplay + sDisplay;
}
export async function video_info(url : string) {
let data = await video_basic_info(url)
if(data.LiveStreamData.isLive === true && data.LiveStreamData.hlsManifestUrl !== null){