prototyping done

This commit is contained in:
Aria Moradi 2020-12-23 19:52:16 +03:30
parent ded9cc992b
commit b7605b9946
4 changed files with 68 additions and 16 deletions

View File

@ -1,4 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
val compileKotlin: KotlinCompile by tasks
@ -46,7 +47,7 @@ dependencies {
implementation("io.reactivex:rxjava:1.3.8")
// implementation 'io.reactivex:rxandroid:1.2.1'
// implementation("io.reactivex:rxandroid:1.2.1")
// implementation("com.jakewharton.rxrelay:rxrelay:1.2.0")
// implementation("com.github.pwittchen:reactivenetwork:0.13.0")
@ -59,6 +60,10 @@ dependencies {
implementation("com.squareup.duktape:duktape-android:1.3.0")
val coroutinesVersion = "1.3.9"
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
}

View File

@ -77,6 +77,6 @@ internal class ExtensionGithubApi {
companion object {
const val BASE_URL = "https://raw.githubusercontent.com/"
const val REPO_URL_PREFIX = "${BASE_URL}inorichi/tachiyomi-extensions/repo/"
const val REPO_URL_PREFIX = "${BASE_URL}inorichi/tachiyomi-extensions/repo"
}
}

View File

@ -39,6 +39,6 @@ interface ExtensionGithubService {
}
}
@GET("${ExtensionGithubApi.REPO_URL_PREFIX}index.json.gz")
@GET("${ExtensionGithubApi.REPO_URL_PREFIX}/index.json.gz")
suspend fun getRepo(): JsonArray
}

View File

@ -1,10 +1,57 @@
package ir.armor.tachidesk
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.model.MangasPage
import okhttp3.Request
import rx.Observable
import java.io.File
import java.net.URL
import java.net.URLClassLoader
class Main {
companion object {
@JvmStatic
fun main(args: Array<String>) {
println("hello bitches")
// get list of extensions
var apkToDownload: String = ""
// runBlocking {
// val api = ExtensionGithubApi()
// apkToDownload = api.getApkUrl(api.findExtensions().first {
// api.getApkUrl(it).endsWith("killsixbilliondemons-v1.2.3.apk")
// })
// }
apkToDownload = "https://raw.githubusercontent.com/inorichi/tachiyomi-extensions/repo/apk/tachiyomi-en.killsixbilliondemons-v1.2.3.apk"
println(apkToDownload)
val apkFileName = apkToDownload.split("/").last()
val apkFileDir = apkFileName.substringBefore(".apk")
val apkFileDirAbsolutePath = File("$apkFileDir.jar").absolutePath
val request = Request.Builder().url(apkToDownload)
// .addHeader("Content-Type", "application/json")
.build();
// val response = NetworkHelper().client.newCall(request).execute();
// println(response.code)
//
// val downloadedFile = File(apkFileName)
// val sink: BufferedSink = downloadedFile.sink().buffer()
// sink.writeAll(response.body!!.source())
// sink.close()
// Runtime.getRuntime().exec("unzip $apkFileName -d $apkFileDir")
// Runtime.getRuntime().exec("dex2jar $apkFileDir/classes.dex -o $apkFileDir.jar")
val child = URLClassLoader(arrayOf<URL>(URL("file:$apkFileDirAbsolutePath")), this.javaClass.classLoader)
val classToLoad = Class.forName("eu.kanade.tachiyomi.extension.en.killsixbilliondemons.KillSixBillionDemons", true, child)
// val method = classToLoad.getDeclaredMethod("fetchPopularManga")
val instance = classToLoad.newInstance() as CatalogueSource
// val result = method.invoke(instance, 1) as Observable<MangasPage>
val result = instance.fetchPopularManga(1)
val mangasPage = result.toBlocking().first() as MangasPage
mangasPage.mangas.forEach{
println(it.title)
}
}
}
}