Add SponsorBlock support
Functional description
Skip non-musical start and end segments when available. Closes #808
Changes
Add sponsorBlock api client dependency, and call the API when adding songs to the playlist. See review comments for details on implementation choices.
Comments
Hello ! Hope you don't mind this PR, and that it's up to your standards :) Here are a few opinionated choices I made and things I didn't include. Feel free to challenge them !
- I decided to assume most songs would not have cuts in the middle anyway, or that they would be negligible. It simplifies the use case a lot, since only start and end segments are considered for trimming (no complex time check). This way, we can leverage the existing
offsetmetadata field to treat the "middle segment" like a chapter. - SponsorBlock servers are regularly down or over-capacity. When that's the case, we skip segment requests for 5mn (arbitrary)
- I did not include any timeout on the API requests. This means the SB calls will be blocking when adding songs to the playlist.
- Error handling is not my forte, so feedback on this part is welcomed !
- There is no integration with chapter slicing
- There is no cache at video level, from my understanding the whole song result is cached
I tested my code locally ! No issue ocured during testing.
:package: A new release has been made for this pull request.
To play around with this PR, pull codetheweb/muse:pr-1013 or codetheweb/muse:468cf0cf09175a665387030810ec7f99e8c4a620.
Images are available for x86_64 and ARM64.
Latest commit: 468cf0cf09175a665387030810ec7f99e8c4a620
would also be great to leverage Muse's cache class to cache the result sponsorblock calls if the API is typically slow/often down
Pushed all the code review changes, I'll do a separate commit for cache implementation !
sounds good
@codetheweb sorry life has been pretty busy, but I'm done :)
Tested and got the following debug log, as expected
muse Cache hit: F2AitTPI5U0 +2ms
Hum, that's strange ! I tried it again and it seems to be working properly, the play time displayed by Muse matches the video without the segments
It may be the configuration, have you added
ENABLE_SPONSORBLOCK=true in your .env ?
oh my bad, forgot it slices the video instead of skipping over segments 😅
🚀 Released in Release v2.8.0.