-
-
Notifications
You must be signed in to change notification settings - Fork 463
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
feat(local): implement support for SponsorBlock and DeArrow #7195
Conversation
According to the SponsorBlock API documentation categories and actionTypes are string arrays.
Allows users to use SponsorBlock when using full local mode. Closes: libre-tube#7193
.toHexString() | ||
|
||
return RetrofitInstance.externalApi.getSegments( | ||
hashedId.substring(0..4), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
substring(0..4)
would be hashedId[0]...hashedId[4]
(5 chars), while below you used substring(0, 4)
which excludes hashedId[4]
. Probably a typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just me being used to Rust Ranges :)
): SegmentData { | ||
// use hashed video id for privacy | ||
// https://wiki.sponsor.ajay.app/w/API_Docs#GET_/api/skipSegments/:sha256HashPrefix | ||
val hashedId = MessageDigest.getInstance("SHA-256") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer moving the hashing function to a helper method since its implementation details are unrelated to the logic of this method, it could even make sense to create an extension function String.sha256sum()
.
value.copy( | ||
thumbnails = value.thumbnails.map { thumbnail -> | ||
thumbnail.takeIf { it.original } ?: thumbnail.copy( | ||
thumbnail = "https://dearrow-thumb.ajay.app/api/v1/getThumbnail?videoID=$videoId&time=${thumbnail.timestamp}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put the base url to a constant.
val hashedId = digest | ||
.digest(videoId.toByteArray()) | ||
.toHexString() | ||
RetrofitInstance.externalApi.getDeArrowContent( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should use runCatching
here because if one chunk of data fails to load (for whatever reasons, e.g. ratelimits), we could still display the results from the other requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Implements support for SponsorBlock and DeArrow when using the full local mode.
Please note that I was unable to confirm that DeArrow works correctly, as neither the local nor the Piped API worked, so I'm assuming it is an external failure.
Closes: #7193