Added skipsegment command that interacts with SponsorBlock API to skip non music segments on YouTube music videos #1067
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request...
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:
Command succeeding at retrieving database entry but failing because no non-music segment is currently playing:
Command failing because the song is not in the SponsorBlock database:
Relevant Issue(s)
This PR closes feature request #982