mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions-inspector.git
synced 2024-12-25 16:21:50 +01:00
commit what we got
This commit is contained in:
parent
59c69a4f7f
commit
d57827b6d3
@ -15,6 +15,7 @@ compileKotlin.kotlinOptions {
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -69,6 +70,16 @@ dependencies {
|
||||
implementation("org.slf4j:slf4j-api:1.8.0-beta4")
|
||||
implementation("com.fasterxml.jackson.core:jackson-databind:2.10.3")
|
||||
|
||||
// to get application content root
|
||||
implementation("net.harawata:appdirs:1.2.0")
|
||||
|
||||
// Exposed ORM
|
||||
val exposed_version = "0.28.1"
|
||||
implementation ("org.jetbrains.exposed:exposed-core:$exposed_version")
|
||||
implementation ("org.jetbrains.exposed:exposed-dao:$exposed_version")
|
||||
implementation ("org.jetbrains.exposed:exposed-jdbc:$exposed_version")
|
||||
implementation ("org.xerial:sqlite-jdbc:3.30.1")
|
||||
|
||||
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test")
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
|
||||
|
7
server/src/main/kotlin/ir/armor/tachidesk/Config.kt
Normal file
7
server/src/main/kotlin/ir/armor/tachidesk/Config.kt
Normal file
@ -0,0 +1,7 @@
|
||||
package ir.armor.tachidesk
|
||||
|
||||
import net.harawata.appdirs.AppDirsFactory
|
||||
|
||||
object Config {
|
||||
val dataRoot = AppDirsFactory.getInstance().getUserDataDir("Tachidesk",null, null)
|
||||
}
|
@ -7,19 +7,25 @@ import eu.kanade.tachiyomi.source.model.MangasPage
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import io.javalin.Javalin
|
||||
import io.javalin.http.Context
|
||||
import ir.armor.tachidesk.database.DBMangaer
|
||||
import ir.armor.tachidesk.database.makeDataBaseTables
|
||||
import ir.armor.tachidesk.database.model.ExtensionsTable
|
||||
import ir.armor.tachidesk.database.model.SourcesTable
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import net.harawata.appdirs.AppDirsFactory
|
||||
import okhttp3.Request
|
||||
import okio.buffer
|
||||
import okio.sink
|
||||
import org.jetbrains.exposed.sql.Database
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import java.net.URLClassLoader
|
||||
import org.jetbrains.exposed.sql.SchemaUtils
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
|
||||
|
||||
class Main {
|
||||
companion object {
|
||||
const val contentRoot = "/tmp/tachidesk"
|
||||
|
||||
@JvmStatic
|
||||
fun downloadAPK(url: String, apkPath: String){
|
||||
val request = Request.Builder().url(url).build()
|
||||
@ -33,6 +39,7 @@ class Main {
|
||||
|
||||
@JvmStatic
|
||||
fun testExtensionExecution(){
|
||||
val contentRoot = Config.dataRoot + "/extensions"
|
||||
File(contentRoot).mkdirs()
|
||||
var sourcePkg = ""
|
||||
|
||||
@ -61,7 +68,7 @@ class Main {
|
||||
// dex -> jar
|
||||
Dex2jarCmd.main(dexFilePath, "-o", jarFilePath, "--force")
|
||||
|
||||
val child = URLClassLoader(arrayOf<URL>(URL("file:$jarFilePath")), this.javaClass.classLoader)
|
||||
val child = URLClassLoader(arrayOf<URL>(URL("file:$jarFilePath")), this::class.java.classLoader)
|
||||
val classToLoad = Class.forName(className, true, child)
|
||||
val instance = classToLoad.newInstance() as HttpSource
|
||||
val result = instance.fetchPopularManga(1)
|
||||
@ -75,19 +82,34 @@ class Main {
|
||||
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
val app = Javalin.create().start(4567)
|
||||
// make sure data everything we need exists
|
||||
File(Config.dataRoot).mkdirs()
|
||||
makeDataBaseTables()
|
||||
|
||||
app.before() { ctx ->
|
||||
ctx.header("Access-Control-Allow-Origin", "*")
|
||||
}
|
||||
|
||||
app.get("/api/v1/extensions") { ctx ->
|
||||
runBlocking {
|
||||
val api = ExtensionGithubApi()
|
||||
val sources = api.findExtensions()
|
||||
ctx.json(sources)
|
||||
}
|
||||
}
|
||||
// val app = Javalin.create().start(4567)
|
||||
//
|
||||
// app.before() { ctx ->
|
||||
// ctx.header("Access-Control-Allow-Origin", "*")
|
||||
// }
|
||||
//
|
||||
// app.get("/api/v1/extensions") { ctx ->
|
||||
// runBlocking {
|
||||
// val api = ExtensionGithubApi()
|
||||
// val sources = api.findExtensions()
|
||||
// ctx.json(sources)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// app.get("/api/v1/extensions/install/:extensionURL") { ctx ->
|
||||
// ctx.pathParam("extensionURL")
|
||||
// })
|
||||
|
||||
|
||||
// ExtensionTable.new {
|
||||
// name = "khar"
|
||||
// pkgName = "eu.khar"
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package ir.armor.tachidesk.database
|
||||
|
||||
import ir.armor.tachidesk.Config
|
||||
import ir.armor.tachidesk.database.model.ExtensionsTable
|
||||
import ir.armor.tachidesk.database.model.SourcesTable
|
||||
import org.jetbrains.exposed.sql.Database
|
||||
import org.jetbrains.exposed.sql.SchemaUtils
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
|
||||
object DBMangaer {
|
||||
val db by lazy {
|
||||
Database.connect("jdbc:sqlite:${Config.dataRoot}/database.db", "org.sqlite.JDBC")
|
||||
}
|
||||
}
|
||||
|
||||
fun makeDataBaseTables() {
|
||||
// mention db object to connect
|
||||
DBMangaer.db
|
||||
|
||||
transaction {
|
||||
SchemaUtils.create(ExtensionsTable)
|
||||
SchemaUtils.create(SourcesTable)
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package ir.armor.tachidesk.database.model
|
||||
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import org.jetbrains.exposed.dao.IntEntity
|
||||
import org.jetbrains.exposed.dao.IntEntityClass
|
||||
import org.jetbrains.exposed.dao.id.EntityID
|
||||
import org.jetbrains.exposed.dao.id.IntIdTable
|
||||
import org.jetbrains.exposed.sql.Column
|
||||
import org.jetbrains.exposed.sql.Table
|
||||
|
||||
|
||||
object ExtensionsTable : IntIdTable() {
|
||||
val name = varchar("name", 128)
|
||||
val pkgName = varchar("pkg_name", 128)
|
||||
val versionName = varchar("version_name", 16)
|
||||
val versionCode = integer("version_code")
|
||||
val lang = varchar("lang", 5)
|
||||
val isNsfw = bool("is_nsfw")
|
||||
}
|
||||
|
||||
//class Extension(id: EntityID<Int>) : IntEntity(id) {
|
||||
// companion object : IntEntityClass<Extension>(ExtensionsTable)
|
||||
//
|
||||
// val name by ExtensionsTable.name
|
||||
// val pkgName by ExtensionsTable.pkgName
|
||||
// val versionName by ExtensionsTable.versionName
|
||||
// val versionCode by ExtensionsTable.versionCode
|
||||
// val lang by ExtensionsTable.lang
|
||||
// val isNsfw by ExtensionsTable.isNsfw
|
||||
//}
|
@ -0,0 +1,26 @@
|
||||
package ir.armor.tachidesk.database.model
|
||||
|
||||
import org.jetbrains.exposed.dao.Entity
|
||||
import org.jetbrains.exposed.dao.IntEntity
|
||||
import org.jetbrains.exposed.dao.IntEntityClass
|
||||
import org.jetbrains.exposed.dao.id.EntityID
|
||||
import org.jetbrains.exposed.sql.Column
|
||||
import org.jetbrains.exposed.sql.Table
|
||||
|
||||
object SourcesTable : Table() {
|
||||
val id: Column<Long> = long("id")
|
||||
val name: Column<String> = varchar("name", 128)
|
||||
val extension = reference("extension", ExtensionsTable)
|
||||
override val primaryKey = PrimaryKey(id)
|
||||
}
|
||||
|
||||
//class Source : Entity() {
|
||||
// companion object : Entity<Source>(SourcesTable)
|
||||
//
|
||||
// val name by ExtensionsTable.name
|
||||
// val pkgName by ExtensionsTable.pkgName
|
||||
// val versionName by ExtensionsTable.versionName
|
||||
// val versionCode by ExtensionsTable.versionCode
|
||||
// val lang by ExtensionsTable.lang
|
||||
// val isNsfw by ExtensionsTable.isNsfw
|
||||
//}
|
@ -0,0 +1,4 @@
|
||||
package ir.armor.tachidesk.extension
|
||||
|
||||
class Extension {
|
||||
}
|
Loading…
Reference in New Issue
Block a user