From b7605b994641e81465b98e3cd2389c51ebb91f6f Mon Sep 17 00:00:00 2001 From: Aria Moradi Date: Wed, 23 Dec 2020 19:52:16 +0330 Subject: [PATCH] prototyping done --- app/build.gradle.kts | 29 ++++++----- .../extension/api/ExtensionGithubApi.kt | 2 +- .../extension/api/ExtensionGithubService.kt | 2 +- .../main/kotlin/ir/armor/tachidesk/Main.kt | 51 ++++++++++++++++++- 4 files changed, 68 insertions(+), 16 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index ebdb0bc..24f3de3 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,4 +1,5 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + val compileKotlin: KotlinCompile by tasks @@ -30,35 +31,39 @@ dependencies { // implementation("com.github.inorichi.injekt:injekt-core:65b0440") val okhttp_version = "4.10.0-RC1" - implementation( "com.squareup.okhttp3:okhttp:$okhttp_version") - implementation( "com.squareup.okhttp3:logging-interceptor:$okhttp_version") - implementation( "com.squareup.okhttp3:okhttp-dnsoverhttps:$okhttp_version") - implementation ("com.squareup.okio:okio:2.9.0") + implementation("com.squareup.okhttp3:okhttp:$okhttp_version") + implementation("com.squareup.okhttp3:logging-interceptor:$okhttp_version") + implementation("com.squareup.okhttp3:okhttp-dnsoverhttps:$okhttp_version") + implementation("com.squareup.okio:okio:2.9.0") // retrofit val retrofit_version = "2.9.0" - implementation ("com.squareup.retrofit2:retrofit:$retrofit_version") - implementation ("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.8.0") + implementation("com.squareup.retrofit2:retrofit:$retrofit_version") + implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.8.0") implementation("com.squareup.retrofit2:converter-gson:$retrofit_version") - implementation ("com.squareup.retrofit2:adapter-rxjava:$retrofit_version") + implementation("com.squareup.retrofit2:adapter-rxjava:$retrofit_version") implementation("io.reactivex:rxjava:1.3.8") -// implementation 'io.reactivex:rxandroid:1.2.1' -// implementation ("com.jakewharton.rxrelay:rxrelay:1.2.0") -// implementation ("com.github.pwittchen:reactivenetwork:0.13.0") +// implementation("io.reactivex:rxandroid:1.2.1") +// implementation("com.jakewharton.rxrelay:rxrelay:1.2.0") +// implementation("com.github.pwittchen:reactivenetwork:0.13.0") - implementation( "org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0") implementation("com.google.code.gson:gson:2.8.6") - implementation ("com.github.salomonbrys.kotson:kotson:2.5.0") + implementation("com.github.salomonbrys.kotson:kotson:2.5.0") implementation("org.jsoup:jsoup:1.13.1") implementation("com.github.salomonbrys.kotson:kotson:2.5.0") 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") } diff --git a/app/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt b/app/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt index c3aff69..8f41ef1 100644 --- a/app/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt +++ b/app/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt @@ -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" } } diff --git a/app/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubService.kt b/app/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubService.kt index 2c6c88e..eb37e86 100644 --- a/app/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubService.kt +++ b/app/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubService.kt @@ -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 } diff --git a/app/src/main/kotlin/ir/armor/tachidesk/Main.kt b/app/src/main/kotlin/ir/armor/tachidesk/Main.kt index 4b37f75..1e78d99 100644 --- a/app/src/main/kotlin/ir/armor/tachidesk/Main.kt +++ b/app/src/main/kotlin/ir/armor/tachidesk/Main.kt @@ -1,10 +1,57 @@ package ir.armor.tachidesk -class Main{ +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) { - 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("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 + val result = instance.fetchPopularManga(1) + val mangasPage = result.toBlocking().first() as MangasPage + mangasPage.mangas.forEach{ + println(it.title) + } + } } }