added extra logging

This commit is contained in:
LagradOst 2023-10-04 11:33:55 +02:00
parent 3f5119525c
commit 177b1e47f3
2 changed files with 15 additions and 8 deletions

View file

@ -81,6 +81,7 @@ class PreviewGenerator : IPreviewGenerator {
} }
else -> { else -> {
Log.i("PreviewImg", "unsupported format for $link")
currentGenerator.clear(keepCache) currentGenerator.clear(keepCache)
} }
} }
@ -193,6 +194,7 @@ class M3u8PreviewGenerator : IPreviewGenerator {
// no support for encryption atm // no support for encryption atm
if (hsl.isEncrypted) { if (hsl.isEncrypted) {
Log.i(TAG, "m3u8 is encrypted")
totalImages = 0 totalImages = 0
return@withContext return@withContext
} }
@ -239,12 +241,13 @@ class M3u8PreviewGenerator : IPreviewGenerator {
if (!isActive) { if (!isActive) {
return@withContext return@withContext
} }
val frame = retriever.getFrameAtTime(0) val img = retriever.getFrameAtTime(0)
if (!isActive) { if (!isActive) {
return@withContext return@withContext
} }
if(img == null || img.width <= 1 || img.height <= 1) continue
synchronized(images) { synchronized(images) {
images[index] = frame images[index] = img
loadedImages += 1 loadedImages += 1
} }
} catch (t: Throwable) { } catch (t: Throwable) {
@ -302,6 +305,9 @@ class Mp4PreviewGenerator : IPreviewGenerator {
if (idx > loadedImages) { if (idx > loadedImages) {
break break
} }
if(images[idx] == null) {
continue
}
val currentFraction = val currentFraction =
(1.0f.div((1 shl l).toFloat()) + i * 1.0f.div(items.toFloat())) (1.0f.div((1 shl l).toFloat()) + i * 1.0f.div(items.toFloat()))
val diff = currentFraction.minus(fraction).absoluteValue val diff = currentFraction.minus(fraction).absoluteValue
@ -382,6 +388,7 @@ class Mp4PreviewGenerator : IPreviewGenerator {
MediaMetadataRetriever.OPTION_CLOSEST_SYNC MediaMetadataRetriever.OPTION_CLOSEST_SYNC
) )
if (!scope.isActive) return if (!scope.isActive) return
if(img == null || img.width <= 1 || img.height <= 1) continue
synchronized(images) { synchronized(images) {
images[idx] = img images[idx] = img
loadedImages = maxOf(loadedImages, idx) loadedImages = maxOf(loadedImages, idx)

View file

@ -115,19 +115,19 @@ object M3u8Helper2 {
private fun selectBest(qualities: List<M3u8Helper.M3u8Stream>): M3u8Helper.M3u8Stream? { private fun selectBest(qualities: List<M3u8Helper.M3u8Stream>): M3u8Helper.M3u8Stream? {
val result = qualities.sortedBy { val result = qualities.sortedBy {
if (it.quality != null && it.quality <= 1080) it.quality else 0 it.quality ?: Qualities.Unknown.value //if (it.quality != null && it.quality <= 1080) else 0
}.filter { }/*.filter {
listOf("m3u", "m3u8").contains(absoluteExtensionDetermination(it.streamUrl)) listOf("m3u", "m3u8").contains(absoluteExtensionDetermination(it.streamUrl))
} }*/
return result.lastOrNull() return result.lastOrNull()
} }
private fun selectWorst(qualities: List<M3u8Helper.M3u8Stream>): M3u8Helper.M3u8Stream? { private fun selectWorst(qualities: List<M3u8Helper.M3u8Stream>): M3u8Helper.M3u8Stream? {
val result = qualities.sortedBy { val result = qualities.sortedBy {
if (it.quality != null && it.quality <= 1080) it.quality else 0 it.quality ?: Qualities.Unknown.value //if (it.quality != null && it.quality <= 1080) else 0
}.filter { }/*.filter {
listOf("m3u", "m3u8").contains(absoluteExtensionDetermination(it.streamUrl)) listOf("m3u", "m3u8").contains(absoluteExtensionDetermination(it.streamUrl))
} }*/
return result.firstOrNull() return result.firstOrNull()
} }