mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
feat: RYD support for local stream extraction (#6483)
* feat: RYD support for local stream extraction * add a switch * use runCatching * move check outside if statement additionally return -1 if no dislikes were fetched. --------- Co-authored-by: Bnyro <bnyro@tutanota.com>
This commit is contained in:
parent
bf99635b48
commit
66ccdf1b84
@ -3,6 +3,7 @@ package com.github.libretube.api
|
||||
import com.github.libretube.api.obj.DeArrowBody
|
||||
import com.github.libretube.api.obj.PipedInstance
|
||||
import com.github.libretube.api.obj.SubmitSegmentResponse
|
||||
import com.github.libretube.api.obj.VoteInfo
|
||||
import com.github.libretube.obj.update.UpdateInfo
|
||||
import retrofit2.http.Body
|
||||
import retrofit2.http.GET
|
||||
@ -12,6 +13,7 @@ import retrofit2.http.Url
|
||||
|
||||
private const val GITHUB_API_URL = "https://api.github.com/repos/libre-tube/LibreTube/releases/latest"
|
||||
private const val SB_API_URL = "https://sponsor.ajay.app"
|
||||
private const val RYD_API_URL = "https://returnyoutubedislikeapi.com"
|
||||
|
||||
interface ExternalApi {
|
||||
// only for fetching servers list
|
||||
@ -22,6 +24,9 @@ interface ExternalApi {
|
||||
@GET(GITHUB_API_URL)
|
||||
suspend fun getLatestRelease(): UpdateInfo
|
||||
|
||||
@GET("$RYD_API_URL/votes")
|
||||
suspend fun getVotes(@Query("videoId") videoId: String): VoteInfo
|
||||
|
||||
@POST("$SB_API_URL/api/skipSegments")
|
||||
suspend fun submitSegment(
|
||||
@Query("videoID") videoId: String,
|
||||
|
@ -58,6 +58,9 @@ object StreamsExtractor {
|
||||
category = resp.category,
|
||||
views = resp.viewCount,
|
||||
likes = resp.likeCount,
|
||||
dislikes = if (PlayerHelper.localRYD) runCatching {
|
||||
RetrofitInstance.externalApi.getVotes(videoId).dislikes
|
||||
}.getOrElse { -1 } else -1,
|
||||
license = resp.licence,
|
||||
hls = resp.hlsUrl,
|
||||
dash = resp.dashMpdUrl,
|
||||
|
17
app/src/main/java/com/github/libretube/api/obj/VoteInfo.kt
Normal file
17
app/src/main/java/com/github/libretube/api/obj/VoteInfo.kt
Normal file
@ -0,0 +1,17 @@
|
||||
package com.github.libretube.api.obj
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@Parcelize
|
||||
data class VoteInfo(
|
||||
val likes: Long,
|
||||
val rawDislikes: Long,
|
||||
val rawLikes: Long,
|
||||
val dislikes: Long,
|
||||
val rating: Float,
|
||||
val viewCount: Long,
|
||||
val deleted: Boolean
|
||||
) : Parcelable
|
@ -128,6 +128,7 @@ object PreferenceKeys {
|
||||
const val MAX_CONCURRENT_DOWNLOADS = "max_parallel_downloads"
|
||||
const val EXTERNAL_DOWNLOAD_PROVIDER = "external_download_provider"
|
||||
const val DISABLE_VIDEO_IMAGE_PROXY = "disable_video_image_proxy"
|
||||
const val LOCAL_RYD = "local_return_youtube_dislikes"
|
||||
const val LOCAL_STREAM_EXTRACTION = "local_stream_extraction"
|
||||
|
||||
// History
|
||||
|
@ -356,6 +356,12 @@ object PlayerHelper {
|
||||
true
|
||||
)
|
||||
|
||||
val localRYD: Boolean
|
||||
get() = PreferenceHelper.getBoolean(
|
||||
PreferenceKeys.LOCAL_RYD,
|
||||
true
|
||||
)
|
||||
|
||||
val useHlsOverDash: Boolean
|
||||
get() = PreferenceHelper.getBoolean(
|
||||
PreferenceKeys.USE_HLS_OVER_DASH,
|
||||
|
@ -512,6 +512,8 @@
|
||||
<string name="external_download_provider_summary">Enter the package name of the app you want to use for downloading videos. Leave blank to use LibreTube\'s inbuilt downloader.</string>
|
||||
<string name="local_stream_extraction">Local stream extraction</string>
|
||||
<string name="local_stream_extraction_summary">Directly fetch video playback information from YouTube without using Piped.</string>
|
||||
<string name="local_ryd">Local Return Youtube Dislikes</string>
|
||||
<string name="local_ryd_summary">Directly fetch dislike information from https://returnyoutubedislikeapi.com</string>
|
||||
|
||||
<!-- Notification channel strings -->
|
||||
<string name="download_channel_name">Download Service</string>
|
||||
|
@ -81,6 +81,14 @@
|
||||
android:dependency="disable_video_image_proxy"
|
||||
app:key="local_stream_extraction" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:icon="@drawable/ic_dislike"
|
||||
android:summary="@string/local_ryd_summary"
|
||||
android:title="@string/local_ryd"
|
||||
android:dependency="local_stream_extraction"
|
||||
app:key="local_return_youtube_dislikes" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user