diff --git a/app/src/main/java/com/github/libretube/api/ExternalApi.kt b/app/src/main/java/com/github/libretube/api/ExternalApi.kt index ab63bebc0..b8107dd46 100644 --- a/app/src/main/java/com/github/libretube/api/ExternalApi.kt +++ b/app/src/main/java/com/github/libretube/api/ExternalApi.kt @@ -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, diff --git a/app/src/main/java/com/github/libretube/api/StreamsExtractor.kt b/app/src/main/java/com/github/libretube/api/StreamsExtractor.kt index e1e10d951..236ee7d36 100644 --- a/app/src/main/java/com/github/libretube/api/StreamsExtractor.kt +++ b/app/src/main/java/com/github/libretube/api/StreamsExtractor.kt @@ -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, diff --git a/app/src/main/java/com/github/libretube/api/obj/VoteInfo.kt b/app/src/main/java/com/github/libretube/api/obj/VoteInfo.kt new file mode 100644 index 000000000..e6c8bcc26 --- /dev/null +++ b/app/src/main/java/com/github/libretube/api/obj/VoteInfo.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt index 7f0ae3674..14c7160b4 100644 --- a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt +++ b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt b/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt index 40a762c9b..22ff62a93 100644 --- a/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt +++ b/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt @@ -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, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b427dd1bc..4fcae4f37 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -512,6 +512,8 @@ Enter the package name of the app you want to use for downloading videos. Leave blank to use LibreTube\'s inbuilt downloader. Local stream extraction Directly fetch video playback information from YouTube without using Piped. + Local Return Youtube Dislikes + Directly fetch dislike information from https://returnyoutubedislikeapi.com Download Service diff --git a/app/src/main/res/xml/instance_settings.xml b/app/src/main/res/xml/instance_settings.xml index 578e36d75..37034dc1a 100644 --- a/app/src/main/res/xml/instance_settings.xml +++ b/app/src/main/res/xml/instance_settings.xml @@ -81,6 +81,14 @@ android:dependency="disable_video_image_proxy" app:key="local_stream_extraction" /> + + \ No newline at end of file