From eee80becbef915b6590f361e2d42baa83d6b6571 Mon Sep 17 00:00:00 2001 From: C10udburst <18114966+C10udburst@users.noreply.github.com> Date: Sat, 6 Aug 2022 10:13:21 +0200 Subject: [PATCH] fix again --- .github/workflows/prerelease.yml | 8 +- app/build.gradle | 43 +- .../lagradost/cloudstream3/ProviderTests.kt | 400 +++++++++--------- 3 files changed, 231 insertions(+), 220 deletions(-) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 9162bba9..19df6708 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -40,9 +40,9 @@ jobs: # echo $ENCODED_STRING | base64 -di > "${TMP_KEYSTORE_FILE_PATH}"/prerelease_keystore.keystore - name: Run Gradle run: | - ./gradlew app:assembleDebug - ./gradlew app:androidSourcesJar - ./gradlew build || true + ./gradlew assembleDebug + ./gradlew androidSourcesJar + ./gradlew makeJar # env: # SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }} # SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} @@ -61,4 +61,4 @@ jobs: files: | app/build/outputs/apk/debug/*.apk app/build/libs/app-sources.jar - app/build/intermediates/compile_app_classes_jar/debug/classes.jar + app/build/classes.jar diff --git a/app/build.gradle b/app/build.gradle index 7013eb61..aee896b8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -51,22 +51,22 @@ android { } buildTypes { - release { - debuggable false - minifyEnabled false - shrinkResources false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - prerelease { - applicationIdSuffix ".prerelease" - buildConfigField("boolean", "BETA", "true") - signingConfig signingConfigs.prerelease - versionNameSuffix '-PRE' - debuggable false - minifyEnabled false - shrinkResources false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + // release { + // debuggable false + // minifyEnabled false + // shrinkResources false + // proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + // } + // prerelease { + // applicationIdSuffix ".prerelease" + // buildConfigField("boolean", "BETA", "true") + // signingConfig signingConfigs.prerelease + // versionNameSuffix '-PRE' + // debuggable false + // minifyEnabled false + // shrinkResources false + // proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + // } debug { debuggable true applicationIdSuffix ".debug" @@ -83,6 +83,10 @@ android { jvmTarget = '1.8' freeCompilerArgs = ['-Xjvm-default=compatibility'] } + lintOptions { + checkReleaseBuilds false + abortOnError false + } } repositories { @@ -188,4 +192,11 @@ dependencies { task androidSourcesJar(type: Jar) { getArchiveClassifier().set('sources') from android.sourceSets.main.java.srcDirs//full sources +} + +task makeJar(type: Copy) { + from('build/intermediates/compile_app_classes_jar/debug') // after modifying here, you can export. Jar + into('build') // output location + include('classes.jar') // the classes file of the imported rack package + dependsOn build } \ No newline at end of file diff --git a/app/src/test/java/com/lagradost/cloudstream3/ProviderTests.kt b/app/src/test/java/com/lagradost/cloudstream3/ProviderTests.kt index 1c3b4b1b..34bd9f18 100644 --- a/app/src/test/java/com/lagradost/cloudstream3/ProviderTests.kt +++ b/app/src/test/java/com/lagradost/cloudstream3/ProviderTests.kt @@ -1,220 +1,220 @@ package com.lagradost.cloudstream3 -import com.lagradost.cloudstream3.APIHolder.allProviders -import com.lagradost.cloudstream3.mvvm.logError -import com.lagradost.cloudstream3.utils.Qualities -import com.lagradost.cloudstream3.utils.SubtitleHelper -import kotlinx.coroutines.runBlocking -import org.junit.Assert -import org.junit.Test +// import com.lagradost.cloudstream3.APIHolder.allProviders +// import com.lagradost.cloudstream3.mvvm.logError +// import com.lagradost.cloudstream3.utils.Qualities +// import com.lagradost.cloudstream3.utils.SubtitleHelper +// import kotlinx.coroutines.runBlocking +// import org.junit.Assert +// import org.junit.Test class ProviderTests { - private fun getAllProviders(): List { - return allProviders.filter { !it.usesWebView } - } +// private fun getAllProviders(): List { +// return allProviders.filter { !it.usesWebView } +// } - private suspend fun loadLinks(api: MainAPI, url: String?): Boolean { - Assert.assertNotNull("Api ${api.name} has invalid url on episode", url) - if (url == null) return true - var linksLoaded = 0 - try { - val success = api.loadLinks(url, false, {}) { link -> - Assert.assertTrue( - "Api ${api.name} returns link with invalid Quality", - Qualities.values().map { it.value }.contains(link.quality) - ) - Assert.assertTrue( - "Api ${api.name} returns link with invalid url", - link.url.length > 4 - ) - linksLoaded++ - } - if (success) { - return linksLoaded > 0 - } - Assert.assertTrue("Api ${api.name} has returns false on .loadLinks", success) - } catch (e: Exception) { - if (e.cause is NotImplementedError) { - Assert.fail("Provider has not implemented .loadLinks") - } - logError(e) - } - return true - } +// private suspend fun loadLinks(api: MainAPI, url: String?): Boolean { +// Assert.assertNotNull("Api ${api.name} has invalid url on episode", url) +// if (url == null) return true +// var linksLoaded = 0 +// try { +// val success = api.loadLinks(url, false, {}) { link -> +// Assert.assertTrue( +// "Api ${api.name} returns link with invalid Quality", +// Qualities.values().map { it.value }.contains(link.quality) +// ) +// Assert.assertTrue( +// "Api ${api.name} returns link with invalid url", +// link.url.length > 4 +// ) +// linksLoaded++ +// } +// if (success) { +// return linksLoaded > 0 +// } +// Assert.assertTrue("Api ${api.name} has returns false on .loadLinks", success) +// } catch (e: Exception) { +// if (e.cause is NotImplementedError) { +// Assert.fail("Provider has not implemented .loadLinks") +// } +// logError(e) +// } +// return true +// } - private suspend fun testSingleProviderApi(api: MainAPI): Boolean { - val searchQueries = listOf("over", "iron", "guy") - var correctResponses = 0 - var searchResult: List? = null - for (query in searchQueries) { - val response = try { - api.search(query) - } catch (e: Exception) { - if (e.cause is NotImplementedError) { - Assert.fail("Provider has not implemented .search") - } - logError(e) - null - } - if (!response.isNullOrEmpty()) { - correctResponses++ - if (searchResult == null) { - searchResult = response - } - } - } +// private suspend fun testSingleProviderApi(api: MainAPI): Boolean { +// val searchQueries = listOf("over", "iron", "guy") +// var correctResponses = 0 +// var searchResult: List? = null +// for (query in searchQueries) { +// val response = try { +// api.search(query) +// } catch (e: Exception) { +// if (e.cause is NotImplementedError) { +// Assert.fail("Provider has not implemented .search") +// } +// logError(e) +// null +// } +// if (!response.isNullOrEmpty()) { +// correctResponses++ +// if (searchResult == null) { +// searchResult = response +// } +// } +// } - if (correctResponses == 0 || searchResult == null) { - System.err.println("Api ${api.name} did not return any valid search responses") - return false - } +// if (correctResponses == 0 || searchResult == null) { +// System.err.println("Api ${api.name} did not return any valid search responses") +// return false +// } - try { - var validResults = false - for (result in searchResult) { - Assert.assertEquals( - "Invalid apiName on response on ${api.name}", - result.apiName, - api.name - ) - val load = api.load(result.url) ?: continue - Assert.assertEquals( - "Invalid apiName on load on ${api.name}", - load.apiName, - result.apiName - ) - Assert.assertTrue( - "Api ${api.name} on load does not contain any of the supportedTypes", - api.supportedTypes.contains(load.type) - ) - when (load) { - is AnimeLoadResponse -> { - val gotNoEpisodes = - load.episodes.keys.isEmpty() || load.episodes.keys.any { load.episodes[it].isNullOrEmpty() } +// try { +// var validResults = false +// for (result in searchResult) { +// Assert.assertEquals( +// "Invalid apiName on response on ${api.name}", +// result.apiName, +// api.name +// ) +// val load = api.load(result.url) ?: continue +// Assert.assertEquals( +// "Invalid apiName on load on ${api.name}", +// load.apiName, +// result.apiName +// ) +// Assert.assertTrue( +// "Api ${api.name} on load does not contain any of the supportedTypes", +// api.supportedTypes.contains(load.type) +// ) +// when (load) { +// is AnimeLoadResponse -> { +// val gotNoEpisodes = +// load.episodes.keys.isEmpty() || load.episodes.keys.any { load.episodes[it].isNullOrEmpty() } - if (gotNoEpisodes) { - println("Api ${api.name} got no episodes on ${load.url}") - continue - } +// if (gotNoEpisodes) { +// println("Api ${api.name} got no episodes on ${load.url}") +// continue +// } - val url = (load.episodes[load.episodes.keys.first()])?.first()?.data - validResults = loadLinks(api, url) - if (!validResults) continue - } - is MovieLoadResponse -> { - val gotNoEpisodes = load.dataUrl.isBlank() - if (gotNoEpisodes) { - println("Api ${api.name} got no movie on ${load.url}") - continue - } +// val url = (load.episodes[load.episodes.keys.first()])?.first()?.data +// validResults = loadLinks(api, url) +// if (!validResults) continue +// } +// is MovieLoadResponse -> { +// val gotNoEpisodes = load.dataUrl.isBlank() +// if (gotNoEpisodes) { +// println("Api ${api.name} got no movie on ${load.url}") +// continue +// } - validResults = loadLinks(api, load.dataUrl) - if (!validResults) continue - } - is TvSeriesLoadResponse -> { - val gotNoEpisodes = load.episodes.isEmpty() - if (gotNoEpisodes) { - println("Api ${api.name} got no episodes on ${load.url}") - continue - } +// validResults = loadLinks(api, load.dataUrl) +// if (!validResults) continue +// } +// is TvSeriesLoadResponse -> { +// val gotNoEpisodes = load.episodes.isEmpty() +// if (gotNoEpisodes) { +// println("Api ${api.name} got no episodes on ${load.url}") +// continue +// } - validResults = loadLinks(api, load.episodes.first().data) - if (!validResults) continue - } - } - break - } +// validResults = loadLinks(api, load.episodes.first().data) +// if (!validResults) continue +// } +// } +// break +// } - Assert.assertTrue("Api ${api.name} did not load on any}", validResults) - } catch (e: Exception) { - if (e.cause is NotImplementedError) { - Assert.fail("Provider has not implemented .load") - } - logError(e) - return false - } - return true - } +// Assert.assertTrue("Api ${api.name} did not load on any}", validResults) +// } catch (e: Exception) { +// if (e.cause is NotImplementedError) { +// Assert.fail("Provider has not implemented .load") +// } +// logError(e) +// return false +// } +// return true +// } - @Test - fun providersExist() { - Assert.assertTrue(getAllProviders().isNotEmpty()) - } +// @Test +// fun providersExist() { +// Assert.assertTrue(getAllProviders().isNotEmpty()) +// } - @Test - fun providerCorrectData() { - val isoNames = SubtitleHelper.languages.map { it.ISO_639_1 } - Assert.assertFalse("ISO does not contain any languages", isoNames.isNullOrEmpty()) - for (api in getAllProviders()) { - Assert.assertTrue("Api does not contain a mainUrl", api.mainUrl != "NONE") - Assert.assertTrue("Api does not contain a name", api.name != "NONE") - Assert.assertTrue( - "Api ${api.name} does not contain a valid language code", - isoNames.contains(api.lang) - ) - Assert.assertTrue( - "Api ${api.name} does not contain any supported types", - api.supportedTypes.isNotEmpty() - ) - } - } +// @Test +// fun providerCorrectData() { +// val isoNames = SubtitleHelper.languages.map { it.ISO_639_1 } +// Assert.assertFalse("ISO does not contain any languages", isoNames.isNullOrEmpty()) +// for (api in getAllProviders()) { +// Assert.assertTrue("Api does not contain a mainUrl", api.mainUrl != "NONE") +// Assert.assertTrue("Api does not contain a name", api.name != "NONE") +// Assert.assertTrue( +// "Api ${api.name} does not contain a valid language code", +// isoNames.contains(api.lang) +// ) +// Assert.assertTrue( +// "Api ${api.name} does not contain any supported types", +// api.supportedTypes.isNotEmpty() +// ) +// } +// } - @Test - fun providerCorrectHomepage() { - runBlocking { - getAllProviders().apmap { api -> - if (api.hasMainPage) { - try { - val homepage = api.getMainPage() - when { - homepage == null -> { - Assert.fail("Homepage provider ${api.name} did not correctly load homepage!") - } - homepage.items.isEmpty() -> { - Assert.fail("Homepage provider ${api.name} does not contain any items!") - } - homepage.items.any { it.list.isEmpty() } -> { - Assert.fail("Homepage provider ${api.name} does not have any items on result!") - } - } - } catch (e: Exception) { - if (e.cause is NotImplementedError) { - Assert.fail("Provider marked as hasMainPage, while in reality is has not been implemented") - } - logError(e) - } - } - } - } - } +// @Test +// fun providerCorrectHomepage() { +// runBlocking { +// getAllProviders().apmap { api -> +// if (api.hasMainPage) { +// try { +// val homepage = api.getMainPage() +// when { +// homepage == null -> { +// Assert.fail("Homepage provider ${api.name} did not correctly load homepage!") +// } +// homepage.items.isEmpty() -> { +// Assert.fail("Homepage provider ${api.name} does not contain any items!") +// } +// homepage.items.any { it.list.isEmpty() } -> { +// Assert.fail("Homepage provider ${api.name} does not have any items on result!") +// } +// } +// } catch (e: Exception) { +// if (e.cause is NotImplementedError) { +// Assert.fail("Provider marked as hasMainPage, while in reality is has not been implemented") +// } +// logError(e) +// } +// } +// } +// } +// } -// @Test -// fun testSingleProvider() { -// testSingleProviderApi(ThenosProvider()) -// } +// // @Test +// // fun testSingleProvider() { +// // testSingleProviderApi(ThenosProvider()) +// // } - @Test - suspend fun providerCorrect() { - val invalidProvider = ArrayList>() - val providers = getAllProviders() - providers.apmap { api -> - try { - println("Trying $api") - if (testSingleProviderApi(api)) { - println("Success $api") - } else { - System.err.println("Error $api") - invalidProvider.add(Pair(api, null)) - } - } catch (e: Exception) { - logError(e) - invalidProvider.add(Pair(api, e)) - } - } +// @Test +// suspend fun providerCorrect() { +// val invalidProvider = ArrayList>() +// val providers = getAllProviders() +// providers.apmap { api -> +// try { +// println("Trying $api") +// if (testSingleProviderApi(api)) { +// println("Success $api") +// } else { +// System.err.println("Error $api") +// invalidProvider.add(Pair(api, null)) +// } +// } catch (e: Exception) { +// logError(e) +// invalidProvider.add(Pair(api, e)) +// } +// } - println("Invalid providers are: ") - for (provider in invalidProvider) { - println("${provider.first}") - } - } +// println("Invalid providers are: ") +// for (provider in invalidProvider) { +// println("${provider.first}") +// } +// } } \ No newline at end of file