mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions-inspector.git
synced 2025-01-11 16:29:08 +01:00
put it all together
This commit is contained in:
parent
b7605b9946
commit
e67a7ab481
@ -1,56 +1,64 @@
|
||||
package ir.armor.tachidesk
|
||||
|
||||
import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import okhttp3.Request
|
||||
import okio.BufferedSink
|
||||
import okio.buffer
|
||||
import okio.sink
|
||||
import rx.Observable
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import java.net.URLClassLoader
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class Main {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
val contentRoot = "/tmp/tachidesk"
|
||||
File(contentRoot).mkdirs()
|
||||
|
||||
// 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")
|
||||
// })
|
||||
// }
|
||||
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 apkFilePath = "$contentRoot/$apkFileName"
|
||||
val zipDirPath = apkFilePath.substringBefore(".apk")
|
||||
val jarFilePath = "$contentRoot/$zipDirPath.jar"
|
||||
|
||||
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()
|
||||
val request = Request.Builder().url(apkToDownload).build()
|
||||
val response = NetworkHelper().client.newCall(request).execute();
|
||||
println(response.code)
|
||||
|
||||
// Runtime.getRuntime().exec("unzip $apkFileName -d $apkFileDir")
|
||||
// Runtime.getRuntime().exec("dex2jar $apkFileDir/classes.dex -o $apkFileDir.jar")
|
||||
val downloadedFile = File(apkFilePath)
|
||||
val sink: BufferedSink = downloadedFile.sink().buffer()
|
||||
sink.writeAll(response.body!!.source())
|
||||
sink.close()
|
||||
|
||||
val child = URLClassLoader(arrayOf<URL>(URL("file:$apkFileDirAbsolutePath")), this.javaClass.classLoader)
|
||||
Runtime.getRuntime().exec("unzip ${downloadedFile.absolutePath} -d $zipDirPath").waitFor()
|
||||
Runtime.getRuntime().exec("dex2jar $zipDirPath/classes.dex -o $jarFilePath").waitFor()
|
||||
|
||||
val child = URLClassLoader(arrayOf<URL>(URL("file:$jarFilePath")), 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)
|
||||
}
|
||||
exitProcess(0)
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user