mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 08:20:32 +05:30
avoid duplicated resolutions
This commit is contained in:
parent
58c606c858
commit
c766fb953b
@ -1087,12 +1087,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
val videoStreams = try {
|
val videoStreams = try {
|
||||||
// attempt to sort the qualities, catch if there was an error ih parsing
|
// attempt to sort the qualities, catch if there was an error ih parsing
|
||||||
streams.videoStreams?.sortedBy {
|
streams.videoStreams?.sortedBy {
|
||||||
it.quality
|
it.quality?.toLong() ?: 0L
|
||||||
.toString()
|
|
||||||
.split("p")
|
|
||||||
.first()
|
|
||||||
.replace("p", "")
|
|
||||||
.toLong()
|
|
||||||
}?.reversed()
|
}?.reversed()
|
||||||
.orEmpty()
|
.orEmpty()
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
@ -1102,14 +1097,20 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
for (vid in videoStreams) {
|
for (vid in videoStreams) {
|
||||||
// append quality to list if it has the preferred format (e.g. MPEG)
|
// append quality to list if it has the preferred format (e.g. MPEG)
|
||||||
val preferredMimeType = "video/${PlayerHelper.videoFormatPreference}"
|
val preferredMimeType = "video/${PlayerHelper.videoFormatPreference}"
|
||||||
if (vid.url != null && vid.mimeType == preferredMimeType) { // preferred format
|
if (vid.url != null && vid.mimeType == preferredMimeType) {
|
||||||
|
// avoid duplicated resolutions
|
||||||
|
if (resolutions.any {
|
||||||
|
it.resolution == vid.quality.toString().split("p").first().toInt()
|
||||||
|
}
|
||||||
|
) continue
|
||||||
|
|
||||||
resolutions.add(
|
resolutions.add(
|
||||||
VideoResolution(
|
VideoResolution(
|
||||||
name = vid.quality!!,
|
name = vid.quality!!,
|
||||||
resolution = vid.quality.toString().split("p").first().toInt()
|
resolution = vid.quality.toString().split("p").first().toInt()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
} else if (vid.quality.equals("LBRY") && vid.format.equals("MP4")) { // LBRY MP4 format
|
} else if (vid.quality.equals("LBRY") && vid.format.equals("MP4")) {
|
||||||
resolutions.add(
|
resolutions.add(
|
||||||
VideoResolution(
|
VideoResolution(
|
||||||
name = "LBRY MP4",
|
name = "LBRY MP4",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user