Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added skipsegment command that interacts with SponsorBlock API to skip non music segments on YouTube music videos #1067

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Tommy-Davies
Copy link

@Tommy-Davies Tommy-Davies commented Dec 6, 2021

This pull request...

  • Fixes a bug
  • Introduces a new feature
  • Improves an existing feature
  • Boosts code quality or performance

Description

This implements feature request #982 and adds a new command that allows a user to optionally skip the non-music segment that is currently playing. This feature is implemented with the skipSegCmd class which retrieves the URL of the currently playing song, extracts the video ID, sends a request to the SponsorBlock API, and parses the JSON file. The JSON parser returns either an error code (-1) or the millisecond value of the end of the current segment if one is found. If it succeeded, it will tell the user where the track is seeking to. If it failed it will tell the user why. It uses the lava player setPosition() method to set the track position to the correct time upon success.

Purpose

When listening to a music video on YouTube, there are often non-music sections or intros that are impossible to skip, and can be very frustrating to sit through without visual context. This often makes these versions of songs unplayable. This feature is invoked with the "skipsegment" command. The user will use this command while a song is playing to skip to the end of the current segment in a song. The command will return the timestamp for the segment that it is jumping ahead to or display “No segments found”. If the song is in the last segment of the song and the user tries to skipSegment, the message “Cannot skip here because no segment is currently playing!”. This happens since there are no segments left in the song. This feature only works with YouTube videos, due to the limitations of the SponsorBlock API, so if the user tries to skipSegment while playing a SoundCloud, Vimeo, or Twitch stream, they will get a “Could not get video ID!” message.

Command succeeding by skipping a segment that is currently playing and moving the track ahead to the correct location:
Screen Shot 2021-12-05 at 8 36 49 PM

Command succeeding at retrieving database entry but failing because no non-music segment is currently playing:
Screen Shot 2021-12-05 at 8 36 59 PM

Command failing because the song is not in the SponsorBlock database:
Screen Shot 2021-12-05 at 8 37 10 PM

Relevant Issue(s)

This PR closes feature request #982

@@ -99,7 +99,7 @@ public static void main(String[] args)
new PingCommand(),
new SettingsCmd(bot),

new LyricsCmd(bot),
// new LyricsCmd(bot),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was causing problems when I tried to run the bot from a jar executable.

boolean musicSegment = false;

try {
String nonMusicURLString = "https://sponsor.ajay.app/api/searchSegments?videoID=";
Copy link

@Joe-Dowd Joe-Dowd Jan 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use the skipSegments endpoint rather than searchSegments (docs). Using the hash prefix version of skipSegments would be better for user privacy.

Also, category should be supplied as a query parameter with the value of music_offtopic (or categories if multiple types are to be skipped) to ensure you're getting non-music segments back, as the default is to only retrieve sponsor segments. (docs)

uncreativeCultist added a commit to uncreativeCultist/MusicBotShiverFork that referenced this pull request Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants