Skip to content

Commit

Permalink
add proxy support to NewPipeDownloaderImpl & YTPlayerUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
gechoto authored Jan 9, 2025
1 parent 01f4df1 commit 18c7caa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/src/main/java/com/zionhuang/music/utils/YTPlayerUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import okhttp3.OkHttpClient

object YTPlayerUtils {

private val httpClient = OkHttpClient.Builder().build()
private val httpClient = OkHttpClient.Builder()
.proxy(YouTube.proxy)
.build()

/**
* The main client is used for metadata and initial streams.
Expand Down
9 changes: 6 additions & 3 deletions innertube/src/main/java/com/zionhuang/innertube/NewPipe.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException
import org.schabi.newpipe.extractor.services.youtube.YoutubeJavaScriptPlayerManager
import java.io.IOException
import java.net.Proxy

private object NewPipeDownloaderImpl : Downloader() {
private class NewPipeDownloaderImpl(proxy: Proxy?) : Downloader() {

private val client = OkHttpClient.Builder().build()
private val client = OkHttpClient.Builder()
.proxy(proxy)
.build()

@Throws(IOException::class, ReCaptchaException::class)
override fun execute(request: Request): Response {
Expand Down Expand Up @@ -61,7 +64,7 @@ private object NewPipeDownloaderImpl : Downloader() {
object NewPipeUtils {

init {
NewPipe.init(NewPipeDownloaderImpl)
NewPipe.init(NewPipeDownloaderImpl(YouTube.proxy))
}

fun getSignatureTimestamp(videoId: String): Result<Int> = runCatching {
Expand Down

0 comments on commit 18c7caa

Please sign in to comment.