|
| 1 | +# CloudstreamApi |
| 2 | + |
| 3 | +[](https://jitpack.io/#Blatzar/CloudstreamApi) |
| 4 | + |
| 5 | +A minimal subset of the Cloudstream Provider API used to allow local compilation and testing. |
| 6 | +Currently work in progress and may not work with all providers. |
| 7 | +Please make an issue if there are any useful missing methods from the main app. |
| 8 | + |
| 9 | +## Getting started |
| 10 | + |
| 11 | +### Setup |
| 12 | + |
| 13 | +In your build.gradle.kts: |
| 14 | + |
| 15 | +```kt |
| 16 | + dependencies { |
| 17 | + val apkTasks = listOf("deployWithAdb", "build") |
| 18 | + val useApk = gradle.startParameter.taskNames.any { taskName -> |
| 19 | + apkTasks.any { apkTask -> |
| 20 | + taskName.contains(apkTask, ignoreCase = true) |
| 21 | + } |
| 22 | + } |
| 23 | + |
| 24 | + val implementation by configurations |
| 25 | + val apk by configurations |
| 26 | + |
| 27 | + // If the task is specifically to compile the app then use the stubs, otherwise us the library. |
| 28 | + if (useApk) { |
| 29 | + // Stubs for all Cloudstream classes |
| 30 | + apk("com.lagradost:cloudstream3:pre-release") |
| 31 | + } else { |
| 32 | + // For running locally |
| 33 | + implementation("com.github.Blatzar:CloudstreamApi:0.1.3") |
| 34 | + } |
| 35 | + |
| 36 | + // Rest of your code here... |
| 37 | + } |
| 38 | +``` |
| 39 | + |
| 40 | +### Testing locally |
| 41 | + |
| 42 | +Running it is as simple as defining a main method and running it by clicking the green arrow in Android Studio. |
| 43 | + |
| 44 | + |
| 45 | +```kt |
| 46 | +suspend fun main() { |
| 47 | + val providerTester = com.lagradost.cloudstreamtest.ProviderTester(YourProvider()) |
| 48 | + providerTester.testAll() |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +Using the ProviderTester it becomes easy to test all methods at once, or just test individual methods with printing. |
| 53 | +It is mainly to prevent a lot of boilerplate code in every provider. |
| 54 | + |
| 55 | +Note that you can run the providers locally too, without using ProviderTester: |
| 56 | + |
| 57 | +```kt |
| 58 | +suspend fun main() { |
| 59 | + val responses = YourProvider().search("Query") |
| 60 | + println(responses) |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +An automated testing system, or testing all providers does not exist currently, but is likely to come in the future. |
0 commit comments