YouTube.js icon indicating copy to clipboard operation
YouTube.js copied to clipboard

Check if duration exists

Open dnicolson opened this issue 2 months ago • 1 comments

This prevents the following for live and upcoming videos:

{text: 'N/A', seconds: NaN}

dnicolson avatar Oct 19 '25 15:10 dnicolson

Please fix the type error.

absidue avatar Oct 19 '25 15:10 absidue

The issue can be reproduced by adding a live video to the Watch Later playlist:

const VIDEO_ID = "jfKfPfyJRdk";
const PLAYLIST_ID = "WL";

await yt.playlist.addVideos(PLAYLIST_ID, [VIDEO_ID]);
const playlist = await yt.getPlaylist(PLAYLIST_ID);

for (const item of playlist.items) {
  if (item.type === "PlaylistVideo" && item.id === VIDEO_ID) {
    console.log(`Duration of video ${VIDEO_ID}`, item.duration);
    break;
  }
}

dnicolson avatar Dec 18 '25 19:12 dnicolson