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
@ -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")
}

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
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<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)
}
}
}
}