muse icon indicating copy to clipboard operation
muse copied to clipboard

Add SponsorBlock support

Open Charlignon opened this issue 2 years ago • 6 comments

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 offset metadata 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.

Charlignon avatar Apr 03 '24 15:04 Charlignon

: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

github-actions[bot] avatar Apr 03 '24 15:04 github-actions[bot]

would also be great to leverage Muse's cache class to cache the result sponsorblock calls if the API is typically slow/often down

codetheweb avatar Apr 09 '24 04:04 codetheweb

Pushed all the code review changes, I'll do a separate commit for cache implementation !

Charlignon avatar Apr 09 '24 15:04 Charlignon

sounds good

codetheweb avatar Apr 10 '24 05:04 codetheweb

@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

Charlignon avatar Apr 21 '24 10:04 Charlignon

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 image It may be the configuration, have you added ENABLE_SPONSORBLOCK=true in your .env ?

Charlignon avatar Apr 22 '24 11:04 Charlignon

oh my bad, forgot it slices the video instead of skipping over segments 😅

codetheweb avatar Apr 28 '24 21:04 codetheweb

🚀 Released in Release v2.8.0.

github-actions[bot] avatar Apr 28 '24 21:04 github-actions[bot]