added some new properties
This commit is contained in:
parent
f674b07e22
commit
497b1aa61d
@ -6,8 +6,8 @@ interface VideoOptions {
|
|||||||
url? : string;
|
url? : string;
|
||||||
title?: string;
|
title?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
duration_formatted: string;
|
durationRaw: string;
|
||||||
duration: number;
|
durationInSec: number;
|
||||||
uploadedAt?: string;
|
uploadedAt?: string;
|
||||||
views: number;
|
views: number;
|
||||||
thumbnail?: {
|
thumbnail?: {
|
||||||
@ -84,8 +84,8 @@ export class Video {
|
|||||||
url: this.url,
|
url: this.url,
|
||||||
title: this.title,
|
title: this.title,
|
||||||
description: this.description,
|
description: this.description,
|
||||||
duration: this.duration,
|
durationInSec: this.duration,
|
||||||
duration_formatted: this.durationFormatted,
|
durationRaw: this.durationFormatted,
|
||||||
uploadedAt: this.uploadedAt,
|
uploadedAt: this.uploadedAt,
|
||||||
thumbnail: this.thumbnail?.toJSON(),
|
thumbnail: this.thumbnail?.toJSON(),
|
||||||
channel: {
|
channel: {
|
||||||
|
|||||||
@ -23,7 +23,8 @@ export async function video_basic_info(url : string){
|
|||||||
url : 'https://www.youtube.com/watch?v=' + vid.videoId,
|
url : 'https://www.youtube.com/watch?v=' + vid.videoId,
|
||||||
title : vid.title,
|
title : vid.title,
|
||||||
description : vid.shortDescription,
|
description : vid.shortDescription,
|
||||||
duration : vid.lengthSeconds,
|
durationInSec : vid.lengthSeconds,
|
||||||
|
durationRaw : parseSeconds(vid.lengthSeconds),
|
||||||
uploadedDate : microformat.publishDate,
|
uploadedDate : microformat.publishDate,
|
||||||
thumbnail : {
|
thumbnail : {
|
||||||
width : vid.thumbnail.thumbnails[vid.thumbnail.thumbnails.length - 1].width,
|
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) {
|
export async function video_info(url : string) {
|
||||||
let data = await video_basic_info(url)
|
let data = await video_basic_info(url)
|
||||||
if(data.LiveStreamData.isLive === true && data.LiveStreamData.hlsManifestUrl !== null){
|
if(data.LiveStreamData.isLive === true && data.LiveStreamData.hlsManifestUrl !== null){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user