Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: RYD support for local stream extraction #6483

Merged
merged 4 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/src/main/java/com/github/libretube/api/ExternalApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
janisslsm marked this conversation as resolved.
Show resolved Hide resolved
}.getOrElse { -1 } else -1,
license = resp.licence,
hls = resp.hlsUrl,
dash = resp.dashMpdUrl,
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/com/github/libretube/api/obj/VoteInfo.kt
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/xml/instance_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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