mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
refactor: cleanup DashHelper.kt
This commit is contained in:
parent
8eac9d8a38
commit
9b296fe036
@ -7,7 +7,7 @@ import kotlin.io.path.Path
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class PipedStream(
|
data class PipedStream(
|
||||||
val url: String? = null,
|
var url: String? = null,
|
||||||
val format: String? = null,
|
val format: String? = null,
|
||||||
val quality: String? = null,
|
val quality: String? = null,
|
||||||
val mimeType: String? = null,
|
val mimeType: String? = null,
|
||||||
|
@ -40,17 +40,25 @@ object DashHelper {
|
|||||||
|
|
||||||
val adapSetInfos = ArrayList<AdapSetInfo>()
|
val adapSetInfos = ArrayList<AdapSetInfo>()
|
||||||
|
|
||||||
for (
|
for (stream in streams.videoStreams) {
|
||||||
stream in streams.videoStreams
|
|
||||||
// used to avoid including LBRY HLS inside the streams in the manifest
|
// used to avoid including LBRY HLS inside the streams in the manifest
|
||||||
.filter { !it.format.orEmpty().contains("HLS") }
|
if (stream.format.orEmpty().contains("HLS")) {
|
||||||
.filter { supportsHdr || !it.quality.orEmpty().uppercase().contains("HDR") }
|
continue
|
||||||
) {
|
}
|
||||||
|
|
||||||
|
// HDR is only supported by some new devices
|
||||||
|
if (!supportsHdr && stream.quality.orEmpty().uppercase().contains("HDR")) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// ignore dual format and OTF streams
|
// ignore dual format and OTF streams
|
||||||
if (!stream.videoOnly!! || stream.indexEnd!! <= 0) {
|
if (!stream.videoOnly!! || stream.indexEnd!! <= 0) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// only unwraps the url if the preference is set in the settings
|
||||||
|
stream.url = ProxyHelper.unwrapStreamUrl(stream.url.orEmpty())
|
||||||
|
|
||||||
val adapSetInfo = adapSetInfos.find { it.mimeType == stream.mimeType }
|
val adapSetInfo = adapSetInfos.find { it.mimeType == stream.mimeType }
|
||||||
if (adapSetInfo != null) {
|
if (adapSetInfo != null) {
|
||||||
adapSetInfo.formats.add(stream)
|
adapSetInfo.formats.add(stream)
|
||||||
@ -73,6 +81,10 @@ object DashHelper {
|
|||||||
adapSetInfo.formats.add(stream)
|
adapSetInfo.formats.add(stream)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// only unwraps the url if the preference is set in the settings
|
||||||
|
stream.url = ProxyHelper.unwrapStreamUrl(stream.url.orEmpty())
|
||||||
|
|
||||||
adapSetInfos.add(
|
adapSetInfos.add(
|
||||||
AdapSetInfo(
|
AdapSetInfo(
|
||||||
stream.mimeType!!,
|
stream.mimeType!!,
|
||||||
|
Loading…
Reference in New Issue
Block a user