mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
Merge pull request #4807 from Bnyro/master
fix: default SponsorBlock categories are not being respected
This commit is contained in:
commit
86007d5998
@ -47,6 +47,15 @@ object PlayerHelper {
|
|||||||
const val SPONSOR_HIGHLIGHT_CATEGORY = "poi_highlight"
|
const val SPONSOR_HIGHLIGHT_CATEGORY = "poi_highlight"
|
||||||
const val ROLE_FLAG_AUTO_GEN_SUBTITLE = C.ROLE_FLAG_SUPPLEMENTARY
|
const val ROLE_FLAG_AUTO_GEN_SUBTITLE = C.ROLE_FLAG_SUPPLEMENTARY
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of all categories that are not disabled by default
|
||||||
|
* Also update `sponsorblock_settings.xml` when modifying this!
|
||||||
|
*/
|
||||||
|
private val sbDefaultValues = mapOf(
|
||||||
|
"sponsor" to SbSkipOptions.AUTOMATIC,
|
||||||
|
"selfpromo" to SbSkipOptions.AUTOMATIC
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a base64 encoded DASH stream manifest
|
* Create a base64 encoded DASH stream manifest
|
||||||
*/
|
*/
|
||||||
@ -221,7 +230,7 @@ object PlayerHelper {
|
|||||||
.roundToInt()
|
.roundToInt()
|
||||||
.toLong() * 1000
|
.toLong() * 1000
|
||||||
|
|
||||||
val playbackSpeed: Float
|
private val playbackSpeed: Float
|
||||||
get() = PreferenceHelper.getString(
|
get() = PreferenceHelper.getString(
|
||||||
PreferenceKeys.PLAYBACK_SPEED,
|
PreferenceKeys.PLAYBACK_SPEED,
|
||||||
"1"
|
"1"
|
||||||
@ -456,11 +465,16 @@ object PlayerHelper {
|
|||||||
for (category in LibreTubeApp.instance.resources.getStringArray(
|
for (category in LibreTubeApp.instance.resources.getStringArray(
|
||||||
R.array.sponsorBlockSegments
|
R.array.sponsorBlockSegments
|
||||||
)) {
|
)) {
|
||||||
val state = PreferenceHelper.getString(category + "_category", "off").uppercase()
|
val defaultCategoryValue = sbDefaultValues.getOrDefault(category, SbSkipOptions.OFF)
|
||||||
if (SbSkipOptions.valueOf(state) != SbSkipOptions.OFF) {
|
val skipOption = PreferenceHelper
|
||||||
categories[category] = SbSkipOptions.valueOf(state)
|
.getString("${category}_category", defaultCategoryValue.name)
|
||||||
|
.let { SbSkipOptions.valueOf(it.uppercase()) }
|
||||||
|
|
||||||
|
if (skipOption != SbSkipOptions.OFF) {
|
||||||
|
categories[category] = skipOption
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the highlights category to display in the chapters
|
// Add the highlights category to display in the chapters
|
||||||
if (sponsorBlockHighlights) categories[SPONSOR_HIGHLIGHT_CATEGORY] = SbSkipOptions.OFF
|
if (sponsorBlockHighlights) categories[SPONSOR_HIGHLIGHT_CATEGORY] = SbSkipOptions.OFF
|
||||||
return categories
|
return categories
|
||||||
|
@ -50,6 +50,8 @@
|
|||||||
|
|
||||||
<PreferenceCategory app:title="@string/category_segments">
|
<PreferenceCategory app:title="@string/category_segments">
|
||||||
|
|
||||||
|
<!-- When changing default values, they must also be changed in the PlayerHelper.kt file! -->
|
||||||
|
|
||||||
<com.github.libretube.ui.views.SbSpinnerPreference
|
<com.github.libretube.ui.views.SbSpinnerPreference
|
||||||
app:defaultValue="automatic"
|
app:defaultValue="automatic"
|
||||||
app:key="sponsor_category"
|
app:key="sponsor_category"
|
||||||
|
Loading…
Reference in New Issue
Block a user