mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 15:30:31 +05:30
refactor(MediaServiceRepository): use lists for SponsorBlock categories
According to the SponsorBlock API documentation categories and actionTypes are string arrays.
This commit is contained in:
parent
4f4b090fc0
commit
2497fa8702
@ -17,8 +17,8 @@ interface MediaServiceRepository {
|
||||
suspend fun getComments(videoId: String): CommentsPage
|
||||
suspend fun getSegments(
|
||||
videoId: String,
|
||||
category: String,
|
||||
actionType: String? = null
|
||||
category: List<String>,
|
||||
actionType: List<String>? = null
|
||||
): SegmentData
|
||||
|
||||
suspend fun getDeArrowContent(videoIds: String): Map<String, DeArrowContent>
|
||||
|
@ -13,6 +13,7 @@ import com.github.libretube.api.obj.StreamItem
|
||||
import com.github.libretube.api.obj.Streams
|
||||
import com.github.libretube.constants.PreferenceKeys
|
||||
import com.github.libretube.helpers.PreferenceHelper
|
||||
import kotlinx.serialization.encodeToString
|
||||
import retrofit2.HttpException
|
||||
|
||||
open class PipedMediaServiceRepository : MediaServiceRepository {
|
||||
@ -36,9 +37,13 @@ open class PipedMediaServiceRepository : MediaServiceRepository {
|
||||
|
||||
override suspend fun getSegments(
|
||||
videoId: String,
|
||||
category: String,
|
||||
actionType: String?
|
||||
): SegmentData = api.getSegments(videoId, category, actionType)
|
||||
category: List<String>,
|
||||
actionType: List<String>?
|
||||
): SegmentData = api.getSegments(
|
||||
videoId,
|
||||
JsonHelper.json.encodeToString(category),
|
||||
JsonHelper.json.encodeToString(actionType)
|
||||
)
|
||||
|
||||
override suspend fun getDeArrowContent(videoIds: String): Map<String, DeArrowContent> =
|
||||
api.getDeArrowContent(videoIds)
|
||||
|
@ -209,8 +209,8 @@ open class OnlinePlayerService : AbstractPlayerService() {
|
||||
if (sponsorBlockConfig.isEmpty()) return@runCatching
|
||||
sponsorBlockSegments = MediaServiceRepository.instance.getSegments(
|
||||
videoId,
|
||||
JsonHelper.json.encodeToString(sponsorBlockConfig.keys),
|
||||
"""["skip","mute","full","poi","chapter"]"""
|
||||
sponsorBlockConfig.keys.toList(),
|
||||
listOf("skip","mute","full","poi","chapter")
|
||||
).segments
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
|
@ -147,7 +147,7 @@ class SubmitSegmentDialog : DialogFragment() {
|
||||
private suspend fun fetchSegments() {
|
||||
val categories = resources.getStringArray(R.array.sponsorBlockSegments).toList()
|
||||
segments = try {
|
||||
MediaServiceRepository.instance.getSegments(videoId, JsonHelper.json.encodeToString(categories)).segments
|
||||
MediaServiceRepository.instance.getSegments(videoId, categories).segments
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG(), e.toString())
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user