Fix playlist stopping between tracks; add retry logic to getNextTrack#74
Open
ElFishi wants to merge 1 commit intophilippe44:masterfrom
Open
Fix playlist stopping between tracks; add retry logic to getNextTrack#74ElFishi wants to merge 1 commit intophilippe44:masterfrom
ElFishi wants to merge 1 commit intophilippe44:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix playlist stopping between tracks; add retry logic to
getNextTrackThis PR fixes a bug that caused playlist playback to stop between tracks instead of advancing automatically, and adds automatic retry logic to make the player resilient against the transient yt-dlp failures that triggered it.
Bug
When yt-dlp resolves a track's stream URL, YouTube occasionally returns only format 18 — a legacy muxed 360p mp4 — instead of the expected audio-only streams (opus/ogg/aac). Since format 18 is not present in the
@audioIdor@videoIdlookup tables,_selectTracksreturns an empty list,_getNextTrackfinds no matching track and callserrorCb, causing LMS to stop playback entirely. Because the track is not removed from the playlist, pressing play manually succeeds — typically because yt-dlp returns proper audio streams on the second attempt.A secondary bug existed in
_selectTracks: in the audio loop,$track->{_id} = $itemwas executed after thepushand unconditionally, meaning it ran even when no matching track was found (leaving$trackundef), and any pushed track had_idunset at the point it was pushed.Changes
getNextTracknow accepts an optional$_retriesparameter, defaulting to 3. On any failure — yt-dlp parse error, no matching tracks, or stream initialisation failure from_getNextTrack— a$retryOrFailclosure either schedules a fresh attempt viaSlim::Utils::Timers::setTimerafter a 2-second delay, or calls the realerrorCbonce all retries are exhausted. The 2-second delay avoids immediately hammering YouTube's CDN and gives the event loop room to breathe. The$retryOrFailclosure is passed down as the error callback to_getNextTrackas well, so failures at the stream initialisation level are retried on the same terms.In
_selectTracks, both the audio and video loops are corrected to assign$track->{_id}before pushing, and only when a matching track was actually found.