Skip to content

topi314/SponsorBlock-Plugin

Repository files navigation

SponsorBlock-Plugin

A Lavalink plugin to skip SponsorBlock segments in YouTube videos and provide information about chapters

Installation

Warning This plugin requires Lavalink v4 beta 3 or higher

To install this plugin either download the latest release and place it into your plugins folder or add the following into your application.yml

Note For a full application.yml example see here

lavalink:
  plugins:
    - dependency: "com.github.topi314.sponsorblock:sponsorblock-plugin:x.x.x" # replace x.x.x with the latest release tag!
      repository: "https://maven.lavalink.dev/releases" # this is optional for lavalink v4.0.0-beta.5 or greater
      snapshot: false # set to true if you want to use snapshot builds (see below)

Snapshot builds are available in https://maven.lavalink.dev/snapshots with the short commit hash as the version

Usage

Get Categories

GET /v4/sessions/{sessionId}/players/{guildId}/sponsorblock/categories

Response:

[
  "sponsor",
  "selfpromo"
]

Put Categories

PUT /v4/sessions/{sessionId}/players/{guildId}/sponsorblock/categories

Request:

[
  "sponsor",
  "selfpromo"
]

Delete Categories

DELETE /v4/sessions/{sessionId}/players/{guildId}/sponsorblock/categories

  • sponsor
  • selfpromo
  • interaction
  • intro
  • outro
  • preview
  • music_offtopic
  • filler

There are also two new events:

SegmentsLoaded

which is fired when the segments for a track are loaded

{
  "op": "event",
  "type": "SegmentsLoaded",
  "guildId": "...",
  "segments": [
    {
      "category": "...",
      "start": 0, // in milliseconds
      "end": 3000 // in milliseconds
    }
  ]
}

SegmentSkipped

which is fired when a segment is skipped

{
  "op": "event",
  "type": "SegmentSkipped",
  "guildId": "...",
  "segment": {
    "category": "...",
    "start": 0, // in milliseconds
    "end": 3000 // in milliseconds
  }
}

ChaptersLoaded

which is fired when the chapters for a track are loaded

{
  "op": "event",
  "type": "ChaptersLoaded",
  "guildId": "...",
  "chapters": [
    {
      "name": "Prelude",
      "start": 0, // in milliseconds
      "end": 0, // in milliseconds
      "duration": "0" // in milliseconds
    }
  ]}

ChapterStarted

which is fired when a new Chapter starts

{
  "op": "event",
  "type": "ChapterStarted",
  "guildId": "...",
  "chapter": {
    "name": "Prelude",
    "start": 0, // in milliseconds
    "end": 0,// in milliseconds
    "duration": "0" // in milliseconds
  }
}

Example

An example implementation in Go can be found here