Merged with dark25 (#636)
* merge merged lib, lib-multisrc, all, ar, de, en, es, fr, hi, id, it, pt, tr src from dark25 * patch
This commit is contained in:
parent
9f385108fc
commit
1384df62f3
350 changed files with 12176 additions and 1064 deletions
|
@ -8,6 +8,7 @@ import okhttp3.Headers
|
|||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.internal.commonEmptyHeaders
|
||||
import kotlin.math.abs
|
||||
|
||||
class PlaylistUtils(private val client: OkHttpClient, private val headers: Headers = commonEmptyHeaders) {
|
||||
|
||||
|
@ -126,10 +127,16 @@ class PlaylistUtils(private val client: OkHttpClient, private val headers: Heade
|
|||
}.toList()
|
||||
|
||||
return masterPlaylist.substringAfter(PLAYLIST_SEPARATOR).split(PLAYLIST_SEPARATOR).mapNotNull {
|
||||
val codec = it.substringAfter("CODECS=\"", "").substringBefore("\"", "")
|
||||
if (codec.isNotEmpty()) {
|
||||
if (codec.startsWith("mp4a")) return@mapNotNull null
|
||||
}
|
||||
|
||||
|
||||
val resolution = it.substringAfter("RESOLUTION=")
|
||||
.substringBefore("\n")
|
||||
.substringAfter("x")
|
||||
.substringBefore(",") + "p"
|
||||
.substringBefore(",").let(::stnQuality)
|
||||
|
||||
val videoUrl = it.substringAfter("\n").substringBefore("\n").let { url ->
|
||||
getAbsoluteUrl(url, playlistUrl, masterUrlBasePath)?.trimEnd()
|
||||
|
@ -328,6 +335,13 @@ class PlaylistUtils(private val client: OkHttpClient, private val headers: Heade
|
|||
|
||||
// ============================= Utilities ==============================
|
||||
|
||||
private fun stnQuality(quality: String): String {
|
||||
val intQuality = quality.toInt()
|
||||
val standardQualities = listOf(144, 240, 360, 480, 720, 1080)
|
||||
val result = standardQualities.minByOrNull { abs(it - intQuality) } ?: quality
|
||||
return "${result}p"
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val PLAYLIST_SEPARATOR = "#EXT-X-STREAM-INF:"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue