mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-07-04 12:47:04 +00:00
feat: add live stream start_timestamp (#275)
This commit is contained in:
@@ -34,6 +34,7 @@ class PlayerMicroformat extends YTNode {
|
|||||||
publish_date: string;
|
publish_date: string;
|
||||||
upload_date: string;
|
upload_date: string;
|
||||||
available_countries: string[];
|
available_countries: string[];
|
||||||
|
start_timestamp: Date | null;
|
||||||
|
|
||||||
constructor(data: any) {
|
constructor(data: any) {
|
||||||
super();
|
super();
|
||||||
@@ -65,6 +66,7 @@ class PlayerMicroformat extends YTNode {
|
|||||||
this.publish_date = data.publishDate;
|
this.publish_date = data.publishDate;
|
||||||
this.upload_date = data.uploadDate;
|
this.upload_date = data.uploadDate;
|
||||||
this.available_countries = data.availableCountries;
|
this.available_countries = data.availableCountries;
|
||||||
|
this.start_timestamp = data.liveBroadcastDetails?.startTimestamp ? new Date(data.liveBroadcastDetails.startTimestamp) : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -133,7 +133,8 @@ class VideoInfo {
|
|||||||
channel: info.microformat?.is(PlayerMicroformat) ? info.microformat?.channel : null,
|
channel: info.microformat?.is(PlayerMicroformat) ? info.microformat?.channel : null,
|
||||||
is_unlisted: info.microformat?.is_unlisted,
|
is_unlisted: info.microformat?.is_unlisted,
|
||||||
is_family_safe: info.microformat?.is_family_safe,
|
is_family_safe: info.microformat?.is_family_safe,
|
||||||
has_ypc_metadata: info.microformat?.is(PlayerMicroformat) ? info.microformat?.has_ypc_metadata : null
|
has_ypc_metadata: info.microformat?.is(PlayerMicroformat) ? info.microformat?.has_ypc_metadata : null,
|
||||||
|
start_timestamp: info.microformat?.is(PlayerMicroformat) ? info.microformat.start_timestamp : null
|
||||||
},
|
},
|
||||||
like_count: undefined as number | undefined,
|
like_count: undefined as number | undefined,
|
||||||
is_liked: undefined as boolean | undefined,
|
is_liked: undefined as boolean | undefined,
|
||||||
|
|||||||
@@ -54,6 +54,12 @@ describe('YouTube.js Tests', () => {
|
|||||||
const b_info = await yt.getBasicInfo(VIDEOS[5].ID);
|
const b_info = await yt.getBasicInfo(VIDEOS[5].ID);
|
||||||
expect(b_info.basic_info.is_live).toBe(true);
|
expect(b_info.basic_info.is_live).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should extract live stream start timestamp', async () => {
|
||||||
|
const b_info = await yt.getBasicInfo(VIDEOS[4].ID);
|
||||||
|
expect(b_info.basic_info.start_timestamp).not.toBeNull()
|
||||||
|
expect(b_info.basic_info.start_timestamp!.toISOString()).toBe('2024-03-30T23:00:00.000Z');
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Search', () => {
|
describe('Search', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user