From 670c613f7126e3c6150c2613d25afeee67bf8358 Mon Sep 17 00:00:00 2001 From: LagradOst <11805592+LagradOst@users.noreply.github.com> Date: Sun, 15 May 2022 20:49:26 +0200 Subject: [PATCH] small fix to test and m3u8 --- .../com/lagradost/cloudstream3/ExampleInstrumentedTest.kt | 6 ++---- .../java/com/lagradost/cloudstream3/utils/M3u8Helper.kt | 7 +++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/androidTest/java/com/lagradost/cloudstream3/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/lagradost/cloudstream3/ExampleInstrumentedTest.kt index f0cb0a02..201ddea3 100644 --- a/app/src/androidTest/java/com/lagradost/cloudstream3/ExampleInstrumentedTest.kt +++ b/app/src/androidTest/java/com/lagradost/cloudstream3/ExampleInstrumentedTest.kt @@ -24,9 +24,7 @@ class ExampleInstrumentedTest { //} private fun getAllProviders(): List { - val allApis = APIHolder.apis - allApis.addAll(APIHolder.restrictedApis) - return allApis //.filter { !it.usesWebView } + return APIHolder.allProviders //.filter { !it.usesWebView } } private suspend fun loadLinks(api: MainAPI, url: String?): Boolean { @@ -113,7 +111,7 @@ class ExampleInstrumentedTest { continue } - val url = (load.episodes[load.episodes.keys.first()])?.first()?.url + val url = (load.episodes[load.episodes.keys.first()])?.first()?.data validResults = loadLinks(api, url) if (!validResults) continue } 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 993eae38..ba4fd37f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/M3u8Helper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/M3u8Helper.kt @@ -124,7 +124,10 @@ class M3u8Helper { app.get(m3u8.streamUrl, headers = m3u8.headers).text } + var hasAnyContent = false for (match in QUALITY_REGEX.findAll(response)) { + hasAnyContent = true + var (quality, m3u8Link, m3u8Link2) = match.destructured if (m3u8Link.isEmpty()) m3u8Link = m3u8Link2 if (absoluteExtensionDetermination(m3u8Link) == "m3u8") { @@ -152,11 +155,11 @@ class M3u8Helper { ) ) } - if (returnThis) { + if (returnThis || !hasAnyContent) { yield( M3u8Stream( m3u8.streamUrl, - 0, + Qualities.Unknown.value, m3u8.headers ) )