SponsorBlock

SponsorBlock is a crowdsourced project to skip sponsor segments in YouTube videos. ytdlp-nodejs seamlessly integrates SponsorBlock functionality.

Programmatic Usage

You can use SponsorBlock options in downloadAsync:

1import { YtDlp } from 'ytdlp-nodejs';
2
3const ytdlp = new YtDlp();
4
5await ytdlp.downloadAsync(url, {
6  // Mark segments as chapters
7  sponsorblockMark: ['sponsor', 'intro', 'outro', 'selfpromo'],
8
9  // Or remove segments entirely from the downloaded file
10  sponsorblockRemove: ['sponsor', 'selfpromo'],
11});

Using the Fluent Builder API

1const result = await ytdlp
2  .download(url)
3  .options({
4    sponsorblockMark: ['sponsor', 'intro'],
5    sponsorblockRemove: ['selfpromo'],
6  })
7  .run();

Categories

Common categories include:

  • sponsor: Paid promotion
  • intro: Animation/intro sequence
  • outro: End credits/outro
  • selfpromo: Self-promotion
  • interaction: "Like and subscribe" reminders
  • preview: Preview of next video
  • music_offtopic: Non-music parts in music videos

Modes

  • Mark: Creates chapters in the video file for these segments.
  • Remove: Physically cuts these segments from the video.

Note: Removing segments requires FFmpeg to be installed.