Skip to content

Commit

Permalink
fix(lib/playlistutils): Keep query for m3u8 requests (#3032)
Browse files Browse the repository at this point in the history
  • Loading branch information
Secozzi authored Mar 10, 2024
1 parent 49f8ed9 commit 0bed9f9
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import eu.kanade.tachiyomi.animesource.model.Video
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Headers
import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient
import okhttp3.internal.commonEmptyHeaders
Expand Down Expand Up @@ -105,9 +106,8 @@ class PlaylistUtils(private val client: OkHttpClient, private val headers: Heade
val masterUrlBasePath = playlistHttpUrl.newBuilder().apply {
removePathSegment(playlistHttpUrl.pathSize - 1)
addPathSegment("")
query(null)
fragment(null)
}.build().toString()
}.build()

// Get subtitles
val subtitleTracks = subtitleList + SUBTITLE_REGEX.findAll(masterPlaylist).mapNotNull {
Expand Down Expand Up @@ -146,14 +146,14 @@ class PlaylistUtils(private val client: OkHttpClient, private val headers: Heade
}
}

private fun getAbsoluteUrl(url: String, playlistUrl: String, masterBase: String): String? {
private fun getAbsoluteUrl(url: String, playlistUrl: String, masterBase: HttpUrl): String? {
return when {
url.isEmpty() -> null
url.startsWith("http") -> url
url.startsWith("//") -> "https:$url"
url.startsWith("/") -> playlistUrl.toHttpUrl().newBuilder().encodedPath("/").build().toString()
.substringBeforeLast("/") + url
else -> masterBase + url
else -> masterBase.newBuilder().addEncodedPathSegments(url).build().toString()
}
}

Expand Down

0 comments on commit 0bed9f9

Please sign in to comment.