mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 15:30:31 +05:30
cleanup sponsorblock
This commit is contained in:
parent
e4e71e6e80
commit
8474471691
@ -9,7 +9,7 @@ import com.github.libretube.api.obj.Playlist
|
||||
import com.github.libretube.api.obj.PlaylistId
|
||||
import com.github.libretube.api.obj.Playlists
|
||||
import com.github.libretube.api.obj.SearchResult
|
||||
import com.github.libretube.api.obj.Segments
|
||||
import com.github.libretube.api.obj.SegmentData
|
||||
import com.github.libretube.api.obj.StreamItem
|
||||
import com.github.libretube.api.obj.Streams
|
||||
import com.github.libretube.api.obj.Subscribe
|
||||
@ -36,7 +36,7 @@ interface PipedApi {
|
||||
suspend fun getSegments(
|
||||
@Path("videoId") videoId: String,
|
||||
@Query("category") category: String
|
||||
): Segments
|
||||
): SegmentData
|
||||
|
||||
@GET("nextpage/comments/{videoId}")
|
||||
suspend fun getCommentsNextPage(
|
||||
@ -48,7 +48,7 @@ interface PipedApi {
|
||||
suspend fun getSearchResults(
|
||||
@Query("q") searchQuery: String,
|
||||
@Query("filter") filter: String
|
||||
): com.github.libretube.api.obj.SearchResult
|
||||
): SearchResult
|
||||
|
||||
@GET("nextpage/search")
|
||||
suspend fun getSearchResultsNextPage(
|
||||
|
@ -4,7 +4,13 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
data class Segment(
|
||||
val UUID: String? = null,
|
||||
val actionType: String? = null,
|
||||
val category: String? = null,
|
||||
val segment: List<Float>? = arrayListOf()
|
||||
val description: String? = null,
|
||||
val locked: Int? = null,
|
||||
val segment: List<Double> = listOf(),
|
||||
val userID: String? = null,
|
||||
val videoDuration: Double? = null,
|
||||
val votes: Int? = null
|
||||
)
|
||||
|
@ -3,6 +3,8 @@ package com.github.libretube.api.obj
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
data class Segments(
|
||||
val segments: MutableList<Segment> = arrayListOf()
|
||||
data class SegmentData(
|
||||
val hash: String? = null,
|
||||
val segments: List<Segment> = listOf(),
|
||||
val videoID: String? = null
|
||||
)
|
@ -15,7 +15,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.api.RetrofitInstance
|
||||
import com.github.libretube.api.obj.Segment
|
||||
import com.github.libretube.api.obj.Segments
|
||||
import com.github.libretube.api.obj.SegmentData
|
||||
import com.github.libretube.api.obj.Streams
|
||||
import com.github.libretube.constants.BACKGROUND_CHANNEL_ID
|
||||
import com.github.libretube.constants.IntentData
|
||||
@ -72,7 +72,7 @@ class BackgroundMode : Service() {
|
||||
/**
|
||||
* SponsorBlock Segment data
|
||||
*/
|
||||
private var segmentData: Segments? = null
|
||||
private var segmentData: SegmentData? = null
|
||||
|
||||
/**
|
||||
* [Notification] for the player
|
||||
@ -325,7 +325,7 @@ class BackgroundMode : Service() {
|
||||
if (segmentData == null || segmentData!!.segments.isEmpty()) return
|
||||
|
||||
segmentData!!.segments.forEach { segment: Segment ->
|
||||
val segmentStart = (segment.segment!![0] * 1000f).toLong()
|
||||
val segmentStart = (segment.segment[0] * 1000f).toLong()
|
||||
val segmentEnd = (segment.segment[1] * 1000f).toLong()
|
||||
val currentPosition = player?.currentPosition
|
||||
if (currentPosition in segmentStart until segmentEnd) {
|
||||
|
@ -38,6 +38,8 @@ import com.github.libretube.R
|
||||
import com.github.libretube.api.CronetHelper
|
||||
import com.github.libretube.api.RetrofitInstance
|
||||
import com.github.libretube.api.SubscriptionHelper
|
||||
import com.github.libretube.api.obj.ChapterSegment
|
||||
import com.github.libretube.api.obj.SegmentData
|
||||
import com.github.libretube.constants.IntentData
|
||||
import com.github.libretube.constants.PreferenceKeys
|
||||
import com.github.libretube.constants.ShareObjectType
|
||||
@ -139,8 +141,8 @@ class PlayerFragment : BaseFragment() {
|
||||
*/
|
||||
private lateinit var exoPlayer: ExoPlayer
|
||||
private lateinit var trackSelector: DefaultTrackSelector
|
||||
private lateinit var segmentData: com.github.libretube.api.obj.Segments
|
||||
private lateinit var chapters: List<com.github.libretube.api.obj.ChapterSegment>
|
||||
private lateinit var segmentData: SegmentData
|
||||
private lateinit var chapters: List<ChapterSegment>
|
||||
|
||||
/**
|
||||
* for the player view
|
||||
@ -598,7 +600,7 @@ class PlayerFragment : BaseFragment() {
|
||||
|
||||
val currentPosition = exoPlayer.currentPosition
|
||||
segmentData.segments.forEach { segment: com.github.libretube.api.obj.Segment ->
|
||||
val segmentStart = (segment.segment!![0] * 1000f).toLong()
|
||||
val segmentStart = (segment.segment[0] * 1000f).toLong()
|
||||
val segmentEnd = (segment.segment[1] * 1000f).toLong()
|
||||
|
||||
// show the button to manually skip the segment
|
||||
|
@ -43,7 +43,7 @@ class MarkableTimeBar(
|
||||
segments.forEach {
|
||||
canvas.drawRect(
|
||||
Rect(
|
||||
(it.segment!!.first() + HORIZONTAL_OFFSET).toLength(),
|
||||
(it.segment.first() + HORIZONTAL_OFFSET).toLength(),
|
||||
marginY,
|
||||
(it.segment.last() + HORIZONTAL_OFFSET).toLength(),
|
||||
canvas.height - marginY - 1
|
||||
@ -56,7 +56,7 @@ class MarkableTimeBar(
|
||||
canvas.restore()
|
||||
}
|
||||
|
||||
private fun Float.toLength(): Int {
|
||||
private fun Double.toLength(): Int {
|
||||
return (this * 1000 / player!!.duration * length).toInt()
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ object LocaleHelper {
|
||||
val dm = res.displayMetrics
|
||||
val conf = res.configuration
|
||||
conf.setLocale(locale)
|
||||
@Suppress("DEPRECATION")
|
||||
res.updateConfiguration(conf, dm)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user