fix again

This commit is contained in:
C10udburst 2022-08-06 10:13:21 +02:00
parent 0353d6abdd
commit eee80becbe
3 changed files with 231 additions and 220 deletions

View file

@ -40,9 +40,9 @@ jobs:
# echo $ENCODED_STRING | base64 -di > "${TMP_KEYSTORE_FILE_PATH}"/prerelease_keystore.keystore # echo $ENCODED_STRING | base64 -di > "${TMP_KEYSTORE_FILE_PATH}"/prerelease_keystore.keystore
- name: Run Gradle - name: Run Gradle
run: | run: |
./gradlew app:assembleDebug ./gradlew assembleDebug
./gradlew app:androidSourcesJar ./gradlew androidSourcesJar
./gradlew build || true ./gradlew makeJar
# env: # env:
# SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }} # SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
# SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} # SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
@ -61,4 +61,4 @@ jobs:
files: | files: |
app/build/outputs/apk/debug/*.apk app/build/outputs/apk/debug/*.apk
app/build/libs/app-sources.jar app/build/libs/app-sources.jar
app/build/intermediates/compile_app_classes_jar/debug/classes.jar app/build/classes.jar

View file

@ -51,22 +51,22 @@ android {
} }
buildTypes { buildTypes {
release { // release {
debuggable false // debuggable false
minifyEnabled false // minifyEnabled false
shrinkResources false // shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' // proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} // }
prerelease { // prerelease {
applicationIdSuffix ".prerelease" // applicationIdSuffix ".prerelease"
buildConfigField("boolean", "BETA", "true") // buildConfigField("boolean", "BETA", "true")
signingConfig signingConfigs.prerelease // signingConfig signingConfigs.prerelease
versionNameSuffix '-PRE' // versionNameSuffix '-PRE'
debuggable false // debuggable false
minifyEnabled false // minifyEnabled false
shrinkResources false // shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' // proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} // }
debug { debug {
debuggable true debuggable true
applicationIdSuffix ".debug" applicationIdSuffix ".debug"
@ -83,6 +83,10 @@ android {
jvmTarget = '1.8' jvmTarget = '1.8'
freeCompilerArgs = ['-Xjvm-default=compatibility'] freeCompilerArgs = ['-Xjvm-default=compatibility']
} }
lintOptions {
checkReleaseBuilds false
abortOnError false
}
} }
repositories { repositories {
@ -189,3 +193,10 @@ task androidSourcesJar(type: Jar) {
getArchiveClassifier().set('sources') getArchiveClassifier().set('sources')
from android.sourceSets.main.java.srcDirs//full 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
}

View file

@ -1,220 +1,220 @@
package com.lagradost.cloudstream3 package com.lagradost.cloudstream3
import com.lagradost.cloudstream3.APIHolder.allProviders // import com.lagradost.cloudstream3.APIHolder.allProviders
import com.lagradost.cloudstream3.mvvm.logError // import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.utils.Qualities // import com.lagradost.cloudstream3.utils.Qualities
import com.lagradost.cloudstream3.utils.SubtitleHelper // import com.lagradost.cloudstream3.utils.SubtitleHelper
import kotlinx.coroutines.runBlocking // import kotlinx.coroutines.runBlocking
import org.junit.Assert // import org.junit.Assert
import org.junit.Test // import org.junit.Test
class ProviderTests { class ProviderTests {
private fun getAllProviders(): List<MainAPI> { // private fun getAllProviders(): List<MainAPI> {
return allProviders.filter { !it.usesWebView } // return allProviders.filter { !it.usesWebView }
} // }
private suspend fun loadLinks(api: MainAPI, url: String?): Boolean { // private suspend fun loadLinks(api: MainAPI, url: String?): Boolean {
Assert.assertNotNull("Api ${api.name} has invalid url on episode", url) // Assert.assertNotNull("Api ${api.name} has invalid url on episode", url)
if (url == null) return true // if (url == null) return true
var linksLoaded = 0 // var linksLoaded = 0
try { // try {
val success = api.loadLinks(url, false, {}) { link -> // val success = api.loadLinks(url, false, {}) { link ->
Assert.assertTrue( // Assert.assertTrue(
"Api ${api.name} returns link with invalid Quality", // "Api ${api.name} returns link with invalid Quality",
Qualities.values().map { it.value }.contains(link.quality) // Qualities.values().map { it.value }.contains(link.quality)
) // )
Assert.assertTrue( // Assert.assertTrue(
"Api ${api.name} returns link with invalid url", // "Api ${api.name} returns link with invalid url",
link.url.length > 4 // link.url.length > 4
) // )
linksLoaded++ // linksLoaded++
} // }
if (success) { // if (success) {
return linksLoaded > 0 // return linksLoaded > 0
} // }
Assert.assertTrue("Api ${api.name} has returns false on .loadLinks", success) // Assert.assertTrue("Api ${api.name} has returns false on .loadLinks", success)
} catch (e: Exception) { // } catch (e: Exception) {
if (e.cause is NotImplementedError) { // if (e.cause is NotImplementedError) {
Assert.fail("Provider has not implemented .loadLinks") // Assert.fail("Provider has not implemented .loadLinks")
} // }
logError(e) // logError(e)
} // }
return true // return true
} // }
private suspend fun testSingleProviderApi(api: MainAPI): Boolean { // private suspend fun testSingleProviderApi(api: MainAPI): Boolean {
val searchQueries = listOf("over", "iron", "guy") // val searchQueries = listOf("over", "iron", "guy")
var correctResponses = 0 // var correctResponses = 0
var searchResult: List<SearchResponse>? = null // var searchResult: List<SearchResponse>? = null
for (query in searchQueries) { // for (query in searchQueries) {
val response = try { // val response = try {
api.search(query) // api.search(query)
} catch (e: Exception) { // } catch (e: Exception) {
if (e.cause is NotImplementedError) { // if (e.cause is NotImplementedError) {
Assert.fail("Provider has not implemented .search") // Assert.fail("Provider has not implemented .search")
} // }
logError(e) // logError(e)
null // null
} // }
if (!response.isNullOrEmpty()) { // if (!response.isNullOrEmpty()) {
correctResponses++ // correctResponses++
if (searchResult == null) { // if (searchResult == null) {
searchResult = response // searchResult = response
} // }
} // }
} // }
if (correctResponses == 0 || searchResult == null) { // if (correctResponses == 0 || searchResult == null) {
System.err.println("Api ${api.name} did not return any valid search responses") // System.err.println("Api ${api.name} did not return any valid search responses")
return false // return false
} // }
try { // try {
var validResults = false // var validResults = false
for (result in searchResult) { // for (result in searchResult) {
Assert.assertEquals( // Assert.assertEquals(
"Invalid apiName on response on ${api.name}", // "Invalid apiName on response on ${api.name}",
result.apiName, // result.apiName,
api.name // api.name
) // )
val load = api.load(result.url) ?: continue // val load = api.load(result.url) ?: continue
Assert.assertEquals( // Assert.assertEquals(
"Invalid apiName on load on ${api.name}", // "Invalid apiName on load on ${api.name}",
load.apiName, // load.apiName,
result.apiName // result.apiName
) // )
Assert.assertTrue( // Assert.assertTrue(
"Api ${api.name} on load does not contain any of the supportedTypes", // "Api ${api.name} on load does not contain any of the supportedTypes",
api.supportedTypes.contains(load.type) // api.supportedTypes.contains(load.type)
) // )
when (load) { // when (load) {
is AnimeLoadResponse -> { // is AnimeLoadResponse -> {
val gotNoEpisodes = // val gotNoEpisodes =
load.episodes.keys.isEmpty() || load.episodes.keys.any { load.episodes[it].isNullOrEmpty() } // load.episodes.keys.isEmpty() || load.episodes.keys.any { load.episodes[it].isNullOrEmpty() }
if (gotNoEpisodes) { // if (gotNoEpisodes) {
println("Api ${api.name} got no episodes on ${load.url}") // println("Api ${api.name} got no episodes on ${load.url}")
continue // continue
} // }
val url = (load.episodes[load.episodes.keys.first()])?.first()?.data // val url = (load.episodes[load.episodes.keys.first()])?.first()?.data
validResults = loadLinks(api, url) // validResults = loadLinks(api, url)
if (!validResults) continue // if (!validResults) continue
} // }
is MovieLoadResponse -> { // is MovieLoadResponse -> {
val gotNoEpisodes = load.dataUrl.isBlank() // val gotNoEpisodes = load.dataUrl.isBlank()
if (gotNoEpisodes) { // if (gotNoEpisodes) {
println("Api ${api.name} got no movie on ${load.url}") // println("Api ${api.name} got no movie on ${load.url}")
continue // continue
} // }
validResults = loadLinks(api, load.dataUrl) // validResults = loadLinks(api, load.dataUrl)
if (!validResults) continue // if (!validResults) continue
} // }
is TvSeriesLoadResponse -> { // is TvSeriesLoadResponse -> {
val gotNoEpisodes = load.episodes.isEmpty() // val gotNoEpisodes = load.episodes.isEmpty()
if (gotNoEpisodes) { // if (gotNoEpisodes) {
println("Api ${api.name} got no episodes on ${load.url}") // println("Api ${api.name} got no episodes on ${load.url}")
continue // continue
} // }
validResults = loadLinks(api, load.episodes.first().data) // validResults = loadLinks(api, load.episodes.first().data)
if (!validResults) continue // if (!validResults) continue
} // }
} // }
break // break
} // }
Assert.assertTrue("Api ${api.name} did not load on any}", validResults) // Assert.assertTrue("Api ${api.name} did not load on any}", validResults)
} catch (e: Exception) { // } catch (e: Exception) {
if (e.cause is NotImplementedError) { // if (e.cause is NotImplementedError) {
Assert.fail("Provider has not implemented .load") // Assert.fail("Provider has not implemented .load")
} // }
logError(e) // logError(e)
return false // return false
} // }
return true // return true
} // }
@Test // @Test
fun providersExist() { // fun providersExist() {
Assert.assertTrue(getAllProviders().isNotEmpty()) // Assert.assertTrue(getAllProviders().isNotEmpty())
} // }
@Test // @Test
fun providerCorrectData() { // fun providerCorrectData() {
val isoNames = SubtitleHelper.languages.map { it.ISO_639_1 } // val isoNames = SubtitleHelper.languages.map { it.ISO_639_1 }
Assert.assertFalse("ISO does not contain any languages", isoNames.isNullOrEmpty()) // Assert.assertFalse("ISO does not contain any languages", isoNames.isNullOrEmpty())
for (api in getAllProviders()) { // for (api in getAllProviders()) {
Assert.assertTrue("Api does not contain a mainUrl", api.mainUrl != "NONE") // 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 does not contain a name", api.name != "NONE")
Assert.assertTrue( // Assert.assertTrue(
"Api ${api.name} does not contain a valid language code", // "Api ${api.name} does not contain a valid language code",
isoNames.contains(api.lang) // isoNames.contains(api.lang)
) // )
Assert.assertTrue( // Assert.assertTrue(
"Api ${api.name} does not contain any supported types", // "Api ${api.name} does not contain any supported types",
api.supportedTypes.isNotEmpty() // api.supportedTypes.isNotEmpty()
) // )
} // }
} // }
@Test // @Test
fun providerCorrectHomepage() { // fun providerCorrectHomepage() {
runBlocking { // runBlocking {
getAllProviders().apmap { api -> // getAllProviders().apmap { api ->
if (api.hasMainPage) { // if (api.hasMainPage) {
try { // try {
val homepage = api.getMainPage() // val homepage = api.getMainPage()
when { // when {
homepage == null -> { // homepage == null -> {
Assert.fail("Homepage provider ${api.name} did not correctly load homepage!") // Assert.fail("Homepage provider ${api.name} did not correctly load homepage!")
} // }
homepage.items.isEmpty() -> { // homepage.items.isEmpty() -> {
Assert.fail("Homepage provider ${api.name} does not contain any items!") // Assert.fail("Homepage provider ${api.name} does not contain any items!")
} // }
homepage.items.any { it.list.isEmpty() } -> { // homepage.items.any { it.list.isEmpty() } -> {
Assert.fail("Homepage provider ${api.name} does not have any items on result!") // Assert.fail("Homepage provider ${api.name} does not have any items on result!")
} // }
} // }
} catch (e: Exception) { // } catch (e: Exception) {
if (e.cause is NotImplementedError) { // if (e.cause is NotImplementedError) {
Assert.fail("Provider marked as hasMainPage, while in reality is has not been implemented") // Assert.fail("Provider marked as hasMainPage, while in reality is has not been implemented")
} // }
logError(e) // logError(e)
} // }
} // }
} // }
} // }
} // }
// @Test // // @Test
// fun testSingleProvider() { // // fun testSingleProvider() {
// testSingleProviderApi(ThenosProvider()) // // testSingleProviderApi(ThenosProvider())
// } // // }
@Test // @Test
suspend fun providerCorrect() { // suspend fun providerCorrect() {
val invalidProvider = ArrayList<Pair<MainAPI, Exception?>>() // val invalidProvider = ArrayList<Pair<MainAPI, Exception?>>()
val providers = getAllProviders() // val providers = getAllProviders()
providers.apmap { api -> // providers.apmap { api ->
try { // try {
println("Trying $api") // println("Trying $api")
if (testSingleProviderApi(api)) { // if (testSingleProviderApi(api)) {
println("Success $api") // println("Success $api")
} else { // } else {
System.err.println("Error $api") // System.err.println("Error $api")
invalidProvider.add(Pair(api, null)) // invalidProvider.add(Pair(api, null))
} // }
} catch (e: Exception) { // } catch (e: Exception) {
logError(e) // logError(e)
invalidProvider.add(Pair(api, e)) // invalidProvider.add(Pair(api, e))
} // }
} // }
println("Invalid providers are: ") // println("Invalid providers are: ")
for (provider in invalidProvider) { // for (provider in invalidProvider) {
println("${provider.first}") // println("${provider.first}")
} // }
} // }
} }