From 177b1e47f3f08110c07e3839a2d1935fe491a4da Mon Sep 17 00:00:00 2001 From: LagradOst <11805592+LagradOst@users.noreply.github.com> Date: Wed, 4 Oct 2023 11:33:55 +0200 Subject: [PATCH] added extra logging --- .../cloudstream3/ui/player/PreviewGenerator.kt | 11 +++++++++-- .../com/lagradost/cloudstream3/utils/M3u8Helper.kt | 12 ++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PreviewGenerator.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PreviewGenerator.kt index 53699782..946c1d33 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PreviewGenerator.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PreviewGenerator.kt @@ -81,6 +81,7 @@ class PreviewGenerator : IPreviewGenerator { } else -> { + Log.i("PreviewImg", "unsupported format for $link") currentGenerator.clear(keepCache) } } @@ -193,6 +194,7 @@ class M3u8PreviewGenerator : IPreviewGenerator { // no support for encryption atm if (hsl.isEncrypted) { + Log.i(TAG, "m3u8 is encrypted") totalImages = 0 return@withContext } @@ -239,12 +241,13 @@ class M3u8PreviewGenerator : IPreviewGenerator { if (!isActive) { return@withContext } - val frame = retriever.getFrameAtTime(0) + val img = retriever.getFrameAtTime(0) if (!isActive) { return@withContext } + if(img == null || img.width <= 1 || img.height <= 1) continue synchronized(images) { - images[index] = frame + images[index] = img loadedImages += 1 } } catch (t: Throwable) { @@ -302,6 +305,9 @@ class Mp4PreviewGenerator : IPreviewGenerator { if (idx > loadedImages) { break } + if(images[idx] == null) { + continue + } val currentFraction = (1.0f.div((1 shl l).toFloat()) + i * 1.0f.div(items.toFloat())) val diff = currentFraction.minus(fraction).absoluteValue @@ -382,6 +388,7 @@ class Mp4PreviewGenerator : IPreviewGenerator { MediaMetadataRetriever.OPTION_CLOSEST_SYNC ) if (!scope.isActive) return + if(img == null || img.width <= 1 || img.height <= 1) continue synchronized(images) { images[idx] = img loadedImages = maxOf(loadedImages, idx) diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/M3u8Helper.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/M3u8Helper.kt index d3fe7162..298f1601 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/M3u8Helper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/M3u8Helper.kt @@ -115,19 +115,19 @@ object M3u8Helper2 { private fun selectBest(qualities: List): M3u8Helper.M3u8Stream? { val result = qualities.sortedBy { - if (it.quality != null && it.quality <= 1080) it.quality else 0 - }.filter { + it.quality ?: Qualities.Unknown.value //if (it.quality != null && it.quality <= 1080) else 0 + }/*.filter { listOf("m3u", "m3u8").contains(absoluteExtensionDetermination(it.streamUrl)) - } + }*/ return result.lastOrNull() } private fun selectWorst(qualities: List): M3u8Helper.M3u8Stream? { val result = qualities.sortedBy { - if (it.quality != null && it.quality <= 1080) it.quality else 0 - }.filter { + it.quality ?: Qualities.Unknown.value //if (it.quality != null && it.quality <= 1080) else 0 + }/*.filter { listOf("m3u", "m3u8").contains(absoluteExtensionDetermination(it.streamUrl)) - } + }*/ return result.firstOrNull() }