Compare commits
82 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f0940b7926 | |||
| 0066e0b901 | |||
| 9771f566b0 | |||
| 38ad4c6dec | |||
| 37cf80a188 | |||
| c86ee53f66 | |||
| c2cea7e797 | |||
| a8ef6cdd4f | |||
| 53d157fee8 | |||
| c2e07b13f6 | |||
| 2e8cc48311 | |||
| f6f811eb77 | |||
| ac5528fb15 | |||
| 940d2b7862 | |||
| 835fe3dad3 | |||
| dfaecc08c5 | |||
| 87f5e9b847 | |||
| 3d3939e808 | |||
| 90822e3858 | |||
| 14eec47e9c | |||
| 15ed3fcc69 | |||
| fd8fa9f3ef | |||
| b81075f4a7 | |||
| f11a52e8e1 | |||
| 9c007483d4 | |||
| ff4e818e4c | |||
| 45a50ca0c1 | |||
| 65d9021c37 | |||
| 66481a0391 | |||
| a14a82bc9a | |||
| 756c57a16e | |||
| 8b19e34dc5 | |||
| 50083019ee | |||
| 155272e638 | |||
| 08443ceb3d | |||
| c215696f04 | |||
| 5ca42bf9b6 | |||
| 3272b9dec5 | |||
| 2ebd5da4aa | |||
| 34f024ace2 | |||
| b31f2d50f6 | |||
| da44d3b2b4 | |||
| 99ec2aca6a | |||
| 6c278604ec | |||
| 1e094a467a | |||
| 978ccfeeba | |||
| e93d66d8a1 | |||
| c29a749833 | |||
| b08d5d1261 | |||
| 9b129789e9 | |||
| a76a6d2798 | |||
| 086a760378 | |||
| f78c8d4fd8 | |||
| 7b91489997 | |||
| 36a8980c95 | |||
| 7c65640cb7 | |||
| d70e68495a | |||
| 2586202772 | |||
| b5f771368a | |||
| 0c28320ce3 | |||
| c8b4fbc36b | |||
| e9b07849fe | |||
| 409260af6f | |||
| d3d53d1a4e | |||
| e2db191f70 | |||
| d61816734d | |||
| f4dad8058f | |||
| 70bdb375c3 | |||
| e724ab0a29 | |||
| 7d0ee2ac11 | |||
| 59b7e852e2 | |||
| b2eb1a391d | |||
| 9b3aee98d3 | |||
| 0476f4144c | |||
| ed77f45fae | |||
| 0cd529e746 | |||
| 5969048318 | |||
| d1a7f8baa0 | |||
| 18dc936002 | |||
| 5af64892e7 | |||
| 9bdd9f8aa6 | |||
| f3856f051b |
@@ -88,5 +88,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Run Docker build workflow
|
- name: Run Docker build workflow
|
||||||
run: |
|
run: |
|
||||||
|
sleep 10 # sleep a bit to make sure the release is actually inside github db
|
||||||
curl -X POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ secrets.DEPLOY_PREVIEW_TOKEN }}" -d '{"ref":"main", "inputs":{"tachidesk_release_type": "stable"}}' https://api.github.com/repos/suwayomi/docker-tachidesk/actions/workflows/build_container_images.yml/dispatches
|
curl -X POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ secrets.DEPLOY_PREVIEW_TOKEN }}" -d '{"ref":"main", "inputs":{"tachidesk_release_type": "stable"}}' https://api.github.com/repos/suwayomi/docker-tachidesk/actions/workflows/build_container_images.yml/dispatches
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ package xyz.nulldev.ts.config
|
|||||||
|
|
||||||
import net.harawata.appdirs.AppDirsFactory
|
import net.harawata.appdirs.AppDirsFactory
|
||||||
|
|
||||||
|
const val CONFIG_PREFIX = "suwayomi.tachidesk.config"
|
||||||
|
|
||||||
val ApplicationRootDir: String
|
val ApplicationRootDir: String
|
||||||
get(): String {
|
get(): String {
|
||||||
return System.getProperty(
|
return System.getProperty(
|
||||||
"suwayomi.tachidesk.server.rootDir",
|
"$CONFIG_PREFIX.server.rootDir",
|
||||||
AppDirsFactory.getInstance().getUserDataDir("Tachidesk", null, null)
|
AppDirsFactory.getInstance().getUserDataDir("Tachidesk", null, null)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ open class ConfigManager {
|
|||||||
val baseConfig =
|
val baseConfig =
|
||||||
ConfigFactory.parseMap(
|
ConfigFactory.parseMap(
|
||||||
mapOf(
|
mapOf(
|
||||||
"ts.server.rootDir" to ApplicationRootDir
|
"androidcompat.rootDir" to "$ApplicationRootDir/android-compat" // override AndroidCompat's rootDir
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -14,26 +14,31 @@ import kotlin.reflect.KProperty
|
|||||||
/**
|
/**
|
||||||
* Abstract config module.
|
* Abstract config module.
|
||||||
*/
|
*/
|
||||||
abstract class ConfigModule(config: Config, moduleName: String = "") {
|
@Suppress("UNUSED_PARAMETER")
|
||||||
val overridableWithSysProperty = SystemPropertyOverrideDelegate(config, moduleName)
|
abstract class ConfigModule(config: Config)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract jvm-commandline-argument-overridable config module.
|
||||||
|
*/
|
||||||
|
abstract class SystemPropertyOverridableConfigModule(config: Config, moduleName: String): ConfigModule(config) {
|
||||||
|
val overridableConfig = SystemPropertyOverrideDelegate(config, moduleName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Defines a config property that is overridable with jvm `-D` commandline arguments prefixed with [CONFIG_PREFIX] */
|
||||||
class SystemPropertyOverrideDelegate(val config: Config, val moduleName: String) {
|
class SystemPropertyOverrideDelegate(val config: Config, val moduleName: String) {
|
||||||
inline operator fun <R, reified T> getValue(thisRef: R, property: KProperty<*>): T {
|
inline operator fun <R, reified T> getValue(thisRef: R, property: KProperty<*>): T {
|
||||||
val configValue: T = config.getValue(thisRef, property)
|
val configValue: T = config.getValue(thisRef, property)
|
||||||
|
|
||||||
val combined = System.getProperty(
|
val combined = System.getProperty(
|
||||||
"suwayomi.tachidesk.config.$moduleName.${property.name}",
|
"$CONFIG_PREFIX.$moduleName.${property.name}",
|
||||||
configValue.toString()
|
configValue.toString()
|
||||||
)
|
)
|
||||||
|
|
||||||
val asT = when(T::class.simpleName) {
|
return when(T::class.simpleName) {
|
||||||
"Int" -> combined.toInt()
|
"Int" -> combined.toInt()
|
||||||
"Boolean" -> combined.toBoolean()
|
"Boolean" -> combined.toBoolean()
|
||||||
// add more types as needed
|
// add more types as needed
|
||||||
else -> combined
|
else -> combined // covers String
|
||||||
}
|
} as T
|
||||||
|
|
||||||
return asT as T
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -1,6 +1,7 @@
|
|||||||
package xyz.nulldev.androidcompat.config
|
package xyz.nulldev.androidcompat.config
|
||||||
|
|
||||||
import com.typesafe.config.Config
|
import com.typesafe.config.Config
|
||||||
|
import io.github.config4k.getValue
|
||||||
import xyz.nulldev.ts.config.ConfigModule
|
import xyz.nulldev.ts.config.ConfigModule
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -8,8 +9,8 @@ import xyz.nulldev.ts.config.ConfigModule
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class ApplicationInfoConfigModule(config: Config) : ConfigModule(config) {
|
class ApplicationInfoConfigModule(config: Config) : ConfigModule(config) {
|
||||||
val packageName = config.getString("packageName")!!
|
val packageName: String by config
|
||||||
val debug = config.getBoolean("debug")
|
val debug: Boolean by config
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun register(config: Config)
|
fun register(config: Config)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package xyz.nulldev.androidcompat.config
|
package xyz.nulldev.androidcompat.config
|
||||||
|
|
||||||
import com.typesafe.config.Config
|
import com.typesafe.config.Config
|
||||||
|
import io.github.config4k.getValue
|
||||||
import xyz.nulldev.ts.config.ConfigModule
|
import xyz.nulldev.ts.config.ConfigModule
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -8,23 +9,23 @@ import xyz.nulldev.ts.config.ConfigModule
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class FilesConfigModule(config: Config) : ConfigModule(config) {
|
class FilesConfigModule(config: Config) : ConfigModule(config) {
|
||||||
val dataDir = config.getString("dataDir")!!
|
val dataDir:String by config
|
||||||
val filesDir = config.getString("filesDir")!!
|
val filesDir:String by config
|
||||||
val noBackupFilesDir = config.getString("noBackupFilesDir")!!
|
val noBackupFilesDir:String by config
|
||||||
val externalFilesDirs: MutableList<String> = config.getStringList("externalFilesDirs")!!
|
val externalFilesDirs: MutableList<String> by config
|
||||||
val obbDirs: MutableList<String> = config.getStringList("obbDirs")!!
|
val obbDirs: MutableList<String> by config
|
||||||
val cacheDir = config.getString("cacheDir")!!
|
val cacheDir:String by config
|
||||||
val codeCacheDir = config.getString("codeCacheDir")!!
|
val codeCacheDir:String by config
|
||||||
val externalCacheDirs: MutableList<String> = config.getStringList("externalCacheDirs")!!
|
val externalCacheDirs: MutableList<String> by config
|
||||||
val externalMediaDirs: MutableList<String> = config.getStringList("externalMediaDirs")!!
|
val externalMediaDirs: MutableList<String> by config
|
||||||
val rootDir = config.getString("rootDir")!!
|
val rootDir:String by config
|
||||||
val externalStorageDir = config.getString("externalStorageDir")!!
|
val externalStorageDir:String by config
|
||||||
val downloadCacheDir = config.getString("downloadCacheDir")!!
|
val downloadCacheDir:String by config
|
||||||
val databasesDir = config.getString("databasesDir")!!
|
val databasesDir:String by config
|
||||||
|
|
||||||
val prefsDir = config.getString("prefsDir")!!
|
val prefsDir:String by config
|
||||||
|
|
||||||
val packageDir = config.getString("packageDir")!!
|
val packageDir:String by config
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun register(config: Config)
|
fun register(config: Config)
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ package xyz.nulldev.androidcompat.config
|
|||||||
|
|
||||||
import com.typesafe.config.Config
|
import com.typesafe.config.Config
|
||||||
import xyz.nulldev.ts.config.ConfigModule
|
import xyz.nulldev.ts.config.ConfigModule
|
||||||
|
import io.github.config4k.getValue
|
||||||
|
|
||||||
class SystemConfigModule(val config: Config) : ConfigModule(config) {
|
class SystemConfigModule(val config: Config) : ConfigModule(config) {
|
||||||
val isDebuggable = config.getBoolean("isDebuggable")
|
val isDebuggable: Boolean by config
|
||||||
|
|
||||||
val propertyPrefix = "properties."
|
val propertyPrefix = "properties."
|
||||||
|
|
||||||
|
|||||||
@@ -1,36 +1,12 @@
|
|||||||
|
# AndroidComapt Root dir
|
||||||
|
androidcompat.rootDir = androidcompat-root
|
||||||
|
|
||||||
# Allow/disallow preference changes (useful for demos)
|
####################### `android.files` (FilesConfigModule) #######################
|
||||||
ts.server.allowConfigChanges = true
|
|
||||||
|
|
||||||
# Enable the WebUI? Note: The API and multi-user sync server ui will remain available even if the WebUI is disabled
|
|
||||||
ts.server.enableWebUi = true
|
|
||||||
|
|
||||||
# 'true' to use the old, buggy/memory-leaking WebUI
|
|
||||||
ts.server.useOldWebUi = false
|
|
||||||
|
|
||||||
# 'true' to pretty print all JSON API responses
|
|
||||||
ts.server.prettyPrintApi = false
|
|
||||||
|
|
||||||
# List of blacklisted/whitelisted API endpoints/operation IDs
|
|
||||||
ts.server.disabledApiEndpoints = []
|
|
||||||
ts.server.enabledApiEndpoints = []
|
|
||||||
|
|
||||||
# Message to print in the console when the API has finished booting
|
|
||||||
ts.server.httpInitializedPrintMessage = ""
|
|
||||||
|
|
||||||
# Use external folder for static files
|
|
||||||
ts.server.useExternalStaticFiles = false
|
|
||||||
ts.server.externalStaticFilesFolder = ""
|
|
||||||
|
|
||||||
# Root storage dir
|
|
||||||
ts.server.rootDir = tachiserver-data
|
|
||||||
# Dir to store JVM patches
|
|
||||||
ts.server.patchesDir = ${ts.server.rootDir}/patches
|
|
||||||
|
|
||||||
# Storage dir for the emulated Android app
|
# Storage dir for the emulated Android app
|
||||||
android.files.rootDir = ${ts.server.rootDir}/android-compat/appdata
|
android.files.rootDir = ${androidcompat.rootDir}/appdata
|
||||||
# External storage dir for the emulated Android app's
|
# External storage dir for the emulated Android app's
|
||||||
android.files.externalStorageDir = ${ts.server.rootDir}/android-compat/extappdata
|
android.files.externalStorageDir = ${androidcompat.rootDir}/extappdata
|
||||||
|
|
||||||
# Internal Android directories
|
# Internal Android directories
|
||||||
android.files.dataDir = ${android.files.rootDir}/data
|
android.files.dataDir = ${android.files.rootDir}/data
|
||||||
@@ -48,37 +24,16 @@ android.files.externalCacheDirs = [${android.files.externalStorageDir}/cache]
|
|||||||
android.files.externalMediaDirs = [${android.files.externalStorageDir}/media]
|
android.files.externalMediaDirs = [${android.files.externalStorageDir}/media]
|
||||||
android.files.downloadCacheDir = ${android.files.externalStorageDir}/downloadCache
|
android.files.downloadCacheDir = ${android.files.externalStorageDir}/downloadCache
|
||||||
|
|
||||||
android.files.packageDir = ${ts.server.rootDir}/android-compat/packages
|
android.files.packageDir = ${androidcompat.rootDir}/android-compat/packages
|
||||||
|
|
||||||
|
####################### `android.app` (ApplicationInfoConfigModule) #######################
|
||||||
|
|
||||||
# Emulated Android app package name
|
# Emulated Android app package name
|
||||||
android.app.packageName = eu.kanade.tachiyomi
|
android.app.packageName = eu.kanade.tachiyomi
|
||||||
# Debug mode for the emulated Android app
|
# Debug mode for the emulated Android app
|
||||||
android.app.debug = true
|
android.app.debug = true
|
||||||
|
|
||||||
|
####################### `android.system` (SystemConfigModule) #######################
|
||||||
|
|
||||||
# Whether or not the emulated Android system is debuggable
|
# Whether or not the emulated Android system is debuggable
|
||||||
android.system.isDebuggable = true
|
android.system.isDebuggable = true
|
||||||
|
|
||||||
# Is the multi-user sync server enabled? Does not affect the single-user sync server included in the API.
|
|
||||||
ts.syncd.enable = false
|
|
||||||
|
|
||||||
# The URL of this server (displayed in the sync server web ui)
|
|
||||||
ts.syncd.baseUrl = "http://example.com"
|
|
||||||
|
|
||||||
# 'true' to disable the API and only enable the multi-user sync server
|
|
||||||
ts.syncd.syncOnlyMode = false
|
|
||||||
|
|
||||||
# The root directory to store synchronized data
|
|
||||||
ts.syncd.rootDir = ${ts.server.rootDir}/sync/accounts
|
|
||||||
|
|
||||||
# Location to store config files for the sandbox
|
|
||||||
ts.syncd.sandboxedConfig = ${ts.server.rootDir}/sync/sandboxed_config.config
|
|
||||||
|
|
||||||
# Recaptcha stuff for signup/login
|
|
||||||
ts.syncd.recaptcha.siteKey = ""
|
|
||||||
ts.syncd.recaptcha.secret = ""
|
|
||||||
|
|
||||||
# Sync server display name
|
|
||||||
ts.syncd.name = "Tachiyomi sync server"
|
|
||||||
|
|
||||||
# Header used to forward the IP to the multi-user sync server if the server is behind a reverse proxy
|
|
||||||
ts.syncd.ipHeader = ""
|
|
||||||
|
|||||||
+21
-36
@@ -2,51 +2,36 @@
|
|||||||
## Where should I start?
|
## Where should I start?
|
||||||
Checkout [This Kanban Board](https://github.com/Suwayomi/Tachidesk/projects/1) to see the rough development roadmap.
|
Checkout [This Kanban Board](https://github.com/Suwayomi/Tachidesk/projects/1) to see the rough development roadmap.
|
||||||
|
|
||||||
**Note to potential contributors:** Notify the developers on Suwayomi discord (#programming channel) or open a WIP pull request before starting if you decide to take on working on anything from/not from the roadmap in order to avoid parallel efforts on the same issue/feature.
|
**Note to potential contributors:** Notify the developers on [Suwayomi discord](https://discord.gg/DDZdqZWaHA) (#programming channel) or open a WIP pull request before starting if you decide to take on working on anything from/not from the roadmap in order to avoid parallel efforts on the same issue/feature.
|
||||||
|
|
||||||
## How does Tachidesk work?
|
## How does Tachidesk-Server work?
|
||||||
This project has two components:
|
This project has two components:
|
||||||
1. **server:** contains the implementation of [tachiyomi's extensions library](https://github.com/tachiyomiorg/extensions-lib) and uses an Android compatibility library to run apk extensions. All this concludes to serving a REST API to `webUI`.
|
1. **Server:** contains the implementation of [tachiyomi's extensions library](https://github.com/tachiyomiorg/extensions-lib) and uses an Android compatibility library to run jar libraries converted from apk extensions. All this concludes to serving a REST API.
|
||||||
2. **webUI:** A react SPA(`create-react-app`) project that works with the server to do the presentation.
|
2. **WebUI:** A react SPA(`create-react-app`) project that works with the server to do the presentation located at https://github.com/Suwayomi/Tachidesk-WebUI
|
||||||
|
|
||||||
## Why a web app?
|
## Why a web server app?
|
||||||
This structure is chosen to
|
This structure is chosen to
|
||||||
- Achieve the maximum multi-platform-ness
|
- Achieve the maximum multi-platform-ness
|
||||||
- Gives the ability to acces Tachidesk from a remote web browser e.g. your phone, tablet or smart TV
|
- Gives the ability to acces Tachidesk-Server from a remote client e.g. your phone, tablet or smart TV
|
||||||
- Eaise development of alternative user intefaces for Tachidesk
|
- Eaise development of user intefaces for Tachidesk
|
||||||
|
|
||||||
## User Interfaces for Tachidesk server
|
|
||||||
Currently, there are three known interfaces for Tachidesk:
|
|
||||||
1. [webUI](https://github.com/Suwayomi/Tachidesk/tree/master/webUI/react): The react SPA that Tachidesk is traditionally shipped with.
|
|
||||||
2. [TachideskJUI](https://github.com/Suwayomi/TachideskJUI): A Jetbrains Compose Native app, re-uses components made for the upcoming Tachiyomi 1.x
|
|
||||||
3. [Equinox](https://github.com/Suwayomi/Equinox): A web user interface made with Vue.js, in super early stages of development.
|
|
||||||
|
|
||||||
## Building from source
|
## Building from source
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
You need these software packages installed in order to build the project
|
You need these software packages installed in order to build the project
|
||||||
### Server
|
|
||||||
- Java Development Kit and Java Runtime Environment version 8 or newer(both Oracle JDK and OpenJDK works)
|
- Java Development Kit and Java Runtime Environment version 8 or newer(both Oracle JDK and OpenJDK works)
|
||||||
- Android stubs jar
|
- Android stubs jar
|
||||||
- Manual download: Download [android.jar](https://raw.githubusercontent.com/Suwayomi/Tachidesk/android-jar/android.jar) and put it under `AndroidCompat/lib`.
|
- **Manual download:** Download [android.jar](https://raw.githubusercontent.com/Suwayomi/Tachidesk/android-jar/android.jar) and put it under `AndroidCompat/lib`.
|
||||||
- Automated download: Run `AndroidCompat/getAndroid.sh`(MacOS/Linux) or `AndroidCompat/getAndroid.ps1`(Windows) from project's root directory to download and rebuild the jar file from Google's repository.
|
- **Automated download:** Run `AndroidCompat/getAndroid.sh`(MacOS/Linux) or `AndroidCompat/getAndroid.ps1`(Windows) from project's root directory to download and rebuild the jar file from Google's repository.
|
||||||
### webUI
|
|
||||||
- Nodejs LTS or latest
|
|
||||||
- Yarn
|
|
||||||
- Git
|
|
||||||
### building the full-blown jar
|
|
||||||
Run `./gradlew :webUI:copyBuild server:shadowJar`, the resulting built jar file will be `server/build/Tachidesk-vX.Y.Z-rxxx.jar`.
|
|
||||||
### building without `webUI` bundled(server only)
|
|
||||||
Delete the `server/src/main/resources/react` directory if exists from previous runs, then run `./gradlew server:shadowJar`, the resulting built jar file will be `server/build/Tachidesk-vX.Y.Z-rxxx.jar`.
|
|
||||||
### building the Windows package
|
|
||||||
First Build the jar, then cd into the `scripts` directory and run `./windows<bits>-bundler.sh` (or `./windows<bits>-bundler.ps1` if you are on windows), the resulting built zip package file will be `server/build/Tachidesk-vX.Y.Z-rxxx-win64.zip`.
|
|
||||||
## Running in development mode
|
|
||||||
First satisfy [the prerequisites](#prerequisites)
|
|
||||||
### server
|
|
||||||
run `./gradlew :server:run --stacktrace` to run the server
|
|
||||||
### webUI
|
|
||||||
How to do it is described in `webUI/react/README.md` but for short,
|
|
||||||
first cd into `webUI/react` then run `yarn` to install the node modules(do this only once)
|
|
||||||
then `yarn start` to start the development server, if a new browser window doesn't get opened automatically,
|
|
||||||
then open `http://127.0.0.1:3000` in a modern browser. This is a `create-react-app` project
|
|
||||||
and supports HMR and all the other goodies you'll need.
|
|
||||||
|
|
||||||
|
### building the full-blown jar (Tachidesk-Server + Tachidesk-WebUI bundle)
|
||||||
|
Run `./gradlew server:downloadWebUI server:shadowJar`, the resulting built jar file will be `server/build/Tachidesk-Server-vX.Y.Z-rxxx.jar`.
|
||||||
|
|
||||||
|
### building without `webUI` bundled (server only)
|
||||||
|
Delete `server/src/main/resources/WebUI.zip` if exists from previous runs, then run `./gradlew server:shadowJar`, the resulting built jar file will be `server/build/Tachidesk-Server-vX.Y.Z-rxxx.jar`.
|
||||||
|
|
||||||
|
### building the Windows package
|
||||||
|
First Build the jar, then cd into the `scripts` directory and run `./windows-bundler.sh win32` or `./windows-bundler.sh win64` depending on the target architecture, the resulting built zip package file will be `server/build/Tachidesk-Server-vX.Y.Z-rxxx-winXX.zip`.
|
||||||
|
|
||||||
|
## Running in development mode
|
||||||
|
run `./gradlew :server:run --stacktrace` to run the server
|
||||||
|
|||||||
@@ -3,30 +3,43 @@
|
|||||||
|-------|----------|---------|---------|
|
|-------|----------|---------|---------|
|
||||||
|  | [](https://github.com/Suwayomi/Tachidesk/releases) | [](https://github.com/Suwayomi/Tachidesk-preview/releases/latest) | [](https://discord.gg/DDZdqZWaHA) |
|
|  | [](https://github.com/Suwayomi/Tachidesk/releases) | [](https://github.com/Suwayomi/Tachidesk-preview/releases/latest) | [](https://discord.gg/DDZdqZWaHA) |
|
||||||
|
|
||||||
# Tachidesk
|
# Tachidesk-Server is a server app! You may not want to Download Tachidesk-Server directly.
|
||||||
|
Yes, you need a client/user interface app as a front-end for Tachidesk-Server, if you Directly Download Tachidesk-Server you'll get a bundled version of [Tachodesk-WebUI](https://github.com/Suwayomi/Tachidesk-WebUI) with it.
|
||||||
|
|
||||||
|
Here's a list of known clients/user interfaces for Tachidesk-Server:
|
||||||
|
- [Tachidesk-JUI](https://github.com/Suwayomi/Tachidesk-JUI): The "official" front-end for Tachidesk-Server, A native desktop Application.
|
||||||
|
- [Tachidesk-WebUI](https://github.com/Suwayomi/Tachidesk-WebUI): The web/electrion front-end that Tachidesk is traditionally shipped with.
|
||||||
|
- [Tachidesk-qtui](https://github.com/Suwayomi/Tachidesk-qtui): A C++/Qt front-end for mobile devices(Android/linux), in super early stage of development.
|
||||||
|
- [Equinox](https://github.com/Suwayomi/Equinox): A web user interface made with Vue.js, in super early stage of development.
|
||||||
|
|
||||||
|
# What is Tachidesk then?
|
||||||
<img src="https://github.com/Suwayomi/Tachidesk/raw/master/server/src/main/resources/icon/faviconlogo.png" alt="drawing" width="200"/>
|
<img src="https://github.com/Suwayomi/Tachidesk/raw/master/server/src/main/resources/icon/faviconlogo.png" alt="drawing" width="200"/>
|
||||||
|
|
||||||
A free and open source manga reader that runs extensions built for [Tachiyomi](https://tachiyomi.org/).
|
A free and open source manga reader server that runs extensions built for [Tachiyomi](https://tachiyomi.org/).
|
||||||
|
|
||||||
Tachidesk is an independent Tachiyomi compatible software and is **not a Fork of** Tachiyomi.
|
Tachidesk is an independent Tachiyomi compatible software and is **not a Fork of** Tachiyomi.
|
||||||
|
|
||||||
Tachidesk is as multi-platform as you can get. Any platform that runs java and/or has a modern browser can run it. This includes Windows, Linux, macOS, chrome OS, etc. Follow [Downloading and Running the app](#downloading-and-running-the-app) for installation instructions.
|
Tachidesk-Server is as multi-platform as you can get. Any platform that runs java and/or has a modern browser can run it. This includes Windows, Linux, macOS, chrome OS, etc. Follow [Downloading and Running the app](#downloading-and-running-the-app) for installation instructions.
|
||||||
|
|
||||||
Ability to read and write Tachiyomi compatible backups and syncing is a planned feature.
|
Ability to read and write Tachiyomi compatible backups and syncing is a planned feature.
|
||||||
|
|
||||||
**Tachidesk needs serious front-end dev help for it's reader and other parts, if you like the app and want to see it become better please don't hesitate to contribute some code!**
|
|
||||||
|
|
||||||
## Is this application usable? Should I test it?
|
## Is this application usable? Should I test it?
|
||||||
Here is a list of current features:
|
Here is a list of current features:
|
||||||
|
|
||||||
- Installing and executing Tachiyomi's Extensions, So you'll get the same sources.
|
- From Tachiyomi
|
||||||
- A library to save your mangas and categories to put them into.
|
- Installing and executing Tachiyomi's Extensions, So you'll get the same sources
|
||||||
- Searching and browsing installed sources.
|
- A library to save your mangas and categories to put them into
|
||||||
- A decent chapter reader.
|
- Searching and browsing installed sources
|
||||||
- Ability to download Manga for offline read
|
- Ability to download Manga for offline read
|
||||||
- Backup and restore support powered by Tachiyomi Legacy Backups
|
- Backup and restore support powered by Tachiyomi Backups
|
||||||
|
- From Aniyomi
|
||||||
|
- Installing and executing Aniyomi's Extensions
|
||||||
|
- Searching and browsing installed sources.
|
||||||
|
- Viewing an anime and it's episodes
|
||||||
|
|
||||||
**Note:** Keep in mind that Tachidesk is alpha software and can break rarely and/or with each update. See [Troubleshooting](https://github.com/Suwayomi/Tachidesk/wiki/Troubleshooting) if it happens.
|
**Note:** These are capabilities of Tachidesk-Server, the actual working support is provided by each front-end app, checkout their respective readme for more info.
|
||||||
|
|
||||||
|
**Note:** Tachidesk-Server is alpha software and can break rarely and/or with each update. See [Troubleshooting](https://github.com/Suwayomi/Tachidesk-Server/wiki/Troubleshooting) if it happens.
|
||||||
|
|
||||||
## Downloading and Running the app
|
## Downloading and Running the app
|
||||||
### All Operating Systems
|
### All Operating Systems
|
||||||
@@ -75,9 +88,9 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|||||||
## Credit
|
## Credit
|
||||||
This project is a spiritual successor of [TachiWeb-Server](https://github.com/Tachiweb/TachiWeb-server), Many of the ideas and the groundwork adopted in this project comes from TachiWeb.
|
This project is a spiritual successor of [TachiWeb-Server](https://github.com/Tachiweb/TachiWeb-server), Many of the ideas and the groundwork adopted in this project comes from TachiWeb.
|
||||||
|
|
||||||
The `AndroidCompat` module was originally developed by [@null-dev](https://github.com/null-dev) for [TachiWeb-Server](https://github.com/Tachiweb/TachiWeb-server) and is licensed under `Apache License Version 2.0`.
|
The `AndroidCompat` module was originally developed by [@null-dev](https://github.com/null-dev) for [TachiWeb-Server](https://github.com/Tachiweb/TachiWeb-server) and is licensed under `Apache License Version 2.0` and `Copyright 2019 Andy Bao and contributors`.
|
||||||
|
|
||||||
Parts of [tachiyomi](https://github.com/tachiyomiorg/tachiyomi) is adopted into this codebase, also licensed under `Apache License Version 2.0`.
|
Parts of [tachiyomi](https://github.com/tachiyomiorg/tachiyomi) is adopted into this codebase, also licensed under `Apache License Version 2.0` and `Copyright 2015 Javier Tomás`.
|
||||||
|
|
||||||
You can obtain a copy of `Apache License Version 2.0` from http://www.apache.org/licenses/LICENSE-2.0
|
You can obtain a copy of `Apache License Version 2.0` from http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -79,9 +79,10 @@ configure(projects) {
|
|||||||
// to get application content root
|
// to get application content root
|
||||||
implementation("net.harawata:appdirs:1.2.1")
|
implementation("net.harawata:appdirs:1.2.1")
|
||||||
|
|
||||||
// dex2jar: https://github.com/DexPatcher/dex2jar/releases/tag/v2.1-20190905-lanchon
|
// dex2jar
|
||||||
// note: watch https://github.com/ThexXTURBOXx/dex2jar for future development
|
val dex2jarVersion = "v21"
|
||||||
implementation("com.github.DexPatcher.dex2jar:dex-tools:v2.1-20190905-lanchon")
|
implementation("com.github.ThexXTURBOXx.dex2jar:dex-translator:$dex2jarVersion")
|
||||||
|
implementation("com.github.ThexXTURBOXx.dex2jar:dex-tools:$dex2jarVersion")
|
||||||
|
|
||||||
// APK parser
|
// APK parser
|
||||||
implementation("net.dongliu:apk-parser:2.6.10")
|
implementation("net.dongliu:apk-parser:2.6.10")
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ const val kotlinVersion = "1.5.21"
|
|||||||
const val MainClass = "suwayomi.tachidesk.MainKt"
|
const val MainClass = "suwayomi.tachidesk.MainKt"
|
||||||
|
|
||||||
// should be bumped with each stable release
|
// should be bumped with each stable release
|
||||||
val tachideskVersion = System.getenv("ProductVersion") ?: "v0.4.6"
|
val tachideskVersion = System.getenv("ProductVersion") ?: "v0.4.8"
|
||||||
|
|
||||||
val webUIRevisionTag = System.getenv("WebUIRevision") ?: "r24"
|
val webUIRevisionTag = System.getenv("WebUIRevision") ?: "r41"
|
||||||
|
|
||||||
// counts commit count on master
|
// counts commits on the the master branch
|
||||||
val tachideskRevision = runCatching {
|
val tachideskRevision = runCatching {
|
||||||
System.getenv("ProductRevision") ?: Runtime
|
System.getenv("ProductRevision") ?: Runtime
|
||||||
.getRuntime()
|
.getRuntime()
|
||||||
|
|||||||
@@ -1 +1,7 @@
|
|||||||
|
:: cleaner output
|
||||||
|
@echo off
|
||||||
|
|
||||||
jre\bin\java -Dsuwayomi.tachidesk.config.server.debugLogsEnabled=true -jar Tachidesk.jar
|
jre\bin\java -Dsuwayomi.tachidesk.config.server.debugLogsEnabled=true -jar Tachidesk.jar
|
||||||
|
|
||||||
|
:: Prevent cmd from closing when Tachidesk crashes
|
||||||
|
pause
|
||||||
+12
-7
@@ -7,8 +7,9 @@ import java.time.Instant
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
application
|
application
|
||||||
|
kotlin("plugin.serialization")
|
||||||
id("com.github.johnrengelman.shadow") version "7.0.0"
|
id("com.github.johnrengelman.shadow") version "7.0.0"
|
||||||
id("org.jmailen.kotlinter") version "3.4.3"
|
id("org.jmailen.kotlinter") version "3.5.0"
|
||||||
id("com.github.gmazzo.buildconfig") version "3.0.2"
|
id("com.github.gmazzo.buildconfig") version "3.0.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +46,7 @@ dependencies {
|
|||||||
implementation("com.h2database:h2:1.4.200")
|
implementation("com.h2database:h2:1.4.200")
|
||||||
|
|
||||||
// Exposed Migrations
|
// Exposed Migrations
|
||||||
val exposedMigrationsVersion = "3.1.0"
|
val exposedMigrationsVersion = "3.1.1"
|
||||||
implementation("com.github.Suwayomi:exposed-migrations:$exposedMigrationsVersion")
|
implementation("com.github.Suwayomi:exposed-migrations:$exposedMigrationsVersion")
|
||||||
|
|
||||||
// tray icon
|
// tray icon
|
||||||
@@ -57,17 +58,20 @@ dependencies {
|
|||||||
implementation("com.github.inorichi.injekt:injekt-core:65b0440")
|
implementation("com.github.inorichi.injekt:injekt-core:65b0440")
|
||||||
implementation("com.squareup.okhttp3:okhttp:4.9.1")
|
implementation("com.squareup.okhttp3:okhttp:4.9.1")
|
||||||
implementation("io.reactivex:rxjava:1.3.8")
|
implementation("io.reactivex:rxjava:1.3.8")
|
||||||
implementation("org.jsoup:jsoup:1.13.1")
|
implementation("org.jsoup:jsoup:1.14.1")
|
||||||
implementation("com.google.code.gson:gson:2.8.6")
|
implementation("com.google.code.gson:gson:2.8.7")
|
||||||
implementation("com.github.salomonbrys.kotson:kotson:2.5.0")
|
implementation("com.github.salomonbrys.kotson:kotson:2.5.0")
|
||||||
|
|
||||||
|
|
||||||
// asm for fixing SimpleDateFormat (must match Dex2Jar version)
|
// asm for ByteCodeEditor(fixing SimpleDateFormat) (must match Dex2Jar version)
|
||||||
implementation("org.ow2.asm:asm-debug-all:5.0.3")
|
implementation("org.ow2.asm:asm:9.2")
|
||||||
|
|
||||||
// extracting zip files
|
// extracting zip files
|
||||||
implementation("net.lingala.zip4j:zip4j:2.9.0")
|
implementation("net.lingala.zip4j:zip4j:2.9.0")
|
||||||
|
|
||||||
|
// CloudflareInterceptor
|
||||||
|
implementation("net.sourceforge.htmlunit:htmlunit:2.52.0")
|
||||||
|
|
||||||
// Source models and interfaces from Tachiyomi 1.x
|
// Source models and interfaces from Tachiyomi 1.x
|
||||||
// using source class from tachiyomi commit 9493577de27c40ce8b2b6122cc447d025e34c477 to not depend on tachiyomi.sourceapi
|
// using source class from tachiyomi commit 9493577de27c40ce8b2b6122cc447d025e34c477 to not depend on tachiyomi.sourceapi
|
||||||
// implementation("tachiyomi.sourceapi:source-api:1.1")
|
// implementation("tachiyomi.sourceapi:source-api:1.1")
|
||||||
@@ -143,7 +147,8 @@ tasks {
|
|||||||
freeCompilerArgs = listOf(
|
freeCompilerArgs = listOf(
|
||||||
"-Xopt-in=kotlin.RequiresOptIn",
|
"-Xopt-in=kotlin.RequiresOptIn",
|
||||||
"-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
|
"-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
|
||||||
"-Xopt-in=kotlinx.coroutines.InternalCoroutinesApi"
|
"-Xopt-in=kotlinx.coroutines.InternalCoroutinesApi",
|
||||||
|
"-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,177 +0,0 @@
|
|||||||
package eu.kanade.tachiyomi.network
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) Contributors to the Suwayomi project
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
// import android.annotation.SuppressLint
|
|
||||||
// import android.content.Context
|
|
||||||
// import android.os.Build
|
|
||||||
// import android.os.Handler
|
|
||||||
// import android.os.Looper
|
|
||||||
// import android.webkit.WebSettings
|
|
||||||
// import android.webkit.WebView
|
|
||||||
// import android.widget.Toast
|
|
||||||
// import eu.kanade.tachiyomi.R
|
|
||||||
// import eu.kanade.tachiyomi.util.lang.launchUI
|
|
||||||
// import eu.kanade.tachiyomi.util.system.WebViewClientCompat
|
|
||||||
// import eu.kanade.tachiyomi.util.system.WebViewUtil
|
|
||||||
// import eu.kanade.tachiyomi.util.system.isOutdated
|
|
||||||
// import eu.kanade.tachiyomi.util.system.setDefaultSettings
|
|
||||||
// import eu.kanade.tachiyomi.util.system.toast
|
|
||||||
import okhttp3.Interceptor
|
|
||||||
import okhttp3.Response
|
|
||||||
// import uy.kohesive.injekt.injectLazy
|
|
||||||
|
|
||||||
class CloudflareInterceptor() : Interceptor {
|
|
||||||
|
|
||||||
// private val handler = Handler(Looper.getMainLooper())
|
|
||||||
|
|
||||||
// private val networkHelper = NetworkHelper()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* When this is called, it initializes the WebView if it wasn't already. We use this to avoid
|
|
||||||
* blocking the main thread too much. If used too often we could consider moving it to the
|
|
||||||
* Application class.
|
|
||||||
*/
|
|
||||||
// private val initWebView by lazy {
|
|
||||||
// WebSettings.getDefaultUserAgent(context)
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Synchronized
|
|
||||||
override fun intercept(chain: Interceptor.Chain): Response {
|
|
||||||
val originalRequest = chain.request()
|
|
||||||
return chain.proceed(originalRequest)
|
|
||||||
|
|
||||||
// if (!WebViewUtil.supportsWebView(context)) {
|
|
||||||
// launchUI {
|
|
||||||
// context.toast(R.string.information_webview_required, Toast.LENGTH_LONG)
|
|
||||||
// }
|
|
||||||
// return chain.proceed(originalRequest)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// initWebView
|
|
||||||
//
|
|
||||||
// val response = chain.proceed(originalRequest)
|
|
||||||
//
|
|
||||||
// // Check if Cloudflare anti-bot is on
|
|
||||||
// if (response.code != 503 || response.header("Server") !in SERVER_CHECK) {
|
|
||||||
// return response
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
// response.close()
|
|
||||||
// networkHelper.cookieManager.remove(originalRequest.url, COOKIE_NAMES, 0)
|
|
||||||
// val oldCookie = networkHelper.cookieManager.get(originalRequest.url)
|
|
||||||
// .firstOrNull { it.name == "cf_clearance" }
|
|
||||||
// resolveWithWebView(originalRequest, oldCookie)
|
|
||||||
//
|
|
||||||
// return chain.proceed(originalRequest)
|
|
||||||
// } catch (e: Exception) {
|
|
||||||
// // Because OkHttp's enqueue only handles IOExceptions, wrap the exception so that
|
|
||||||
// // we don't crash the entire app
|
|
||||||
// throw IOException(e)
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// // @SuppressLint("SetJavaScriptEnabled")
|
|
||||||
// private fun resolveWithWebView(request: Request, oldCookie: Cookie?) {
|
|
||||||
// // We need to lock this thread until the WebView finds the challenge solution url, because
|
|
||||||
// // OkHttp doesn't support asynchronous interceptors.
|
|
||||||
// val latch = CountDownLatch(1)
|
|
||||||
//
|
|
||||||
// var webView: WebView? = null
|
|
||||||
//
|
|
||||||
// var challengeFound = false
|
|
||||||
// var cloudflareBypassed = false
|
|
||||||
// var isWebViewOutdated = false
|
|
||||||
//
|
|
||||||
// val origRequestUrl = request.url.toString()
|
|
||||||
// val headers = request.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }.toMutableMap()
|
|
||||||
// headers["X-Requested-With"] = WebViewUtil.REQUESTED_WITH
|
|
||||||
//
|
|
||||||
// handler.post {
|
|
||||||
// val webview = WebView(context)
|
|
||||||
// webView = webview
|
|
||||||
// webview.setDefaultSettings()
|
|
||||||
//
|
|
||||||
// // Avoid sending empty User-Agent, Chromium WebView will reset to default if empty
|
|
||||||
// webview.settings.userAgentString = request.header("User-Agent")
|
|
||||||
// ?: HttpSource.DEFAULT_USERAGENT
|
|
||||||
//
|
|
||||||
// webview.webViewClient = object : WebViewClientCompat() {
|
|
||||||
// override fun onPageFinished(view: WebView, url: String) {
|
|
||||||
// fun isCloudFlareBypassed(): Boolean {
|
|
||||||
// return networkHelper.cookieManager.get(origRequestUrl.toHttpUrl())
|
|
||||||
// .firstOrNull { it.name == "cf_clearance" }
|
|
||||||
// .let { it != null && it != oldCookie }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (isCloudFlareBypassed()) {
|
|
||||||
// cloudflareBypassed = true
|
|
||||||
// latch.countDown()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // HTTP error codes are only received since M
|
|
||||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
|
|
||||||
// url == origRequestUrl && !challengeFound
|
|
||||||
// ) {
|
|
||||||
// // The first request didn't return the challenge, abort.
|
|
||||||
// latch.countDown()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onReceivedErrorCompat(
|
|
||||||
// view: WebView,
|
|
||||||
// errorCode: Int,
|
|
||||||
// description: String?,
|
|
||||||
// failingUrl: String,
|
|
||||||
// isMainFrame: Boolean
|
|
||||||
// ) {
|
|
||||||
// if (isMainFrame) {
|
|
||||||
// if (errorCode == 503) {
|
|
||||||
// // Found the Cloudflare challenge page.
|
|
||||||
// challengeFound = true
|
|
||||||
// } else {
|
|
||||||
// // Unlock thread, the challenge wasn't found.
|
|
||||||
// latch.countDown()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// webView?.loadUrl(origRequestUrl, headers)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Wait a reasonable amount of time to retrieve the solution. The minimum should be
|
|
||||||
// // around 4 seconds but it can take more due to slow networks or server issues.
|
|
||||||
// latch.await(12, TimeUnit.SECONDS)
|
|
||||||
//
|
|
||||||
// handler.post {
|
|
||||||
// if (!cloudflareBypassed) {
|
|
||||||
// isWebViewOutdated = webView?.isOutdated() == true
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// webView?.stopLoading()
|
|
||||||
// webView?.destroy()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Throw exception if we failed to bypass Cloudflare
|
|
||||||
// if (!cloudflareBypassed) {
|
|
||||||
// // Prompt user to update WebView if it seems too outdated
|
|
||||||
// if (isWebViewOutdated) {
|
|
||||||
// context.toast(R.string.information_webview_outdated, Toast.LENGTH_LONG)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// throw Exception(context.getString(R.string.information_cloudflare_bypass_failure))
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// companion object {
|
|
||||||
// private val SERVER_CHECK = arrayOf("cloudflare-nginx", "cloudflare")
|
|
||||||
// private val COOKIE_NAMES = listOf("__cfduid", "cf_clearance")
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@@ -10,12 +10,16 @@ package eu.kanade.tachiyomi.network
|
|||||||
// import android.content.Context
|
// import android.content.Context
|
||||||
// import eu.kanade.tachiyomi.BuildConfig
|
// import eu.kanade.tachiyomi.BuildConfig
|
||||||
// import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
// import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import android.content.Context
|
|
||||||
// import okhttp3.HttpUrl.Companion.toHttpUrl
|
// import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import okhttp3.OkHttpClient
|
|
||||||
// import okhttp3.dnsoverhttps.DnsOverHttps
|
// import okhttp3.dnsoverhttps.DnsOverHttps
|
||||||
// import okhttp3.logging.HttpLoggingInterceptor
|
// import okhttp3.logging.HttpLoggingInterceptor
|
||||||
// import uy.kohesive.injekt.injectLazy
|
// import uy.kohesive.injekt.injectLazy
|
||||||
|
import android.content.Context
|
||||||
|
import eu.kanade.tachiyomi.network.interceptor.CloudflareInterceptor
|
||||||
|
import eu.kanade.tachiyomi.network.interceptor.UserAgentInterceptor
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.logging.HttpLoggingInterceptor
|
||||||
|
import suwayomi.tachidesk.server.serverConfig
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
@Suppress("UNUSED_PARAMETER")
|
@Suppress("UNUSED_PARAMETER")
|
||||||
@@ -25,55 +29,44 @@ class NetworkHelper(context: Context) {
|
|||||||
|
|
||||||
// private val cacheDir = File(context.cacheDir, "network_cache")
|
// private val cacheDir = File(context.cacheDir, "network_cache")
|
||||||
|
|
||||||
private val cacheSize = 5L * 1024 * 1024 // 5 MiB
|
// private val cacheSize = 5L * 1024 * 1024 // 5 MiB
|
||||||
|
|
||||||
val cookieManager = MemoryCookieJar()
|
val cookieManager = PersistentCookieJar(context)
|
||||||
|
|
||||||
val client by lazy {
|
private val baseClientBuilder: OkHttpClient.Builder
|
||||||
val builder = OkHttpClient.Builder()
|
get() {
|
||||||
.cookieJar(cookieManager)
|
val builder = OkHttpClient.Builder()
|
||||||
// .cache(Cache(cacheDir, cacheSize))
|
.cookieJar(cookieManager)
|
||||||
.connectTimeout(30, TimeUnit.SECONDS)
|
.connectTimeout(30, TimeUnit.SECONDS)
|
||||||
.readTimeout(5, TimeUnit.MINUTES)
|
.readTimeout(30, TimeUnit.SECONDS)
|
||||||
.writeTimeout(5, TimeUnit.MINUTES)
|
.addInterceptor(UserAgentInterceptor())
|
||||||
// .dispatcher(Dispatcher(Executors.newFixedThreadPool(1)))
|
|
||||||
|
|
||||||
// .addInterceptor(UserAgentInterceptor())
|
if (serverConfig.debugLogsEnabled) {
|
||||||
|
val httpLoggingInterceptor = HttpLoggingInterceptor().apply {
|
||||||
|
level = HttpLoggingInterceptor.Level.BASIC
|
||||||
|
}
|
||||||
|
builder.addInterceptor(httpLoggingInterceptor)
|
||||||
|
}
|
||||||
|
|
||||||
// if (BuildConfig.DEBUG) {
|
// when (preferences.dohProvider()) {
|
||||||
// val httpLoggingInterceptor = HttpLoggingInterceptor().apply {
|
// PREF_DOH_CLOUDFLARE -> builder.dohCloudflare()
|
||||||
// level = HttpLoggingInterceptor.Level.HEADERS
|
// PREF_DOH_GOOGLE -> builder.dohGoogle()
|
||||||
// }
|
// }
|
||||||
// builder.addInterceptor(httpLoggingInterceptor)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (preferences.enableDoh()) {
|
return builder
|
||||||
// builder.dns(
|
}
|
||||||
// DnsOverHttps.Builder().client(builder.build())
|
|
||||||
// .url("https://cloudflare-dns.com/dns-query".toHttpUrl())
|
|
||||||
// .bootstrapDnsHosts(
|
|
||||||
// listOf(
|
|
||||||
// InetAddress.getByName("162.159.36.1"),
|
|
||||||
// InetAddress.getByName("162.159.46.1"),
|
|
||||||
// InetAddress.getByName("1.1.1.1"),
|
|
||||||
// InetAddress.getByName("1.0.0.1"),
|
|
||||||
// InetAddress.getByName("162.159.132.53"),
|
|
||||||
// InetAddress.getByName("2606:4700:4700::1111"),
|
|
||||||
// InetAddress.getByName("2606:4700:4700::1001"),
|
|
||||||
// InetAddress.getByName("2606:4700:4700::0064"),
|
|
||||||
// InetAddress.getByName("2606:4700:4700::6400")
|
|
||||||
// )
|
|
||||||
// )
|
|
||||||
// .build()
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
|
|
||||||
builder.build()
|
// val client by lazy { baseClientBuilder.cache(Cache(cacheDir, cacheSize)).build() }
|
||||||
}
|
val client by lazy { baseClientBuilder.build() }
|
||||||
|
|
||||||
val cloudflareClient by lazy {
|
val cloudflareClient by lazy {
|
||||||
client.newBuilder()
|
client.newBuilder()
|
||||||
.addInterceptor(CloudflareInterceptor())
|
.addInterceptor(CloudflareInterceptor())
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tachidesk -->
|
||||||
|
val cookies: PersistentCookieStore
|
||||||
|
get() = cookieManager.store
|
||||||
|
// Tachidesk <--
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package eu.kanade.tachiyomi.network
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import okhttp3.Cookie
|
||||||
|
import okhttp3.CookieJar
|
||||||
|
import okhttp3.HttpUrl
|
||||||
|
|
||||||
|
// from TachiWeb-Server
|
||||||
|
class PersistentCookieJar(context: Context) : CookieJar {
|
||||||
|
|
||||||
|
val store = PersistentCookieStore(context)
|
||||||
|
|
||||||
|
override fun saveFromResponse(url: HttpUrl, cookies: List<Cookie>) {
|
||||||
|
store.addAll(url, cookies)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun loadForRequest(url: HttpUrl): List<Cookie> {
|
||||||
|
return store.get(url)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package eu.kanade.tachiyomi.network
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import okhttp3.Cookie
|
||||||
|
import okhttp3.HttpUrl
|
||||||
|
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||||
|
import java.net.URI
|
||||||
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
|
// from TachiWeb-Server
|
||||||
|
class PersistentCookieStore(context: Context) {
|
||||||
|
|
||||||
|
private val cookieMap = ConcurrentHashMap<String, List<Cookie>>()
|
||||||
|
private val prefs = context.getSharedPreferences("cookie_store", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
|
init {
|
||||||
|
for ((key, value) in prefs.all) {
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
val cookies = value as? Set<String>
|
||||||
|
if (cookies != null) {
|
||||||
|
try {
|
||||||
|
val url = "http://$key".toHttpUrlOrNull() ?: continue
|
||||||
|
val nonExpiredCookies = cookies.mapNotNull { Cookie.parse(url, it) }
|
||||||
|
.filter { !it.hasExpired() }
|
||||||
|
cookieMap.put(key, nonExpiredCookies)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
fun addAll(url: HttpUrl, cookies: List<Cookie>) {
|
||||||
|
val key = url.toUri().host
|
||||||
|
|
||||||
|
// Append or replace the cookies for this domain.
|
||||||
|
val cookiesForDomain = cookieMap[key].orEmpty().toMutableList()
|
||||||
|
for (cookie in cookies) {
|
||||||
|
// Find a cookie with the same name. Replace it if found, otherwise add a new one.
|
||||||
|
val pos = cookiesForDomain.indexOfFirst { it.name == cookie.name }
|
||||||
|
if (pos == -1) {
|
||||||
|
cookiesForDomain.add(cookie)
|
||||||
|
} else {
|
||||||
|
cookiesForDomain[pos] = cookie
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cookieMap.put(key, cookiesForDomain)
|
||||||
|
|
||||||
|
// Get cookies to be stored in disk
|
||||||
|
val newValues = cookiesForDomain.asSequence()
|
||||||
|
.filter { it.persistent && !it.hasExpired() }
|
||||||
|
.map(Cookie::toString)
|
||||||
|
.toSet()
|
||||||
|
|
||||||
|
prefs.edit().putStringSet(key, newValues).apply()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
fun removeAll() {
|
||||||
|
prefs.edit().clear().apply()
|
||||||
|
cookieMap.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun remove(uri: URI) {
|
||||||
|
prefs.edit().remove(uri.host).apply()
|
||||||
|
cookieMap.remove(uri.host)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun get(url: HttpUrl) = get(url.toUri().host)
|
||||||
|
|
||||||
|
fun get(uri: URI) = get(uri.host)
|
||||||
|
|
||||||
|
private fun get(url: String): List<Cookie> {
|
||||||
|
return cookieMap[url].orEmpty().filter { !it.hasExpired() }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Cookie.hasExpired() = System.currentTimeMillis() >= expiresAt
|
||||||
|
}
|
||||||
+110
@@ -0,0 +1,110 @@
|
|||||||
|
package eu.kanade.tachiyomi.network.interceptor
|
||||||
|
|
||||||
|
import com.gargoylesoftware.htmlunit.BrowserVersion
|
||||||
|
import com.gargoylesoftware.htmlunit.WebClient
|
||||||
|
import com.gargoylesoftware.htmlunit.html.HtmlPage
|
||||||
|
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||||
|
import mu.KotlinLogging
|
||||||
|
import okhttp3.Cookie
|
||||||
|
import okhttp3.HttpUrl
|
||||||
|
import okhttp3.Interceptor
|
||||||
|
import okhttp3.Request
|
||||||
|
import okhttp3.Response
|
||||||
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
|
// from TachiWeb-Server
|
||||||
|
class CloudflareInterceptor : Interceptor {
|
||||||
|
private val logger = KotlinLogging.logger {}
|
||||||
|
|
||||||
|
private val network: NetworkHelper by injectLazy()
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
override fun intercept(chain: Interceptor.Chain): Response {
|
||||||
|
val originalRequest = chain.request()
|
||||||
|
|
||||||
|
logger.trace { "CloudflareInterceptor is being used." }
|
||||||
|
|
||||||
|
val response = chain.proceed(originalRequest)
|
||||||
|
|
||||||
|
// Check if Cloudflare anti-bot is on
|
||||||
|
if (response.code != 503 || response.header("Server") !in SERVER_CHECK) {
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug { "Cloudflare anti-bot is on, CloudflareInterceptor is kicking in..." }
|
||||||
|
|
||||||
|
return try {
|
||||||
|
response.close()
|
||||||
|
network.cookies.remove(originalRequest.url.toUri())
|
||||||
|
|
||||||
|
chain.proceed(resolveChallenge(response))
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// Because OkHttp's enqueue only handles IOExceptions, wrap the exception so that
|
||||||
|
// we don't crash the entire app
|
||||||
|
throw IOException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun resolveChallenge(response: Response): Request {
|
||||||
|
val browserVersion = BrowserVersion.BrowserVersionBuilder(BrowserVersion.BEST_SUPPORTED)
|
||||||
|
.setUserAgent(response.request.header("User-Agent") ?: BrowserVersion.BEST_SUPPORTED.userAgent)
|
||||||
|
.build()
|
||||||
|
val convertedCookies = WebClient(browserVersion).use { webClient ->
|
||||||
|
webClient.options.isThrowExceptionOnFailingStatusCode = false
|
||||||
|
webClient.options.isThrowExceptionOnScriptError = false
|
||||||
|
webClient.getPage<HtmlPage>(response.request.url.toString())
|
||||||
|
webClient.waitForBackgroundJavaScript(10000)
|
||||||
|
// Challenge solved, process cookies
|
||||||
|
webClient.cookieManager.cookies.filter {
|
||||||
|
// Only include Cloudflare cookies
|
||||||
|
it.name.startsWith("__cf") || it.name.startsWith("cf_")
|
||||||
|
}.map {
|
||||||
|
// Convert cookies -> OkHttp format
|
||||||
|
Cookie.Builder()
|
||||||
|
.domain(it.domain.removePrefix("."))
|
||||||
|
.expiresAt(it.expires?.time ?: Long.MAX_VALUE)
|
||||||
|
.name(it.name)
|
||||||
|
.path(it.path)
|
||||||
|
.value(it.value).apply {
|
||||||
|
if (it.isHttpOnly) httpOnly()
|
||||||
|
if (it.isSecure) secure()
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy cookies to cookie store
|
||||||
|
convertedCookies.forEach {
|
||||||
|
network.cookies.addAll(
|
||||||
|
HttpUrl.Builder()
|
||||||
|
.scheme("http")
|
||||||
|
.host(it.domain)
|
||||||
|
.build(),
|
||||||
|
listOf(it)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
// Merge new and existing cookies for this request
|
||||||
|
// Find the cookies that we need to merge into this request
|
||||||
|
val convertedForThisRequest = convertedCookies.filter {
|
||||||
|
it.matches(response.request.url)
|
||||||
|
}
|
||||||
|
// Extract cookies from current request
|
||||||
|
val existingCookies = Cookie.parseAll(
|
||||||
|
response.request.url,
|
||||||
|
response.request.headers
|
||||||
|
)
|
||||||
|
// Filter out existing values of cookies that we are about to merge in
|
||||||
|
val filteredExisting = existingCookies.filter { existing ->
|
||||||
|
convertedForThisRequest.none { converted -> converted.name == existing.name }
|
||||||
|
}
|
||||||
|
val newCookies = filteredExisting + convertedForThisRequest
|
||||||
|
return response.request.newBuilder()
|
||||||
|
.header("Cookie", newCookies.map { it.toString() }.joinToString("; "))
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val SERVER_CHECK = arrayOf("cloudflare-nginx", "cloudflare")
|
||||||
|
private val COOKIE_NAMES = listOf("cf_clearance")
|
||||||
|
}
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package eu.kanade.tachiyomi.network.interceptor
|
||||||
|
|
||||||
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
|
import okhttp3.Interceptor
|
||||||
|
import okhttp3.Response
|
||||||
|
|
||||||
|
class UserAgentInterceptor : Interceptor {
|
||||||
|
override fun intercept(chain: Interceptor.Chain): Response {
|
||||||
|
val originalRequest = chain.request()
|
||||||
|
|
||||||
|
return if (originalRequest.header("User-Agent").isNullOrEmpty()) {
|
||||||
|
val newRequest = originalRequest
|
||||||
|
.newBuilder()
|
||||||
|
.removeHeader("User-Agent")
|
||||||
|
.addHeader("User-Agent", HttpSource.DEFAULT_USER_AGENT)
|
||||||
|
.build()
|
||||||
|
chain.proceed(newRequest)
|
||||||
|
} else {
|
||||||
|
chain.proceed(originalRequest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -61,3 +61,30 @@ interface SManga : Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fun SManga.toMangaInfo(): MangaInfo {
|
||||||
|
// return MangaInfo(
|
||||||
|
// key = this.url,
|
||||||
|
// title = this.title,
|
||||||
|
// artist = this.artist ?: "",
|
||||||
|
// author = this.author ?: "",
|
||||||
|
// description = this.description ?: "",
|
||||||
|
// genres = this.genre?.split(", ") ?: emptyList(),
|
||||||
|
// status = this.status,
|
||||||
|
// cover = this.thumbnail_url ?: ""
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// fun MangaInfo.toSManga(): SManga {
|
||||||
|
// val mangaInfo = this
|
||||||
|
// return SManga.create().apply {
|
||||||
|
// url = mangaInfo.key
|
||||||
|
// title = mangaInfo.title
|
||||||
|
// artist = mangaInfo.artist
|
||||||
|
// author = mangaInfo.author
|
||||||
|
// description = mangaInfo.description
|
||||||
|
// genre = mangaInfo.genres.joinToString(", ")
|
||||||
|
// status = mangaInfo.status
|
||||||
|
// thumbnail_url = mangaInfo.cover
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
* Headers builder for requests. Implementations can override this method for custom headers.
|
* Headers builder for requests. Implementations can override this method for custom headers.
|
||||||
*/
|
*/
|
||||||
protected open fun headersBuilder() = Headers.Builder().apply {
|
protected open fun headersBuilder() = Headers.Builder().apply {
|
||||||
add("User-Agent", DEFAULT_USERAGENT)
|
add("User-Agent", DEFAULT_USER_AGENT)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -372,6 +372,6 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
override fun getFilterList() = FilterList()
|
override fun getFilterList() = FilterList()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val DEFAULT_USERAGENT = "Mozilla/5.0 (Windows NT 6.3; WOW64)"
|
const val DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36 Edg/88.0.705.63"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ import io.javalin.apibuilder.ApiBuilder.path
|
|||||||
import io.javalin.apibuilder.ApiBuilder.post
|
import io.javalin.apibuilder.ApiBuilder.post
|
||||||
import io.javalin.apibuilder.ApiBuilder.ws
|
import io.javalin.apibuilder.ApiBuilder.ws
|
||||||
import suwayomi.tachidesk.manga.controller.BackupController
|
import suwayomi.tachidesk.manga.controller.BackupController
|
||||||
|
import suwayomi.tachidesk.manga.controller.CategoryController
|
||||||
import suwayomi.tachidesk.manga.controller.DownloadController
|
import suwayomi.tachidesk.manga.controller.DownloadController
|
||||||
import suwayomi.tachidesk.manga.controller.ExtensionController
|
import suwayomi.tachidesk.manga.controller.ExtensionController
|
||||||
import suwayomi.tachidesk.manga.controller.LibraryController
|
|
||||||
import suwayomi.tachidesk.manga.controller.MangaController
|
import suwayomi.tachidesk.manga.controller.MangaController
|
||||||
import suwayomi.tachidesk.manga.controller.SourceController
|
import suwayomi.tachidesk.manga.controller.SourceController
|
||||||
|
|
||||||
@@ -42,10 +42,10 @@ object MangaAPI {
|
|||||||
get(":sourceId/preferences", SourceController::getPreferences)
|
get(":sourceId/preferences", SourceController::getPreferences)
|
||||||
post(":sourceId/preferences", SourceController::setPreference)
|
post(":sourceId/preferences", SourceController::setPreference)
|
||||||
|
|
||||||
post(":sourceId/filters", SourceController::filters) // TODO
|
get(":sourceId/filters", SourceController::filters)
|
||||||
|
|
||||||
get(":sourceId/search/:searchTerm/:pageNum", SourceController::searchSingle)
|
get(":sourceId/search/:searchTerm/:pageNum", SourceController::searchSingle)
|
||||||
get("search/:searchTerm/:pageNum", SourceController::searchSingle) // TODO
|
// get("search/:searchTerm/:pageNum", SourceController::searchGlobal)
|
||||||
}
|
}
|
||||||
|
|
||||||
path("manga") {
|
path("manga") {
|
||||||
@@ -70,27 +70,26 @@ object MangaAPI {
|
|||||||
get(":mangaId/chapter/:chapterIndex/page/:index", MangaController::pageRetrieve)
|
get(":mangaId/chapter/:chapterIndex/page/:index", MangaController::pageRetrieve)
|
||||||
}
|
}
|
||||||
|
|
||||||
path("") {
|
path("category") {
|
||||||
get("library", LibraryController::list)
|
get("", CategoryController::categoryList)
|
||||||
|
post("", CategoryController::categoryCreate)
|
||||||
|
|
||||||
path("category") {
|
get(":categoryId", CategoryController::categoryMangas)
|
||||||
get("", LibraryController::categoryList)
|
patch(":categoryId", CategoryController::categoryModify)
|
||||||
post("", LibraryController::categoryCreate)
|
delete(":categoryId", CategoryController::categoryDelete)
|
||||||
|
|
||||||
get(":categoryId", LibraryController::categoryMangas)
|
patch("reorder", CategoryController::categoryReorder)
|
||||||
patch(":categoryId", LibraryController::categoryModify)
|
|
||||||
delete(":categoryId", LibraryController::categoryDelete)
|
|
||||||
|
|
||||||
patch(":categoryId/reorder", LibraryController::categoryReorder) // TODO: the underlying code doesn't need `:categoryId`, remove it
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
path("backup") {
|
path("backup") {
|
||||||
post("legacy/import", BackupController::legacyImport)
|
post("import", BackupController::protobufImport)
|
||||||
post("legacy/import/file", BackupController::legacyImportFile)
|
post("import/file", BackupController::protobufImportFile)
|
||||||
|
|
||||||
get("legacy/export", BackupController::legacyExport)
|
post("validate", BackupController::protobufValidate)
|
||||||
get("legacy/export/file", BackupController::legacyExportFile)
|
post("validate/file", BackupController::protobufValidateFile)
|
||||||
|
|
||||||
|
get("export", BackupController::protobufExport)
|
||||||
|
get("export/file", BackupController::protobufExportFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
path("downloads") {
|
path("downloads") {
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ package suwayomi.tachidesk.manga.controller
|
|||||||
|
|
||||||
import io.javalin.http.Context
|
import io.javalin.http.Context
|
||||||
import suwayomi.tachidesk.manga.impl.backup.BackupFlags
|
import suwayomi.tachidesk.manga.impl.backup.BackupFlags
|
||||||
import suwayomi.tachidesk.manga.impl.backup.legacy.LegacyBackupExport
|
import suwayomi.tachidesk.manga.impl.backup.proto.ProtoBackupExport
|
||||||
import suwayomi.tachidesk.manga.impl.backup.legacy.LegacyBackupImport
|
import suwayomi.tachidesk.manga.impl.backup.proto.ProtoBackupImport
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.proto.ProtoBackupValidator
|
||||||
import suwayomi.tachidesk.server.JavalinSetup
|
import suwayomi.tachidesk.server.JavalinSetup
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
@@ -16,30 +17,31 @@ import java.util.Date
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
object BackupController {
|
object BackupController {
|
||||||
/** expects a Tachiyomi legacy backup json in the body */
|
|
||||||
fun legacyImport(ctx: Context) {
|
/** expects a Tachiyomi protobuf backup in the body */
|
||||||
ctx.result(
|
fun protobufImport(ctx: Context) {
|
||||||
|
ctx.json(
|
||||||
JavalinSetup.future {
|
JavalinSetup.future {
|
||||||
LegacyBackupImport.restoreLegacyBackup(ctx.bodyAsInputStream())
|
ProtoBackupImport.performRestore(ctx.bodyAsInputStream())
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** expects a Tachiyomi legacy backup json as a file upload, the file must be named "backup.json" */
|
/** expects a Tachiyomi protobuf backup as a file upload, the file must be named "backup.proto.gz" */
|
||||||
fun legacyImportFile(ctx: Context) {
|
fun protobufImportFile(ctx: Context) {
|
||||||
ctx.result(
|
ctx.json(
|
||||||
JavalinSetup.future {
|
JavalinSetup.future {
|
||||||
LegacyBackupImport.restoreLegacyBackup(ctx.uploadedFile("backup.json")!!.content)
|
ProtoBackupImport.performRestore(ctx.uploadedFile("backup.proto.gz")!!.content)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** returns a Tachiyomi legacy backup json created from the current database as a json body */
|
/** returns a Tachiyomi protobuf backup created from the current database as a body */
|
||||||
fun legacyExport(ctx: Context) {
|
fun protobufExport(ctx: Context) {
|
||||||
ctx.contentType("application/json")
|
ctx.contentType("application/octet-stream")
|
||||||
ctx.result(
|
ctx.result(
|
||||||
JavalinSetup.future {
|
JavalinSetup.future {
|
||||||
LegacyBackupExport.createLegacyBackup(
|
ProtoBackupExport.createBackup(
|
||||||
BackupFlags(
|
BackupFlags(
|
||||||
includeManga = true,
|
includeManga = true,
|
||||||
includeCategories = true,
|
includeCategories = true,
|
||||||
@@ -52,16 +54,15 @@ object BackupController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** returns a Tachiyomi legacy backup json created from the current database as a file */
|
/** returns a Tachiyomi protobuf backup created from the current database as a file */
|
||||||
fun legacyExportFile(ctx: Context) {
|
fun protobufExportFile(ctx: Context) {
|
||||||
ctx.contentType("application/json")
|
ctx.contentType("application/octet-stream")
|
||||||
val sdf = SimpleDateFormat("yyyy-MM-dd_HH-mm")
|
val currentDate = SimpleDateFormat("yyyy-MM-dd_HH-mm").format(Date())
|
||||||
val currentDate = sdf.format(Date())
|
|
||||||
|
|
||||||
ctx.header("Content-Disposition", "attachment; filename=\"tachidesk_$currentDate.json\"")
|
ctx.header("Content-Disposition", """attachment; filename="tachidesk_$currentDate.proto.gz"""")
|
||||||
ctx.result(
|
ctx.result(
|
||||||
JavalinSetup.future {
|
JavalinSetup.future {
|
||||||
LegacyBackupExport.createLegacyBackup(
|
ProtoBackupExport.createBackup(
|
||||||
BackupFlags(
|
BackupFlags(
|
||||||
includeManga = true,
|
includeManga = true,
|
||||||
includeCategories = true,
|
includeCategories = true,
|
||||||
@@ -73,4 +74,22 @@ object BackupController {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Reports missing sources and trackers, expects a Tachiyomi protobuf backup in the body */
|
||||||
|
fun protobufValidate(ctx: Context) {
|
||||||
|
ctx.json(
|
||||||
|
JavalinSetup.future {
|
||||||
|
ProtoBackupValidator.validate(ctx.bodyAsInputStream())
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reports missing sources and trackers, expects a Tachiyomi protobuf backup as a file upload, the file must be named "backup.proto.gz" */
|
||||||
|
fun protobufValidateFile(ctx: Context) {
|
||||||
|
ctx.json(
|
||||||
|
JavalinSetup.future {
|
||||||
|
ProtoBackupValidator.validate(ctx.uploadedFile("backup.proto.gz")!!.content)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-7
@@ -10,14 +10,8 @@ package suwayomi.tachidesk.manga.controller
|
|||||||
import io.javalin.http.Context
|
import io.javalin.http.Context
|
||||||
import suwayomi.tachidesk.manga.impl.Category
|
import suwayomi.tachidesk.manga.impl.Category
|
||||||
import suwayomi.tachidesk.manga.impl.CategoryManga
|
import suwayomi.tachidesk.manga.impl.CategoryManga
|
||||||
import suwayomi.tachidesk.manga.impl.Library
|
|
||||||
|
|
||||||
object LibraryController {
|
|
||||||
/** lists mangas that have no category assigned */
|
|
||||||
fun list(ctx: Context) {
|
|
||||||
ctx.json(Library.getLibraryMangas())
|
|
||||||
}
|
|
||||||
|
|
||||||
|
object CategoryController {
|
||||||
/** category list */
|
/** category list */
|
||||||
fun categoryList(ctx: Context) {
|
fun categoryList(ctx: Context) {
|
||||||
ctx.json(Category.getCategoryList())
|
ctx.json(Category.getCategoryList())
|
||||||
@@ -12,7 +12,6 @@ import suwayomi.tachidesk.manga.impl.MangaList
|
|||||||
import suwayomi.tachidesk.manga.impl.Search
|
import suwayomi.tachidesk.manga.impl.Search
|
||||||
import suwayomi.tachidesk.manga.impl.Source
|
import suwayomi.tachidesk.manga.impl.Source
|
||||||
import suwayomi.tachidesk.manga.impl.Source.SourcePreferenceChange
|
import suwayomi.tachidesk.manga.impl.Source.SourcePreferenceChange
|
||||||
import suwayomi.tachidesk.server.JavalinSetup
|
|
||||||
import suwayomi.tachidesk.server.JavalinSetup.future
|
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||||
|
|
||||||
object SourceController {
|
object SourceController {
|
||||||
@@ -63,9 +62,11 @@ object SourceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** fetch filters of source with id `sourceId` */
|
/** fetch filters of source with id `sourceId` */
|
||||||
fun filters(ctx: Context) { // TODO
|
fun filters(ctx: Context) {
|
||||||
val sourceId = ctx.pathParam("sourceId").toLong()
|
val sourceId = ctx.pathParam("sourceId").toLong()
|
||||||
ctx.json(Search.sourceFilters(sourceId))
|
val reset = ctx.queryParam("reset", "false").toBoolean()
|
||||||
|
|
||||||
|
ctx.json(Search.getInitialFilterList(sourceId, reset))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** single source search */
|
/** single source search */
|
||||||
@@ -73,7 +74,7 @@ object SourceController {
|
|||||||
val sourceId = ctx.pathParam("sourceId").toLong()
|
val sourceId = ctx.pathParam("sourceId").toLong()
|
||||||
val searchTerm = ctx.pathParam("searchTerm")
|
val searchTerm = ctx.pathParam("searchTerm")
|
||||||
val pageNum = ctx.pathParam("pageNum").toInt()
|
val pageNum = ctx.pathParam("pageNum").toInt()
|
||||||
ctx.json(JavalinSetup.future { Search.sourceSearch(sourceId, searchTerm, pageNum) })
|
ctx.json(future { Search.sourceSearch(sourceId, searchTerm, pageNum) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/** all source search */
|
/** all source search */
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package suwayomi.tachidesk.manga.impl
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
import org.jetbrains.exposed.sql.SortOrder
|
import org.jetbrains.exposed.sql.SortOrder
|
||||||
|
import org.jetbrains.exposed.sql.and
|
||||||
import org.jetbrains.exposed.sql.deleteWhere
|
import org.jetbrains.exposed.sql.deleteWhere
|
||||||
import org.jetbrains.exposed.sql.insert
|
import org.jetbrains.exposed.sql.insert
|
||||||
import org.jetbrains.exposed.sql.select
|
import org.jetbrains.exposed.sql.select
|
||||||
@@ -15,9 +16,11 @@ import org.jetbrains.exposed.sql.selectAll
|
|||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
import org.jetbrains.exposed.sql.update
|
import org.jetbrains.exposed.sql.update
|
||||||
import suwayomi.tachidesk.manga.impl.CategoryManga.removeMangaFromCategory
|
import suwayomi.tachidesk.manga.impl.CategoryManga.removeMangaFromCategory
|
||||||
|
import suwayomi.tachidesk.manga.impl.util.lang.isNotEmpty
|
||||||
import suwayomi.tachidesk.manga.model.dataclass.CategoryDataClass
|
import suwayomi.tachidesk.manga.model.dataclass.CategoryDataClass
|
||||||
import suwayomi.tachidesk.manga.model.table.CategoryMangaTable
|
import suwayomi.tachidesk.manga.model.table.CategoryMangaTable
|
||||||
import suwayomi.tachidesk.manga.model.table.CategoryTable
|
import suwayomi.tachidesk.manga.model.table.CategoryTable
|
||||||
|
import suwayomi.tachidesk.manga.model.table.MangaTable
|
||||||
import suwayomi.tachidesk.manga.model.table.toDataClass
|
import suwayomi.tachidesk.manga.model.table.toDataClass
|
||||||
|
|
||||||
object Category {
|
object Category {
|
||||||
@@ -25,27 +28,31 @@ object Category {
|
|||||||
* The new category will be placed at the end of the list
|
* The new category will be placed at the end of the list
|
||||||
*/
|
*/
|
||||||
fun createCategory(name: String) {
|
fun createCategory(name: String) {
|
||||||
|
// creating a category named Default is illegal
|
||||||
|
if (name.equals(DEFAULT_CATEGORY_NAME, ignoreCase = true)) return
|
||||||
|
|
||||||
transaction {
|
transaction {
|
||||||
val count = CategoryTable.selectAll().count()
|
if (CategoryTable.select { CategoryTable.name eq name }.firstOrNull() == null) {
|
||||||
if (CategoryTable.select { CategoryTable.name eq name }.firstOrNull() == null)
|
|
||||||
CategoryTable.insert {
|
CategoryTable.insert {
|
||||||
it[CategoryTable.name] = name
|
it[CategoryTable.name] = name
|
||||||
it[CategoryTable.order] = count.toInt() + 1
|
it[CategoryTable.order] = Int.MAX_VALUE
|
||||||
}
|
}
|
||||||
|
normalizeCategories()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateCategory(categoryId: Int, name: String?, isDefault: Boolean?) {
|
fun updateCategory(categoryId: Int, name: String?, isDefault: Boolean?) {
|
||||||
transaction {
|
transaction {
|
||||||
CategoryTable.update({ CategoryTable.id eq categoryId }) {
|
CategoryTable.update({ CategoryTable.id eq categoryId }) {
|
||||||
if (name != null) it[CategoryTable.name] = name
|
if (name != null && !name.equals(DEFAULT_CATEGORY_NAME, ignoreCase = true)) it[CategoryTable.name] = name
|
||||||
if (isDefault != null) it[CategoryTable.isDefault] = isDefault
|
if (isDefault != null) it[CategoryTable.isDefault] = isDefault
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move the category from position `from` to `to`
|
* Move the category from order number `from` to `to`
|
||||||
*/
|
*/
|
||||||
fun reorderCategory(from: Int, to: Int) {
|
fun reorderCategory(from: Int, to: Int) {
|
||||||
transaction {
|
transaction {
|
||||||
@@ -65,14 +72,38 @@ object Category {
|
|||||||
removeMangaFromCategory(it[CategoryMangaTable.manga].value, categoryId)
|
removeMangaFromCategory(it[CategoryMangaTable.manga].value, categoryId)
|
||||||
}
|
}
|
||||||
CategoryTable.deleteWhere { CategoryTable.id eq categoryId }
|
CategoryTable.deleteWhere { CategoryTable.id eq categoryId }
|
||||||
|
normalizeCategories()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getCategoryList(): List<CategoryDataClass> {
|
/** make sure category order numbers starts from 1 and is consecutive */
|
||||||
return transaction {
|
private fun normalizeCategories() {
|
||||||
CategoryTable.selectAll().orderBy(CategoryTable.order to SortOrder.ASC).map {
|
transaction {
|
||||||
CategoryTable.toDataClass(it)
|
val categories = CategoryTable.selectAll().orderBy(CategoryTable.order to SortOrder.ASC)
|
||||||
|
categories.forEachIndexed { index, cat ->
|
||||||
|
CategoryTable.update({ CategoryTable.id eq cat[CategoryTable.id].value }) {
|
||||||
|
it[CategoryTable.order] = index + 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const val DEFAULT_CATEGORY_ID = 0
|
||||||
|
const val DEFAULT_CATEGORY_NAME = "Default"
|
||||||
|
private fun addDefaultIfNecessary(categories: List<CategoryDataClass>): List<CategoryDataClass> =
|
||||||
|
if (MangaTable.select { (MangaTable.inLibrary eq true) and (MangaTable.defaultCategory eq true) }.isNotEmpty()) {
|
||||||
|
listOf(CategoryDataClass(DEFAULT_CATEGORY_ID, 0, DEFAULT_CATEGORY_NAME, true)) + categories
|
||||||
|
} else {
|
||||||
|
categories
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getCategoryList(): List<CategoryDataClass> {
|
||||||
|
return transaction {
|
||||||
|
val categories = CategoryTable.selectAll().orderBy(CategoryTable.order to SortOrder.ASC).map {
|
||||||
|
CategoryTable.toDataClass(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
addDefaultIfNecessary(categories)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import org.jetbrains.exposed.sql.insert
|
|||||||
import org.jetbrains.exposed.sql.select
|
import org.jetbrains.exposed.sql.select
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
import org.jetbrains.exposed.sql.update
|
import org.jetbrains.exposed.sql.update
|
||||||
|
import suwayomi.tachidesk.manga.impl.Category.DEFAULT_CATEGORY_ID
|
||||||
|
import suwayomi.tachidesk.manga.impl.util.lang.isEmpty
|
||||||
import suwayomi.tachidesk.manga.model.dataclass.CategoryDataClass
|
import suwayomi.tachidesk.manga.model.dataclass.CategoryDataClass
|
||||||
import suwayomi.tachidesk.manga.model.dataclass.MangaDataClass
|
import suwayomi.tachidesk.manga.model.dataclass.MangaDataClass
|
||||||
import suwayomi.tachidesk.manga.model.table.CategoryMangaTable
|
import suwayomi.tachidesk.manga.model.table.CategoryMangaTable
|
||||||
@@ -23,8 +25,10 @@ import suwayomi.tachidesk.manga.model.table.toDataClass
|
|||||||
|
|
||||||
object CategoryManga {
|
object CategoryManga {
|
||||||
fun addMangaToCategory(mangaId: Int, categoryId: Int) {
|
fun addMangaToCategory(mangaId: Int, categoryId: Int) {
|
||||||
|
fun notAlreadyInCategory() = CategoryMangaTable.select { (CategoryMangaTable.category eq categoryId) and (CategoryMangaTable.manga eq mangaId) }.isEmpty()
|
||||||
|
|
||||||
transaction {
|
transaction {
|
||||||
if (CategoryMangaTable.select { (CategoryMangaTable.category eq categoryId) and (CategoryMangaTable.manga eq mangaId) }.firstOrNull() == null) {
|
if (notAlreadyInCategory()) {
|
||||||
CategoryMangaTable.insert {
|
CategoryMangaTable.insert {
|
||||||
it[CategoryMangaTable.category] = categoryId
|
it[CategoryMangaTable.category] = categoryId
|
||||||
it[CategoryMangaTable.manga] = mangaId
|
it[CategoryMangaTable.manga] = mangaId
|
||||||
@@ -52,6 +56,13 @@ object CategoryManga {
|
|||||||
* list of mangas that belong to a category
|
* list of mangas that belong to a category
|
||||||
*/
|
*/
|
||||||
fun getCategoryMangaList(categoryId: Int): List<MangaDataClass> {
|
fun getCategoryMangaList(categoryId: Int): List<MangaDataClass> {
|
||||||
|
if (categoryId == DEFAULT_CATEGORY_ID)
|
||||||
|
return transaction {
|
||||||
|
MangaTable.select { (MangaTable.inLibrary eq true) and (MangaTable.defaultCategory eq true) }.map {
|
||||||
|
MangaTable.toDataClass(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return transaction {
|
return transaction {
|
||||||
CategoryMangaTable.innerJoin(MangaTable).select { CategoryMangaTable.category eq categoryId }.map {
|
CategoryMangaTable.innerJoin(MangaTable).select { CategoryMangaTable.category eq categoryId }.map {
|
||||||
MangaTable.toDataClass(it)
|
MangaTable.toDataClass(it)
|
||||||
|
|||||||
@@ -46,12 +46,12 @@ object Chapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun getSourceChapters(mangaId: Int): List<ChapterDataClass> {
|
private suspend fun getSourceChapters(mangaId: Int): List<ChapterDataClass> {
|
||||||
val mangaDetails = getManga(mangaId)
|
val manga = getManga(mangaId)
|
||||||
val source = getHttpSource(mangaDetails.sourceId.toLong())
|
val source = getHttpSource(manga.sourceId.toLong())
|
||||||
val chapterList = source.fetchChapterList(
|
val chapterList = source.fetchChapterList(
|
||||||
SManga.create().apply {
|
SManga.create().apply {
|
||||||
title = mangaDetails.title
|
title = manga.title
|
||||||
url = mangaDetails.url
|
url = manga.url
|
||||||
}
|
}
|
||||||
).awaitSingle()
|
).awaitSingle()
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ object Chapter {
|
|||||||
it[scanlator] = fetchedChapter.scanlator
|
it[scanlator] = fetchedChapter.scanlator
|
||||||
|
|
||||||
it[chapterIndex] = index + 1
|
it[chapterIndex] = index + 1
|
||||||
it[manga] = mangaId
|
it[ChapterTable.manga] = mangaId
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ChapterTable.update({ ChapterTable.url eq fetchedChapter.url }) {
|
ChapterTable.update({ ChapterTable.url eq fetchedChapter.url }) {
|
||||||
@@ -79,7 +79,7 @@ object Chapter {
|
|||||||
it[scanlator] = fetchedChapter.scanlator
|
it[scanlator] = fetchedChapter.scanlator
|
||||||
|
|
||||||
it[chapterIndex] = index + 1
|
it[chapterIndex] = index + 1
|
||||||
it[manga] = mangaId
|
it[ChapterTable.manga] = mangaId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,23 +7,17 @@ package suwayomi.tachidesk.manga.impl
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
import org.jetbrains.exposed.sql.and
|
|
||||||
import org.jetbrains.exposed.sql.deleteWhere
|
import org.jetbrains.exposed.sql.deleteWhere
|
||||||
import org.jetbrains.exposed.sql.insert
|
import org.jetbrains.exposed.sql.insert
|
||||||
import org.jetbrains.exposed.sql.select
|
import org.jetbrains.exposed.sql.select
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
import org.jetbrains.exposed.sql.update
|
import org.jetbrains.exposed.sql.update
|
||||||
import suwayomi.tachidesk.manga.impl.Manga.getManga
|
import suwayomi.tachidesk.manga.impl.Manga.getManga
|
||||||
import suwayomi.tachidesk.manga.model.dataclass.MangaDataClass
|
|
||||||
import suwayomi.tachidesk.manga.model.table.CategoryMangaTable
|
import suwayomi.tachidesk.manga.model.table.CategoryMangaTable
|
||||||
import suwayomi.tachidesk.manga.model.table.CategoryTable
|
import suwayomi.tachidesk.manga.model.table.CategoryTable
|
||||||
import suwayomi.tachidesk.manga.model.table.MangaTable
|
import suwayomi.tachidesk.manga.model.table.MangaTable
|
||||||
import suwayomi.tachidesk.manga.model.table.toDataClass
|
|
||||||
|
|
||||||
object Library {
|
object Library {
|
||||||
// TODO: `Category.isLanding` is to handle the default categories a new library manga gets,
|
|
||||||
// ..implement that shit at some time...
|
|
||||||
// ..also Consider to rename it to `isDefault`
|
|
||||||
suspend fun addMangaToLibrary(mangaId: Int) {
|
suspend fun addMangaToLibrary(mangaId: Int) {
|
||||||
val manga = getManga(mangaId)
|
val manga = getManga(mangaId)
|
||||||
if (!manga.inLibrary) {
|
if (!manga.inLibrary) {
|
||||||
@@ -57,12 +51,4 @@ object Library {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getLibraryMangas(): List<MangaDataClass> {
|
|
||||||
return transaction {
|
|
||||||
MangaTable.select { (MangaTable.inLibrary eq true) and (MangaTable.defaultCategory eq true) }.map {
|
|
||||||
MangaTable.toDataClass(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ package suwayomi.tachidesk.manga.impl
|
|||||||
|
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import org.jetbrains.exposed.dao.id.EntityID
|
|
||||||
import org.jetbrains.exposed.sql.and
|
import org.jetbrains.exposed.sql.and
|
||||||
import org.jetbrains.exposed.sql.insert
|
import org.jetbrains.exposed.sql.insert
|
||||||
import org.jetbrains.exposed.sql.select
|
import org.jetbrains.exposed.sql.select
|
||||||
@@ -61,17 +60,17 @@ object Manga {
|
|||||||
MangaStatus.valueOf(mangaEntry[MangaTable.status]).name,
|
MangaStatus.valueOf(mangaEntry[MangaTable.status]).name,
|
||||||
mangaEntry[MangaTable.inLibrary],
|
mangaEntry[MangaTable.inLibrary],
|
||||||
getSource(mangaEntry[MangaTable.sourceReference]),
|
getSource(mangaEntry[MangaTable.sourceReference]),
|
||||||
getMangaMetaMap(mangaEntry[MangaTable.id]),
|
getMangaMetaMap(mangaId),
|
||||||
|
mangaEntry[MangaTable.realUrl],
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
} else { // initialize manga
|
} else { // initialize manga
|
||||||
val source = getHttpSource(mangaEntry[MangaTable.sourceReference])
|
val source = getHttpSource(mangaEntry[MangaTable.sourceReference])
|
||||||
val fetchedManga = source.fetchMangaDetails(
|
val sManga = SManga.create().apply {
|
||||||
SManga.create().apply {
|
url = mangaEntry[MangaTable.url]
|
||||||
url = mangaEntry[MangaTable.url]
|
title = mangaEntry[MangaTable.title]
|
||||||
title = mangaEntry[MangaTable.title]
|
}
|
||||||
}
|
val fetchedManga = source.fetchMangaDetails(sManga).awaitSingle()
|
||||||
).awaitSingle()
|
|
||||||
|
|
||||||
transaction {
|
transaction {
|
||||||
MangaTable.update({ MangaTable.id eq mangaId }) {
|
MangaTable.update({ MangaTable.id eq mangaId }) {
|
||||||
@@ -85,6 +84,8 @@ object Manga {
|
|||||||
it[MangaTable.status] = fetchedManga.status
|
it[MangaTable.status] = fetchedManga.status
|
||||||
if (fetchedManga.thumbnail_url != null && fetchedManga.thumbnail_url.orEmpty().isNotEmpty())
|
if (fetchedManga.thumbnail_url != null && fetchedManga.thumbnail_url.orEmpty().isNotEmpty())
|
||||||
it[MangaTable.thumbnail_url] = fetchedManga.thumbnail_url
|
it[MangaTable.thumbnail_url] = fetchedManga.thumbnail_url
|
||||||
|
|
||||||
|
it[MangaTable.realUrl] = try { source.mangaDetailsRequest(sManga).url.toString() } catch (e: Exception) { null }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,13 +110,14 @@ object Manga {
|
|||||||
MangaStatus.valueOf(fetchedManga.status).name,
|
MangaStatus.valueOf(fetchedManga.status).name,
|
||||||
mangaEntry[MangaTable.inLibrary],
|
mangaEntry[MangaTable.inLibrary],
|
||||||
getSource(mangaEntry[MangaTable.sourceReference]),
|
getSource(mangaEntry[MangaTable.sourceReference]),
|
||||||
getMangaMetaMap(mangaEntry[MangaTable.id]),
|
getMangaMetaMap(mangaId),
|
||||||
|
mangaEntry[MangaTable.realUrl],
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getMangaMetaMap(manga: EntityID<Int>): Map<String, String> {
|
fun getMangaMetaMap(manga: Int): Map<String, String> {
|
||||||
return transaction {
|
return transaction {
|
||||||
MangaMetaTable.select { MangaMetaTable.ref eq manga }
|
MangaMetaTable.select { MangaMetaTable.ref eq manga }
|
||||||
.associate { it[MangaMetaTable.key] to it[MangaMetaTable.value] }
|
.associate { it[MangaMetaTable.key] to it[MangaMetaTable.value] }
|
||||||
@@ -126,7 +128,8 @@ object Manga {
|
|||||||
transaction {
|
transaction {
|
||||||
val manga = MangaMetaTable.select { (MangaTable.id eq mangaId) }
|
val manga = MangaMetaTable.select { (MangaTable.id eq mangaId) }
|
||||||
.first()[MangaTable.id]
|
.first()[MangaTable.id]
|
||||||
val meta = transaction { MangaMetaTable.select { (MangaMetaTable.ref eq manga) and (MangaMetaTable.key eq key) } }.firstOrNull()
|
val meta =
|
||||||
|
transaction { MangaMetaTable.select { (MangaMetaTable.ref eq manga) and (MangaMetaTable.key eq key) } }.firstOrNull()
|
||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
MangaMetaTable.insert {
|
MangaMetaTable.insert {
|
||||||
it[MangaMetaTable.key] = key
|
it[MangaMetaTable.key] = key
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ object MangaList {
|
|||||||
val mangasPage = this
|
val mangasPage = this
|
||||||
val mangaList = transaction {
|
val mangaList = transaction {
|
||||||
return@transaction mangasPage.mangas.map { manga ->
|
return@transaction mangasPage.mangas.map { manga ->
|
||||||
val mangaEntry = MangaTable.select { MangaTable.url eq manga.url }.firstOrNull()
|
var mangaEntry = MangaTable.select { MangaTable.url eq manga.url }.firstOrNull()
|
||||||
if (mangaEntry == null) { // create manga entry
|
if (mangaEntry == null) { // create manga entry
|
||||||
val mangaId = MangaTable.insertAndGetId {
|
val mangaId = MangaTable.insertAndGetId {
|
||||||
it[url] = manga.url
|
it[url] = manga.url
|
||||||
@@ -57,6 +57,8 @@ object MangaList {
|
|||||||
it[sourceReference] = sourceId
|
it[sourceReference] = sourceId
|
||||||
}.value
|
}.value
|
||||||
|
|
||||||
|
mangaEntry = MangaTable.select { MangaTable.url eq manga.url }.first()
|
||||||
|
|
||||||
MangaDataClass(
|
MangaDataClass(
|
||||||
mangaId,
|
mangaId,
|
||||||
sourceId.toString(),
|
sourceId.toString(),
|
||||||
@@ -71,7 +73,11 @@ object MangaList {
|
|||||||
manga.author,
|
manga.author,
|
||||||
manga.description,
|
manga.description,
|
||||||
manga.genre,
|
manga.genre,
|
||||||
MangaStatus.valueOf(manga.status).name
|
MangaStatus.valueOf(manga.status).name,
|
||||||
|
false, // It's a new manga entry
|
||||||
|
meta = getMangaMetaMap(mangaId),
|
||||||
|
realUrl = mangaEntry[MangaTable.realUrl],
|
||||||
|
freshData = true
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
val mangaId = mangaEntry[MangaTable.id].value
|
val mangaId = mangaEntry[MangaTable.id].value
|
||||||
@@ -91,7 +97,9 @@ object MangaList {
|
|||||||
mangaEntry[MangaTable.genre],
|
mangaEntry[MangaTable.genre],
|
||||||
MangaStatus.valueOf(mangaEntry[MangaTable.status]).name,
|
MangaStatus.valueOf(mangaEntry[MangaTable.status]).name,
|
||||||
mangaEntry[MangaTable.inLibrary],
|
mangaEntry[MangaTable.inLibrary],
|
||||||
meta = getMangaMetaMap(mangaEntry[MangaTable.id])
|
meta = getMangaMetaMap(mangaId),
|
||||||
|
realUrl = mangaEntry[MangaTable.realUrl],
|
||||||
|
freshData = false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ package suwayomi.tachidesk.manga.impl
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import eu.kanade.tachiyomi.source.model.Filter
|
||||||
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
import suwayomi.tachidesk.manga.impl.MangaList.processEntries
|
import suwayomi.tachidesk.manga.impl.MangaList.processEntries
|
||||||
import suwayomi.tachidesk.manga.impl.util.GetHttpSource.getHttpSource
|
import suwayomi.tachidesk.manga.impl.util.GetHttpSource.getHttpSource
|
||||||
import suwayomi.tachidesk.manga.impl.util.lang.awaitSingle
|
import suwayomi.tachidesk.manga.impl.util.lang.awaitSingle
|
||||||
@@ -15,28 +17,53 @@ import suwayomi.tachidesk.manga.model.dataclass.PagedMangaListDataClass
|
|||||||
object Search {
|
object Search {
|
||||||
suspend fun sourceSearch(sourceId: Long, searchTerm: String, pageNum: Int): PagedMangaListDataClass {
|
suspend fun sourceSearch(sourceId: Long, searchTerm: String, pageNum: Int): PagedMangaListDataClass {
|
||||||
val source = getHttpSource(sourceId)
|
val source = getHttpSource(sourceId)
|
||||||
val searchManga = source.fetchSearchManga(pageNum, searchTerm, source.getFilterList()).awaitSingle()
|
val searchManga = source.fetchSearchManga(pageNum, searchTerm, getFilterListOf(sourceId)).awaitSingle()
|
||||||
return searchManga.processEntries(sourceId)
|
return searchManga.processEntries(sourceId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
private val filterListCache = mutableMapOf<Long, FilterList>()
|
||||||
@Suppress("UNUSED_PARAMETER", "UNUSED_VARIABLE")
|
|
||||||
fun sourceFilters(sourceId: Long) {
|
private fun getFilterListOf(sourceId: Long, reset: Boolean = false): FilterList {
|
||||||
val source = getHttpSource(sourceId)
|
if (reset || !filterListCache.containsKey(sourceId)) {
|
||||||
// source.getFilterList().toItems()
|
filterListCache[sourceId] = getHttpSource(sourceId).getFilterList()
|
||||||
|
}
|
||||||
|
return filterListCache[sourceId]!!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getInitialFilterList(sourceId: Long, reset: Boolean): List<FilterObject> {
|
||||||
|
return getFilterListOf(sourceId, reset).list.map {
|
||||||
|
FilterObject(
|
||||||
|
when (it) {
|
||||||
|
is Filter.Header -> "Header"
|
||||||
|
is Filter.Separator -> "Separator"
|
||||||
|
is Filter.CheckBox -> "CheckBox"
|
||||||
|
is Filter.TriState -> "TriState"
|
||||||
|
is Filter.Text -> "Text"
|
||||||
|
is Filter.Select<*> -> "Select"
|
||||||
|
is Filter.Group<*> -> "Group"
|
||||||
|
is Filter.Sort -> "Sort"
|
||||||
|
},
|
||||||
|
// when (it) {
|
||||||
|
// is Filter.Select<*> -> it.getValuesType()
|
||||||
|
// else -> null
|
||||||
|
// },
|
||||||
|
it
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// private fun Filter.Select<*>.getValuesType(): String = values::class.java.componentType!!.simpleName
|
||||||
|
|
||||||
|
data class FilterObject(
|
||||||
|
val type: String,
|
||||||
|
val filter: Filter<*>
|
||||||
|
)
|
||||||
|
|
||||||
@Suppress("UNUSED_PARAMETER")
|
@Suppress("UNUSED_PARAMETER")
|
||||||
fun sourceGlobalSearch(searchTerm: String) {
|
fun sourceGlobalSearch(searchTerm: String) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("unused")
|
|
||||||
data class FilterWrapper(
|
|
||||||
val type: String,
|
|
||||||
val filter: Any
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: Exhentai had a filter serializer (now in SY) that we might be able to steal
|
* Note: Exhentai had a filter serializer (now in SY) that we might be able to steal
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -35,29 +35,42 @@ object Source {
|
|||||||
fun getSourceList(): List<SourceDataClass> {
|
fun getSourceList(): List<SourceDataClass> {
|
||||||
return transaction {
|
return transaction {
|
||||||
SourceTable.selectAll().map {
|
SourceTable.selectAll().map {
|
||||||
|
val httpSource = getHttpSource(it[SourceTable.id].value)
|
||||||
|
val sourceExtension = ExtensionTable.select { ExtensionTable.id eq it[SourceTable.extension] }.first()
|
||||||
|
|
||||||
SourceDataClass(
|
SourceDataClass(
|
||||||
it[SourceTable.id].value.toString(),
|
it[SourceTable.id].value.toString(),
|
||||||
it[SourceTable.name],
|
it[SourceTable.name],
|
||||||
it[SourceTable.lang],
|
it[SourceTable.lang],
|
||||||
getExtensionIconUrl(ExtensionTable.select { ExtensionTable.id eq it[SourceTable.extension] }.first()[ExtensionTable.apkName]),
|
getExtensionIconUrl(sourceExtension[ExtensionTable.apkName]),
|
||||||
getHttpSource(it[SourceTable.id].value).supportsLatest,
|
httpSource.supportsLatest,
|
||||||
getHttpSource(it[SourceTable.id].value) is ConfigurableSource
|
httpSource is ConfigurableSource,
|
||||||
|
it[SourceTable.isNsfw]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getSource(sourceId: Long): SourceDataClass {
|
fun getSource(sourceId: Long): SourceDataClass { // all the data extracted fresh form the source instance
|
||||||
return transaction {
|
return transaction {
|
||||||
val source = SourceTable.select { SourceTable.id eq sourceId }.firstOrNull()
|
val source = SourceTable.select { SourceTable.id eq sourceId }.firstOrNull()
|
||||||
|
val httpSource = source?.let { getHttpSource(sourceId) }
|
||||||
|
val extension = source?.let {
|
||||||
|
ExtensionTable.select { ExtensionTable.id eq source[SourceTable.extension] }.first()
|
||||||
|
}
|
||||||
|
|
||||||
SourceDataClass(
|
SourceDataClass(
|
||||||
sourceId.toString(),
|
sourceId.toString(),
|
||||||
source?.get(SourceTable.name),
|
source?.get(SourceTable.name),
|
||||||
source?.get(SourceTable.lang),
|
source?.get(SourceTable.lang),
|
||||||
source?.let { getExtensionIconUrl(ExtensionTable.select { ExtensionTable.id eq source[SourceTable.extension] }.first()[ExtensionTable.apkName]) },
|
source?.let {
|
||||||
source?.let { getHttpSource(sourceId).supportsLatest },
|
getExtensionIconUrl(
|
||||||
source?.let { getHttpSource(sourceId) is ConfigurableSource },
|
extension!![ExtensionTable.apkName]
|
||||||
|
)
|
||||||
|
},
|
||||||
|
httpSource?.supportsLatest,
|
||||||
|
httpSource?.let { it is ConfigurableSource },
|
||||||
|
source?.get(SourceTable.isNsfw)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,7 +78,7 @@ object Source {
|
|||||||
private val context by DI.global.instance<CustomContext>()
|
private val context by DI.global.instance<CustomContext>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clients should support these types for extensions to work properly (in order of importance)
|
* (2021-08) Clients should support these types for extensions to work properly
|
||||||
* - EditTextPreference
|
* - EditTextPreference
|
||||||
* - SwitchPreferenceCompat
|
* - SwitchPreferenceCompat
|
||||||
* - ListPreference
|
* - ListPreference
|
||||||
@@ -85,7 +98,8 @@ object Source {
|
|||||||
val source = getHttpSource(sourceId)
|
val source = getHttpSource(sourceId)
|
||||||
|
|
||||||
if (source is ConfigurableSource) {
|
if (source is ConfigurableSource) {
|
||||||
val sourceShardPreferences = Injekt.get<Application>().getSharedPreferences(source.getPreferenceKey(), Context.MODE_PRIVATE)
|
val sourceShardPreferences =
|
||||||
|
Injekt.get<Application>().getSharedPreferences(source.getPreferenceKey(), Context.MODE_PRIVATE)
|
||||||
|
|
||||||
val screen = PreferenceScreen(context)
|
val screen = PreferenceScreen(context)
|
||||||
screen.sharedPreferences = sourceShardPreferences
|
screen.sharedPreferences = sourceShardPreferences
|
||||||
|
|||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
package suwayomi.tachidesk.manga.impl.backup
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
abstract class AbstractBackupValidator {
|
||||||
|
data class ValidationResult(val missingSources: List<String>, val missingTrackers: List<String>)
|
||||||
|
}
|
||||||
-45
@@ -1,45 +0,0 @@
|
|||||||
package suwayomi.tachidesk.manga.impl.backup.legacy
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) Contributors to the Suwayomi project
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
import com.github.salomonbrys.kotson.registerTypeAdapter
|
|
||||||
import com.github.salomonbrys.kotson.registerTypeHierarchyAdapter
|
|
||||||
import com.google.gson.Gson
|
|
||||||
import com.google.gson.GsonBuilder
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.legacy.models.DHistory
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.legacy.serializer.CategoryTypeAdapter
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.legacy.serializer.ChapterTypeAdapter
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.legacy.serializer.HistoryTypeAdapter
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.legacy.serializer.MangaTypeAdapter
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.legacy.serializer.TrackTypeAdapter
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.CategoryImpl
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.ChapterImpl
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.MangaImpl
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.TrackImpl
|
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
open class LegacyBackupBase {
|
|
||||||
protected val parser: Gson = when (version) {
|
|
||||||
2 -> GsonBuilder()
|
|
||||||
.registerTypeAdapter<MangaImpl>(MangaTypeAdapter.build())
|
|
||||||
.registerTypeHierarchyAdapter<ChapterImpl>(ChapterTypeAdapter.build())
|
|
||||||
.registerTypeAdapter<CategoryImpl>(CategoryTypeAdapter.build())
|
|
||||||
.registerTypeAdapter<DHistory>(HistoryTypeAdapter.build())
|
|
||||||
.registerTypeHierarchyAdapter<TrackImpl>(TrackTypeAdapter.build())
|
|
||||||
.create()
|
|
||||||
else -> throw Exception("Unknown backup version")
|
|
||||||
}
|
|
||||||
|
|
||||||
protected var sourceMapping: Map<Long, String> = emptyMap()
|
|
||||||
|
|
||||||
protected val errors = mutableListOf<Pair<Date, String>>()
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
internal const val version = 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-154
@@ -1,154 +0,0 @@
|
|||||||
package suwayomi.tachidesk.manga.impl.backup.legacy
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) Contributors to the Suwayomi project
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
import com.github.salomonbrys.kotson.set
|
|
||||||
import com.google.gson.JsonArray
|
|
||||||
import com.google.gson.JsonElement
|
|
||||||
import com.google.gson.JsonObject
|
|
||||||
import eu.kanade.tachiyomi.source.LocalSource
|
|
||||||
import org.jetbrains.exposed.sql.select
|
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
|
||||||
import suwayomi.tachidesk.manga.impl.Category.getCategoryList
|
|
||||||
import suwayomi.tachidesk.manga.impl.CategoryManga.getMangaCategories
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.BackupFlags
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.legacy.models.Backup
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.legacy.models.Backup.CURRENT_VERSION
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.CategoryImpl
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.ChapterImpl
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.Manga
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.MangaImpl
|
|
||||||
import suwayomi.tachidesk.manga.impl.util.GetHttpSource.getHttpSource
|
|
||||||
import suwayomi.tachidesk.manga.model.table.ChapterTable
|
|
||||||
import suwayomi.tachidesk.manga.model.table.MangaTable
|
|
||||||
|
|
||||||
object LegacyBackupExport : LegacyBackupBase() {
|
|
||||||
|
|
||||||
suspend fun createLegacyBackup(flags: BackupFlags): String? {
|
|
||||||
// Create root object
|
|
||||||
val root = JsonObject()
|
|
||||||
|
|
||||||
// Create manga array
|
|
||||||
val mangaEntries = JsonArray()
|
|
||||||
|
|
||||||
// Create category array
|
|
||||||
val categoryEntries = JsonArray()
|
|
||||||
|
|
||||||
// Create extension ID/name mapping
|
|
||||||
val extensionEntries = JsonArray()
|
|
||||||
|
|
||||||
// Add values to root
|
|
||||||
root[Backup.VERSION] = CURRENT_VERSION
|
|
||||||
root[Backup.MANGAS] = mangaEntries
|
|
||||||
root[Backup.CATEGORIES] = categoryEntries
|
|
||||||
root[Backup.EXTENSIONS] = extensionEntries
|
|
||||||
|
|
||||||
transaction {
|
|
||||||
val mangas = MangaTable.select { (MangaTable.inLibrary eq true) }
|
|
||||||
|
|
||||||
val extensions: MutableSet<String> = mutableSetOf()
|
|
||||||
|
|
||||||
// Backup library manga and its dependencies
|
|
||||||
mangas.map {
|
|
||||||
MangaImpl.fromQuery(it)
|
|
||||||
}.forEach { manga ->
|
|
||||||
|
|
||||||
mangaEntries.add(backupMangaObject(manga, flags))
|
|
||||||
|
|
||||||
// Maintain set of extensions/sources used (excludes local source)
|
|
||||||
if (manga.source != LocalSource.ID) {
|
|
||||||
getHttpSource(manga.source).let {
|
|
||||||
extensions.add("${it.id}:${it.name}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Backup categories
|
|
||||||
if (flags.includeCategories) {
|
|
||||||
backupCategories(categoryEntries)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Backup extension ID/name mapping
|
|
||||||
backupExtensionInfo(extensionEntries, extensions)
|
|
||||||
}
|
|
||||||
|
|
||||||
return parser.toJson(root)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun backupMangaObject(manga: Manga, options: BackupFlags): JsonElement {
|
|
||||||
// Entry for this manga
|
|
||||||
val entry = JsonObject()
|
|
||||||
|
|
||||||
// Backup manga fields
|
|
||||||
entry[Backup.MANGA] = parser.toJsonTree(manga)
|
|
||||||
val mangaId = manga.id!!.toInt()
|
|
||||||
|
|
||||||
// Check if user wants chapter information in backup
|
|
||||||
if (options.includeChapters) {
|
|
||||||
// Backup all the chapters
|
|
||||||
val chapters = ChapterTable.select { ChapterTable.manga eq mangaId }.map { ChapterImpl.fromQuery(it) }
|
|
||||||
if (chapters.count() > 0) {
|
|
||||||
val chaptersJson = parser.toJsonTree(chapters)
|
|
||||||
if (chaptersJson.asJsonArray.size() > 0) {
|
|
||||||
entry[Backup.CHAPTERS] = chaptersJson
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if user wants category information in backup
|
|
||||||
if (options.includeCategories) {
|
|
||||||
// Backup categories for this manga
|
|
||||||
val categoriesForManga = getMangaCategories(mangaId)
|
|
||||||
if (categoriesForManga.isNotEmpty()) {
|
|
||||||
val categoriesNames = categoriesForManga.map { it.name }
|
|
||||||
entry[Backup.CATEGORIES] = parser.toJsonTree(categoriesNames)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if user wants track information in backup
|
|
||||||
if (options.includeTracking) { // TODO
|
|
||||||
// val tracks = databaseHelper.getTracks(manga).executeAsBlocking()
|
|
||||||
// if (tracks.isNotEmpty()) {
|
|
||||||
// entry[TRACK] = parser.toJsonTree(tracks)
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// // Check if user wants history information in backup
|
|
||||||
if (options.includeHistory) { // TODO
|
|
||||||
// val historyForManga = databaseHelper.getHistoryByMangaId(manga.id!!).executeAsBlocking()
|
|
||||||
// if (historyForManga.isNotEmpty()) {
|
|
||||||
// val historyData = historyForManga.mapNotNull { history ->
|
|
||||||
// val url = databaseHelper.getChapter(history.chapter_id).executeAsBlocking()?.url
|
|
||||||
// url?.let { DHistory(url, history.last_read) }
|
|
||||||
// }
|
|
||||||
// val historyJson = parser.toJsonTree(historyData)
|
|
||||||
// if (historyJson.asJsonArray.size() > 0) {
|
|
||||||
// entry[HISTORY] = historyJson
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
return entry
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun backupCategories(root: JsonArray) {
|
|
||||||
val categories = getCategoryList().map {
|
|
||||||
CategoryImpl().apply {
|
|
||||||
name = it.name
|
|
||||||
order = it.order
|
|
||||||
}
|
|
||||||
}
|
|
||||||
categories.forEach { root.add(parser.toJsonTree(it)) }
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun backupExtensionInfo(root: JsonArray, extensions: Set<String>) {
|
|
||||||
extensions.sorted().forEach {
|
|
||||||
root.add(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-212
@@ -1,212 +0,0 @@
|
|||||||
package suwayomi.tachidesk.manga.impl.backup.legacy
|
|
||||||
|
|
||||||
import com.github.salomonbrys.kotson.fromJson
|
|
||||||
import com.google.gson.JsonArray
|
|
||||||
import com.google.gson.JsonElement
|
|
||||||
import com.google.gson.JsonObject
|
|
||||||
import com.google.gson.JsonParser
|
|
||||||
import eu.kanade.tachiyomi.source.Source
|
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
|
||||||
import mu.KotlinLogging
|
|
||||||
import org.jetbrains.exposed.sql.and
|
|
||||||
import org.jetbrains.exposed.sql.insert
|
|
||||||
import org.jetbrains.exposed.sql.select
|
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
|
||||||
import org.jetbrains.exposed.sql.update
|
|
||||||
import suwayomi.tachidesk.manga.impl.Category.createCategory
|
|
||||||
import suwayomi.tachidesk.manga.impl.Category.getCategoryList
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.legacy.LegacyBackupValidator.ValidationResult
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.legacy.LegacyBackupValidator.validate
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.legacy.models.Backup
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.legacy.models.DHistory
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.CategoryImpl
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.Chapter
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.ChapterImpl
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.Manga
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.MangaImpl
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.Track
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.TrackImpl
|
|
||||||
import suwayomi.tachidesk.manga.impl.util.GetHttpSource.getHttpSource
|
|
||||||
import suwayomi.tachidesk.manga.impl.util.lang.awaitSingle
|
|
||||||
import suwayomi.tachidesk.manga.model.table.MangaTable
|
|
||||||
import java.io.InputStream
|
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) Contributors to the Suwayomi project
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
private val logger = KotlinLogging.logger {}
|
|
||||||
|
|
||||||
object LegacyBackupImport : LegacyBackupBase() {
|
|
||||||
suspend fun restoreLegacyBackup(sourceStream: InputStream): ValidationResult {
|
|
||||||
val reader = sourceStream.bufferedReader()
|
|
||||||
val json = JsonParser.parseReader(reader).asJsonObject
|
|
||||||
|
|
||||||
val validationResult = validate(json)
|
|
||||||
|
|
||||||
val mangasJson = json.get(Backup.MANGAS).asJsonArray
|
|
||||||
|
|
||||||
// Restore categories
|
|
||||||
json.get(Backup.CATEGORIES)?.let { restoreCategories(it) }
|
|
||||||
|
|
||||||
// Store source mapping for error messages
|
|
||||||
sourceMapping = LegacyBackupValidator.getSourceMapping(json)
|
|
||||||
|
|
||||||
// Restore individual manga
|
|
||||||
mangasJson.forEach {
|
|
||||||
restoreManga(it.asJsonObject)
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info {
|
|
||||||
"""
|
|
||||||
Restore Errors:
|
|
||||||
${ errors.joinToString("\n") { "${it.first} - ${it.second}" } }
|
|
||||||
Restore Summary:
|
|
||||||
- Missing Sources:
|
|
||||||
${validationResult.missingSources.joinToString("\n")}
|
|
||||||
- Missing Trackers:
|
|
||||||
${validationResult.missingTrackers.joinToString("\n")}
|
|
||||||
""".trimIndent()
|
|
||||||
}
|
|
||||||
|
|
||||||
return validationResult
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun restoreCategories(jsonCategories: JsonElement) {
|
|
||||||
val backupCategories = parser.fromJson<List<CategoryImpl>>(jsonCategories)
|
|
||||||
val dbCategories = getCategoryList()
|
|
||||||
|
|
||||||
// Iterate over them and create missing categories
|
|
||||||
backupCategories.forEach { category ->
|
|
||||||
if (dbCategories.none { it.name == category.name }) {
|
|
||||||
createCategory(category.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private suspend fun restoreManga(mangaJson: JsonObject) {
|
|
||||||
val manga = parser.fromJson<MangaImpl>(
|
|
||||||
mangaJson.get(
|
|
||||||
Backup.MANGA
|
|
||||||
)
|
|
||||||
)
|
|
||||||
val chapters = parser.fromJson<List<ChapterImpl>>(
|
|
||||||
mangaJson.get(Backup.CHAPTERS)
|
|
||||||
?: JsonArray()
|
|
||||||
)
|
|
||||||
val categories = parser.fromJson<List<String>>(
|
|
||||||
mangaJson.get(Backup.CATEGORIES)
|
|
||||||
?: JsonArray()
|
|
||||||
)
|
|
||||||
val history = parser.fromJson<List<DHistory>>(
|
|
||||||
mangaJson.get(Backup.HISTORY)
|
|
||||||
?: JsonArray()
|
|
||||||
)
|
|
||||||
val tracks = parser.fromJson<List<TrackImpl>>(
|
|
||||||
mangaJson.get(Backup.TRACK)
|
|
||||||
?: JsonArray()
|
|
||||||
)
|
|
||||||
|
|
||||||
val source = try {
|
|
||||||
getHttpSource(manga.source)
|
|
||||||
} catch (e: NullPointerException) {
|
|
||||||
null
|
|
||||||
} catch (e: NoSuchElementException) {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
val sourceName = sourceMapping[manga.source] ?: manga.source.toString()
|
|
||||||
|
|
||||||
logger.debug("Restoring Manga: ${manga.title} from $sourceName")
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (source != null) {
|
|
||||||
restoreMangaData(manga, source, chapters, categories, history, tracks)
|
|
||||||
} else {
|
|
||||||
errors.add(Date() to "${manga.title} [$sourceName]: Source not found: $sourceName (${manga.source})")
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
errors.add(Date() to "${manga.title} [$sourceName]: ${e.message}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param manga manga data from json
|
|
||||||
* @param source source to get manga data from
|
|
||||||
* @param chapters chapters data from json
|
|
||||||
* @param categories categories data from json
|
|
||||||
* @param history history data from json
|
|
||||||
* @param tracks tracking data from json
|
|
||||||
*/
|
|
||||||
@Suppress("UNUSED_PARAMETER")
|
|
||||||
private suspend fun restoreMangaData(
|
|
||||||
manga: Manga,
|
|
||||||
source: Source,
|
|
||||||
chapters: List<Chapter>,
|
|
||||||
categories: List<String>,
|
|
||||||
history: List<DHistory>,
|
|
||||||
tracks: List<Track>
|
|
||||||
) {
|
|
||||||
val fetchedManga = fetchManga(source, manga)
|
|
||||||
|
|
||||||
updateChapters(source, fetchedManga, chapters)
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
// backupManager.restoreCategoriesForManga(manga, categories)
|
|
||||||
|
|
||||||
// backupManager.restoreHistoryForManga(history)
|
|
||||||
|
|
||||||
// backupManager.restoreTrackForManga(manga, tracks)
|
|
||||||
|
|
||||||
// updateTracking(fetchedManga, tracks)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches manga information
|
|
||||||
*
|
|
||||||
* @param source source of manga
|
|
||||||
* @param manga manga that needs updating
|
|
||||||
* @return Updated manga.
|
|
||||||
*/
|
|
||||||
private suspend fun fetchManga(source: Source, manga: Manga): SManga {
|
|
||||||
// make sure we have the manga record in library
|
|
||||||
transaction {
|
|
||||||
if (MangaTable.select { (MangaTable.url eq manga.url) and (MangaTable.sourceReference eq manga.source) }.firstOrNull() == null) {
|
|
||||||
MangaTable.insert {
|
|
||||||
it[url] = manga.url
|
|
||||||
it[title] = manga.title
|
|
||||||
|
|
||||||
it[sourceReference] = manga.source
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MangaTable.update({ (MangaTable.url eq manga.url) and (MangaTable.sourceReference eq manga.source) }) {
|
|
||||||
it[MangaTable.inLibrary] = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// update manga details
|
|
||||||
val fetchedManga = source.fetchMangaDetails(manga).awaitSingle()
|
|
||||||
transaction {
|
|
||||||
MangaTable.update({ (MangaTable.url eq manga.url) and (MangaTable.sourceReference eq manga.source) }) {
|
|
||||||
|
|
||||||
it[artist] = fetchedManga.artist
|
|
||||||
it[author] = fetchedManga.author
|
|
||||||
it[description] = fetchedManga.description
|
|
||||||
it[genre] = fetchedManga.genre
|
|
||||||
it[status] = fetchedManga.status
|
|
||||||
if (fetchedManga.thumbnail_url != null && fetchedManga.thumbnail_url.orEmpty().isNotEmpty())
|
|
||||||
it[MangaTable.thumbnail_url] = fetchedManga.thumbnail_url
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return fetchedManga
|
|
||||||
}
|
|
||||||
|
|
||||||
@Suppress("UNUSED_PARAMETER") // TODO: remove this suppress when update Chapters is written
|
|
||||||
private fun updateChapters(source: Source, fetchedManga: SManga, chapters: List<Chapter>) {
|
|
||||||
// TODO("Not yet implemented")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-71
@@ -1,71 +0,0 @@
|
|||||||
package suwayomi.tachidesk.manga.impl.backup.legacy
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) Contributors to the Suwayomi project
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject
|
|
||||||
import org.jetbrains.exposed.sql.select
|
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.legacy.models.Backup
|
|
||||||
import suwayomi.tachidesk.manga.model.table.SourceTable
|
|
||||||
|
|
||||||
object LegacyBackupValidator {
|
|
||||||
data class ValidationResult(val missingSources: List<String>, val missingTrackers: List<String>)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks for critical backup file data.
|
|
||||||
*
|
|
||||||
* @throws Exception if version or manga cannot be found.
|
|
||||||
* @return List of missing sources or missing trackers.
|
|
||||||
*/
|
|
||||||
fun validate(json: JsonObject): ValidationResult {
|
|
||||||
val version = json.get(Backup.VERSION)
|
|
||||||
val mangasJson = json.get(Backup.MANGAS)
|
|
||||||
if (version == null || mangasJson == null) {
|
|
||||||
throw Exception("File is missing data.")
|
|
||||||
}
|
|
||||||
|
|
||||||
val mangas = mangasJson.asJsonArray
|
|
||||||
if (mangas.size() == 0) {
|
|
||||||
throw Exception("Backup does not contain any manga.")
|
|
||||||
}
|
|
||||||
|
|
||||||
val sources = getSourceMapping(json)
|
|
||||||
val missingSources = transaction {
|
|
||||||
sources
|
|
||||||
.filter { SourceTable.select { SourceTable.id eq it.key }.firstOrNull() == null }
|
|
||||||
.map { "${it.value} (${it.key})" }
|
|
||||||
.sorted()
|
|
||||||
}
|
|
||||||
|
|
||||||
// val trackers = mangas
|
|
||||||
// .filter { it.asJsonObject.has("track") }
|
|
||||||
// .flatMap { it.asJsonObject["track"].asJsonArray }
|
|
||||||
// .map { it.asJsonObject["s"].asInt }
|
|
||||||
// .distinct()
|
|
||||||
|
|
||||||
val missingTrackers = listOf("")
|
|
||||||
// val missingTrackers = trackers
|
|
||||||
// .mapNotNull { trackManager.getService(it) }
|
|
||||||
// .filter { !it.isLogged }
|
|
||||||
// .map { context.getString(it.nameRes()) }
|
|
||||||
// .sorted()
|
|
||||||
|
|
||||||
return ValidationResult(missingSources, missingTrackers)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getSourceMapping(json: JsonObject): Map<Long, String> {
|
|
||||||
val extensionsMapping = json.get(Backup.EXTENSIONS) ?: return emptyMap()
|
|
||||||
|
|
||||||
return extensionsMapping.asJsonArray
|
|
||||||
.map {
|
|
||||||
val items = it.asString.split(":")
|
|
||||||
items[0].toLong() to items[1]
|
|
||||||
}
|
|
||||||
.toMap()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package suwayomi.tachidesk.manga.impl.backup.legacy.models
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.util.Date
|
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Json values
|
|
||||||
*/
|
|
||||||
object Backup {
|
|
||||||
const val CURRENT_VERSION = 2
|
|
||||||
const val MANGA = "manga"
|
|
||||||
const val MANGAS = "mangas"
|
|
||||||
const val TRACK = "track"
|
|
||||||
const val CHAPTERS = "chapters"
|
|
||||||
const val CATEGORIES = "categories"
|
|
||||||
const val EXTENSIONS = "extensions"
|
|
||||||
const val HISTORY = "history"
|
|
||||||
const val VERSION = "version"
|
|
||||||
|
|
||||||
fun getDefaultFilename(): String {
|
|
||||||
val date = SimpleDateFormat("yyyy-MM-dd_HH-mm", Locale.getDefault()).format(Date())
|
|
||||||
return "tachiyomi_$date.json"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
package suwayomi.tachidesk.manga.impl.backup.legacy.models
|
|
||||||
|
|
||||||
data class DHistory(val url: String, val lastRead: Long)
|
|
||||||
-31
@@ -1,31 +0,0 @@
|
|||||||
package suwayomi.tachidesk.manga.impl.backup.legacy.serializer
|
|
||||||
|
|
||||||
import com.github.salomonbrys.kotson.typeAdapter
|
|
||||||
import com.google.gson.TypeAdapter
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.CategoryImpl
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JSON Serializer used to write / read [CategoryImpl] to / from json
|
|
||||||
*/
|
|
||||||
object CategoryTypeAdapter {
|
|
||||||
|
|
||||||
fun build(): TypeAdapter<CategoryImpl> {
|
|
||||||
return typeAdapter {
|
|
||||||
write {
|
|
||||||
beginArray()
|
|
||||||
value(it.name)
|
|
||||||
value(it.order)
|
|
||||||
endArray()
|
|
||||||
}
|
|
||||||
|
|
||||||
read {
|
|
||||||
beginArray()
|
|
||||||
val category = CategoryImpl()
|
|
||||||
category.name = nextString()
|
|
||||||
category.order = nextInt()
|
|
||||||
endArray()
|
|
||||||
category
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-59
@@ -1,59 +0,0 @@
|
|||||||
package suwayomi.tachidesk.manga.impl.backup.legacy.serializer
|
|
||||||
|
|
||||||
import com.github.salomonbrys.kotson.typeAdapter
|
|
||||||
import com.google.gson.TypeAdapter
|
|
||||||
import com.google.gson.stream.JsonToken
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.ChapterImpl
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JSON Serializer used to write / read [ChapterImpl] to / from json
|
|
||||||
*/
|
|
||||||
object ChapterTypeAdapter {
|
|
||||||
|
|
||||||
private const val URL = "u"
|
|
||||||
private const val READ = "r"
|
|
||||||
private const val BOOKMARK = "b"
|
|
||||||
private const val LAST_READ = "l"
|
|
||||||
|
|
||||||
fun build(): TypeAdapter<ChapterImpl> {
|
|
||||||
return typeAdapter {
|
|
||||||
write {
|
|
||||||
if (it.read || it.bookmark || it.last_page_read != 0) {
|
|
||||||
beginObject()
|
|
||||||
name(URL)
|
|
||||||
value(it.url)
|
|
||||||
if (it.read) {
|
|
||||||
name(READ)
|
|
||||||
value(1)
|
|
||||||
}
|
|
||||||
if (it.bookmark) {
|
|
||||||
name(BOOKMARK)
|
|
||||||
value(1)
|
|
||||||
}
|
|
||||||
if (it.last_page_read != 0) {
|
|
||||||
name(LAST_READ)
|
|
||||||
value(it.last_page_read)
|
|
||||||
}
|
|
||||||
endObject()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
read {
|
|
||||||
val chapter = ChapterImpl()
|
|
||||||
beginObject()
|
|
||||||
while (hasNext()) {
|
|
||||||
if (peek() == JsonToken.NAME) {
|
|
||||||
when (nextName()) {
|
|
||||||
URL -> chapter.url = nextString()
|
|
||||||
READ -> chapter.read = nextInt() == 1
|
|
||||||
BOOKMARK -> chapter.bookmark = nextInt() == 1
|
|
||||||
LAST_READ -> chapter.last_page_read = nextInt()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
endObject()
|
|
||||||
chapter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
package suwayomi.tachidesk.manga.impl.backup.legacy.serializer
|
|
||||||
|
|
||||||
import com.github.salomonbrys.kotson.typeAdapter
|
|
||||||
import com.google.gson.TypeAdapter
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.legacy.models.DHistory
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JSON Serializer used to write / read [DHistory] to / from json
|
|
||||||
*/
|
|
||||||
object HistoryTypeAdapter {
|
|
||||||
|
|
||||||
fun build(): TypeAdapter<DHistory> {
|
|
||||||
return typeAdapter {
|
|
||||||
write {
|
|
||||||
if (it.lastRead != 0L) {
|
|
||||||
beginArray()
|
|
||||||
value(it.url)
|
|
||||||
value(it.lastRead)
|
|
||||||
endArray()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
read {
|
|
||||||
beginArray()
|
|
||||||
val url = nextString()
|
|
||||||
val lastRead = nextLong()
|
|
||||||
endArray()
|
|
||||||
DHistory(url, lastRead)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-37
@@ -1,37 +0,0 @@
|
|||||||
package suwayomi.tachidesk.manga.impl.backup.legacy.serializer
|
|
||||||
|
|
||||||
import com.github.salomonbrys.kotson.typeAdapter
|
|
||||||
import com.google.gson.TypeAdapter
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.MangaImpl
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JSON Serializer used to write / read [MangaImpl] to / from json
|
|
||||||
*/
|
|
||||||
object MangaTypeAdapter {
|
|
||||||
|
|
||||||
fun build(): TypeAdapter<MangaImpl> {
|
|
||||||
return typeAdapter {
|
|
||||||
write {
|
|
||||||
beginArray()
|
|
||||||
value(it.url)
|
|
||||||
value(it.title)
|
|
||||||
value(it.source)
|
|
||||||
value(it.viewer)
|
|
||||||
value(it.chapter_flags)
|
|
||||||
endArray()
|
|
||||||
}
|
|
||||||
|
|
||||||
read {
|
|
||||||
beginArray()
|
|
||||||
val manga = MangaImpl()
|
|
||||||
manga.url = nextString()
|
|
||||||
manga.title = nextString()
|
|
||||||
manga.source = nextLong()
|
|
||||||
manga.viewer = nextInt()
|
|
||||||
manga.chapter_flags = nextInt()
|
|
||||||
endArray()
|
|
||||||
manga
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-59
@@ -1,59 +0,0 @@
|
|||||||
package suwayomi.tachidesk.manga.impl.backup.legacy.serializer
|
|
||||||
|
|
||||||
import com.github.salomonbrys.kotson.typeAdapter
|
|
||||||
import com.google.gson.TypeAdapter
|
|
||||||
import com.google.gson.stream.JsonToken
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.models.TrackImpl
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JSON Serializer used to write / read [TrackImpl] to / from json
|
|
||||||
*/
|
|
||||||
object TrackTypeAdapter {
|
|
||||||
|
|
||||||
private const val SYNC = "s"
|
|
||||||
private const val MEDIA = "r"
|
|
||||||
private const val LIBRARY = "ml"
|
|
||||||
private const val TITLE = "t"
|
|
||||||
private const val LAST_READ = "l"
|
|
||||||
private const val TRACKING_URL = "u"
|
|
||||||
|
|
||||||
fun build(): TypeAdapter<TrackImpl> {
|
|
||||||
return typeAdapter {
|
|
||||||
write {
|
|
||||||
beginObject()
|
|
||||||
name(TITLE)
|
|
||||||
value(it.title)
|
|
||||||
name(SYNC)
|
|
||||||
value(it.sync_id)
|
|
||||||
name(MEDIA)
|
|
||||||
value(it.media_id)
|
|
||||||
name(LIBRARY)
|
|
||||||
value(it.library_id)
|
|
||||||
name(LAST_READ)
|
|
||||||
value(it.last_chapter_read)
|
|
||||||
name(TRACKING_URL)
|
|
||||||
value(it.tracking_url)
|
|
||||||
endObject()
|
|
||||||
}
|
|
||||||
|
|
||||||
read {
|
|
||||||
val track = TrackImpl()
|
|
||||||
beginObject()
|
|
||||||
while (hasNext()) {
|
|
||||||
if (peek() == JsonToken.NAME) {
|
|
||||||
when (nextName()) {
|
|
||||||
TITLE -> track.title = nextString()
|
|
||||||
SYNC -> track.sync_id = nextInt()
|
|
||||||
MEDIA -> track.media_id = nextInt()
|
|
||||||
LIBRARY -> track.library_id = nextLong()
|
|
||||||
LAST_READ -> track.last_chapter_read = nextInt()
|
|
||||||
TRACKING_URL -> track.tracking_url = nextString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
endObject()
|
|
||||||
track
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,18 @@
|
|||||||
package suwayomi.tachidesk.manga.impl.backup.models
|
package suwayomi.tachidesk.manga.impl.backup.models
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
|
// import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
||||||
|
// import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
||||||
|
|
||||||
// import tachiyomi.source.model.MangaInfo
|
// substitute for eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
||||||
|
object OrientationType {
|
||||||
|
const val MASK = 0x00000038
|
||||||
|
}
|
||||||
|
|
||||||
|
// substitute for eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
||||||
|
object ReadingModeType {
|
||||||
|
const val MASK = 0x00000007
|
||||||
|
}
|
||||||
|
|
||||||
interface Manga : SManga {
|
interface Manga : SManga {
|
||||||
|
|
||||||
@@ -10,85 +20,100 @@ interface Manga : SManga {
|
|||||||
|
|
||||||
var source: Long
|
var source: Long
|
||||||
|
|
||||||
/** is in library */
|
|
||||||
var favorite: Boolean
|
var favorite: Boolean
|
||||||
|
|
||||||
|
// last time the chapter list changed in any way
|
||||||
var last_update: Long
|
var last_update: Long
|
||||||
|
|
||||||
|
// predicted next update time based on latest (by date) 4 chapters' deltas
|
||||||
|
var next_update: Long
|
||||||
|
|
||||||
var date_added: Long
|
var date_added: Long
|
||||||
|
|
||||||
var viewer: Int
|
var viewer_flags: Int
|
||||||
|
|
||||||
var chapter_flags: Int
|
var chapter_flags: Int
|
||||||
|
|
||||||
var cover_last_modified: Long
|
var cover_last_modified: Long
|
||||||
|
|
||||||
fun setChapterOrder(order: Int) {
|
fun setChapterOrder(order: Int) {
|
||||||
setFlags(order, SORT_MASK)
|
setChapterFlags(order, CHAPTER_SORT_MASK)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sortDescending(): Boolean {
|
fun sortDescending(): Boolean {
|
||||||
return chapter_flags and SORT_MASK == SORT_DESC
|
return chapter_flags and CHAPTER_SORT_MASK == CHAPTER_SORT_DESC
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getGenres(): List<String>? {
|
fun getGenres(): List<String>? {
|
||||||
return genre?.split(", ")?.map { it.trim() }
|
return genre?.split(", ")?.map { it.trim() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setFlags(flag: Int, mask: Int) {
|
private fun setChapterFlags(flag: Int, mask: Int) {
|
||||||
chapter_flags = chapter_flags and mask.inv() or (flag and mask)
|
chapter_flags = chapter_flags and mask.inv() or (flag and mask)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setViewerFlags(flag: Int, mask: Int) {
|
||||||
|
viewer_flags = viewer_flags and mask.inv() or (flag and mask)
|
||||||
|
}
|
||||||
|
|
||||||
// Used to display the chapter's title one way or another
|
// Used to display the chapter's title one way or another
|
||||||
var displayMode: Int
|
var displayMode: Int
|
||||||
get() = chapter_flags and DISPLAY_MASK
|
get() = chapter_flags and CHAPTER_DISPLAY_MASK
|
||||||
set(mode) = setFlags(mode, DISPLAY_MASK)
|
set(mode) = setChapterFlags(mode, CHAPTER_DISPLAY_MASK)
|
||||||
|
|
||||||
var readFilter: Int
|
var readFilter: Int
|
||||||
get() = chapter_flags and READ_MASK
|
get() = chapter_flags and CHAPTER_READ_MASK
|
||||||
set(filter) = setFlags(filter, READ_MASK)
|
set(filter) = setChapterFlags(filter, CHAPTER_READ_MASK)
|
||||||
|
|
||||||
var downloadedFilter: Int
|
var downloadedFilter: Int
|
||||||
get() = chapter_flags and DOWNLOADED_MASK
|
get() = chapter_flags and CHAPTER_DOWNLOADED_MASK
|
||||||
set(filter) = setFlags(filter, DOWNLOADED_MASK)
|
set(filter) = setChapterFlags(filter, CHAPTER_DOWNLOADED_MASK)
|
||||||
|
|
||||||
var bookmarkedFilter: Int
|
var bookmarkedFilter: Int
|
||||||
get() = chapter_flags and BOOKMARKED_MASK
|
get() = chapter_flags and CHAPTER_BOOKMARKED_MASK
|
||||||
set(filter) = setFlags(filter, BOOKMARKED_MASK)
|
set(filter) = setChapterFlags(filter, CHAPTER_BOOKMARKED_MASK)
|
||||||
|
|
||||||
var sorting: Int
|
var sorting: Int
|
||||||
get() = chapter_flags and SORTING_MASK
|
get() = chapter_flags and CHAPTER_SORTING_MASK
|
||||||
set(sort) = setFlags(sort, SORTING_MASK)
|
set(sort) = setChapterFlags(sort, CHAPTER_SORTING_MASK)
|
||||||
|
|
||||||
|
var readingModeType: Int
|
||||||
|
get() = viewer_flags and ReadingModeType.MASK
|
||||||
|
set(readingMode) = setViewerFlags(readingMode, ReadingModeType.MASK)
|
||||||
|
|
||||||
|
var orientationType: Int
|
||||||
|
get() = viewer_flags and OrientationType.MASK
|
||||||
|
set(rotationType) = setViewerFlags(rotationType, OrientationType.MASK)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
const val SORT_DESC = 0x00000000
|
|
||||||
const val SORT_ASC = 0x00000001
|
|
||||||
const val SORT_MASK = 0x00000001
|
|
||||||
|
|
||||||
// Generic filter that does not filter anything
|
// Generic filter that does not filter anything
|
||||||
const val SHOW_ALL = 0x00000000
|
const val SHOW_ALL = 0x00000000
|
||||||
|
|
||||||
const val SHOW_UNREAD = 0x00000002
|
const val CHAPTER_SORT_DESC = 0x00000000
|
||||||
const val SHOW_READ = 0x00000004
|
const val CHAPTER_SORT_ASC = 0x00000001
|
||||||
const val READ_MASK = 0x00000006
|
const val CHAPTER_SORT_MASK = 0x00000001
|
||||||
|
|
||||||
const val SHOW_DOWNLOADED = 0x00000008
|
const val CHAPTER_SHOW_UNREAD = 0x00000002
|
||||||
const val SHOW_NOT_DOWNLOADED = 0x00000010
|
const val CHAPTER_SHOW_READ = 0x00000004
|
||||||
const val DOWNLOADED_MASK = 0x00000018
|
const val CHAPTER_READ_MASK = 0x00000006
|
||||||
|
|
||||||
const val SHOW_BOOKMARKED = 0x00000020
|
const val CHAPTER_SHOW_DOWNLOADED = 0x00000008
|
||||||
const val SHOW_NOT_BOOKMARKED = 0x00000040
|
const val CHAPTER_SHOW_NOT_DOWNLOADED = 0x00000010
|
||||||
const val BOOKMARKED_MASK = 0x00000060
|
const val CHAPTER_DOWNLOADED_MASK = 0x00000018
|
||||||
|
|
||||||
const val SORTING_SOURCE = 0x00000000
|
const val CHAPTER_SHOW_BOOKMARKED = 0x00000020
|
||||||
const val SORTING_NUMBER = 0x00000100
|
const val CHAPTER_SHOW_NOT_BOOKMARKED = 0x00000040
|
||||||
const val SORTING_UPLOAD_DATE = 0x00000200
|
const val CHAPTER_BOOKMARKED_MASK = 0x00000060
|
||||||
const val SORTING_MASK = 0x00000300
|
|
||||||
|
|
||||||
const val DISPLAY_NAME = 0x00000000
|
const val CHAPTER_SORTING_SOURCE = 0x00000000
|
||||||
const val DISPLAY_NUMBER = 0x00100000
|
const val CHAPTER_SORTING_NUMBER = 0x00000100
|
||||||
const val DISPLAY_MASK = 0x00100000
|
const val CHAPTER_SORTING_UPLOAD_DATE = 0x00000200
|
||||||
|
const val CHAPTER_SORTING_MASK = 0x00000300
|
||||||
|
|
||||||
|
const val CHAPTER_DISPLAY_NAME = 0x00000000
|
||||||
|
const val CHAPTER_DISPLAY_NUMBER = 0x00100000
|
||||||
|
const val CHAPTER_DISPLAY_MASK = 0x00100000
|
||||||
|
|
||||||
fun create(source: Long): Manga = MangaImpl().apply {
|
fun create(source: Long): Manga = MangaImpl().apply {
|
||||||
this.source = source
|
this.source = source
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import suwayomi.tachidesk.manga.model.table.MangaTable
|
|||||||
|
|
||||||
open class MangaImpl : Manga {
|
open class MangaImpl : Manga {
|
||||||
|
|
||||||
override var id: Long? = 0
|
override var id: Long? = null
|
||||||
|
|
||||||
override var source: Long = -1
|
override var source: Long = -1
|
||||||
|
|
||||||
@@ -29,6 +29,8 @@ open class MangaImpl : Manga {
|
|||||||
|
|
||||||
override var last_update: Long = 0
|
override var last_update: Long = 0
|
||||||
|
|
||||||
|
override var next_update: Long = 0
|
||||||
|
|
||||||
override var date_added: Long = 0
|
override var date_added: Long = 0
|
||||||
|
|
||||||
override var initialized: Boolean = false
|
override var initialized: Boolean = false
|
||||||
@@ -42,7 +44,7 @@ open class MangaImpl : Manga {
|
|||||||
* 4 -> Webtoon
|
* 4 -> Webtoon
|
||||||
* 5 -> Continues Vertical
|
* 5 -> Continues Vertical
|
||||||
*/
|
*/
|
||||||
override var viewer: Int = 0
|
override var viewer_flags: Int = 0
|
||||||
|
|
||||||
/** Contains some useful info about
|
/** Contains some useful info about
|
||||||
*/
|
*/
|
||||||
@@ -70,7 +72,7 @@ open class MangaImpl : Manga {
|
|||||||
url = mangaRecord[MangaTable.url]
|
url = mangaRecord[MangaTable.url]
|
||||||
title = mangaRecord[MangaTable.title]
|
title = mangaRecord[MangaTable.title]
|
||||||
source = mangaRecord[MangaTable.sourceReference]
|
source = mangaRecord[MangaTable.sourceReference]
|
||||||
viewer = 0 // TODO: implement
|
viewer_flags = 0 // TODO: implement
|
||||||
chapter_flags = 0 // TODO: implement
|
chapter_flags = 0 // TODO: implement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package suwayomi.tachidesk.manga.impl.backup.proto
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import kotlinx.serialization.protobuf.ProtoBuf
|
||||||
|
|
||||||
|
open class ProtoBackupBase {
|
||||||
|
var sourceMapping: Map<Long, String> = emptyMap()
|
||||||
|
|
||||||
|
val parser = ProtoBuf
|
||||||
|
}
|
||||||
+136
@@ -0,0 +1,136 @@
|
|||||||
|
package suwayomi.tachidesk.manga.impl.backup.proto
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import okio.buffer
|
||||||
|
import okio.gzip
|
||||||
|
import okio.sink
|
||||||
|
import org.jetbrains.exposed.sql.Query
|
||||||
|
import org.jetbrains.exposed.sql.SortOrder
|
||||||
|
import org.jetbrains.exposed.sql.select
|
||||||
|
import org.jetbrains.exposed.sql.selectAll
|
||||||
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
|
import suwayomi.tachidesk.manga.impl.CategoryManga
|
||||||
|
import suwayomi.tachidesk.manga.impl.Chapter
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.BackupFlags
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.proto.models.Backup
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.proto.models.BackupCategory
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.proto.models.BackupChapter
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.proto.models.BackupManga
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.proto.models.BackupSerializer
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.proto.models.BackupSource
|
||||||
|
import suwayomi.tachidesk.manga.model.table.CategoryTable
|
||||||
|
import suwayomi.tachidesk.manga.model.table.MangaStatus
|
||||||
|
import suwayomi.tachidesk.manga.model.table.MangaTable
|
||||||
|
import suwayomi.tachidesk.manga.model.table.SourceTable
|
||||||
|
import suwayomi.tachidesk.manga.model.table.toDataClass
|
||||||
|
import java.io.ByteArrayOutputStream
|
||||||
|
import java.io.InputStream
|
||||||
|
|
||||||
|
object ProtoBackupExport : ProtoBackupBase() {
|
||||||
|
suspend fun createBackup(flags: BackupFlags): InputStream {
|
||||||
|
// Create root object
|
||||||
|
|
||||||
|
val databaseManga = transaction { MangaTable.select { MangaTable.inLibrary eq true } }
|
||||||
|
|
||||||
|
val backup: Backup = transaction {
|
||||||
|
Backup(
|
||||||
|
backupManga(databaseManga, flags),
|
||||||
|
backupCategories(),
|
||||||
|
backupExtensionInfo(databaseManga)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val byteArray = parser.encodeToByteArray(BackupSerializer, backup)
|
||||||
|
|
||||||
|
val byteStream = ByteArrayOutputStream()
|
||||||
|
byteStream.sink().gzip().buffer().use { it.write(byteArray) }
|
||||||
|
|
||||||
|
return byteStream.toByteArray().inputStream()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun backupManga(databaseManga: Query, flags: BackupFlags): List<BackupManga> {
|
||||||
|
return databaseManga.map { mangaRow ->
|
||||||
|
val backupManga = BackupManga(
|
||||||
|
mangaRow[MangaTable.sourceReference],
|
||||||
|
mangaRow[MangaTable.url],
|
||||||
|
mangaRow[MangaTable.title],
|
||||||
|
mangaRow[MangaTable.artist],
|
||||||
|
mangaRow[MangaTable.author],
|
||||||
|
mangaRow[MangaTable.description],
|
||||||
|
mangaRow[MangaTable.genre]?.split(", ") ?: emptyList(),
|
||||||
|
MangaStatus.valueOf(mangaRow[MangaTable.status]).value,
|
||||||
|
mangaRow[MangaTable.thumbnail_url],
|
||||||
|
0, // not supported in Tachidesk
|
||||||
|
0, // not supported in Tachidesk
|
||||||
|
)
|
||||||
|
|
||||||
|
val mangaId = mangaRow[MangaTable.id].value
|
||||||
|
|
||||||
|
if (flags.includeChapters) {
|
||||||
|
val chapters = runBlocking { Chapter.getChapterList(mangaId) }
|
||||||
|
backupManga.chapters = chapters.map {
|
||||||
|
BackupChapter(
|
||||||
|
it.url,
|
||||||
|
it.name,
|
||||||
|
it.scanlator,
|
||||||
|
it.read,
|
||||||
|
it.bookmarked,
|
||||||
|
it.lastPageRead,
|
||||||
|
0, // not supported in Tachidesk
|
||||||
|
it.uploadDate,
|
||||||
|
it.chapterNumber,
|
||||||
|
it.index,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags.includeCategories) {
|
||||||
|
backupManga.categories = CategoryManga.getMangaCategories(mangaId).map { it.order }
|
||||||
|
}
|
||||||
|
|
||||||
|
// if(flags.includeTracking) {
|
||||||
|
// backupManga.tracking = TODO()
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (flags.includeHistory) {
|
||||||
|
// backupManga.history = TODO()
|
||||||
|
// }
|
||||||
|
|
||||||
|
backupManga
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun backupCategories(): List<BackupCategory> {
|
||||||
|
return CategoryTable.selectAll().orderBy(CategoryTable.order to SortOrder.ASC).map {
|
||||||
|
CategoryTable.toDataClass(it)
|
||||||
|
}.map {
|
||||||
|
BackupCategory(
|
||||||
|
it.name,
|
||||||
|
it.order,
|
||||||
|
0, // not supported in Tachidesk
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun backupExtensionInfo(mangas: Query): List<BackupSource> {
|
||||||
|
return mangas
|
||||||
|
.asSequence()
|
||||||
|
.map { it[MangaTable.sourceReference] }
|
||||||
|
.distinct()
|
||||||
|
.map {
|
||||||
|
val sourceRow = SourceTable.select { SourceTable.id eq it }.firstOrNull()
|
||||||
|
BackupSource(
|
||||||
|
sourceRow?.get(SourceTable.name) ?: "",
|
||||||
|
it
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.toList()
|
||||||
|
}
|
||||||
|
}
|
||||||
+237
@@ -0,0 +1,237 @@
|
|||||||
|
package suwayomi.tachidesk.manga.impl.backup.proto
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import mu.KotlinLogging
|
||||||
|
import okio.buffer
|
||||||
|
import okio.gzip
|
||||||
|
import okio.source
|
||||||
|
import org.jetbrains.exposed.sql.and
|
||||||
|
import org.jetbrains.exposed.sql.insert
|
||||||
|
import org.jetbrains.exposed.sql.insertAndGetId
|
||||||
|
import org.jetbrains.exposed.sql.select
|
||||||
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
|
import org.jetbrains.exposed.sql.update
|
||||||
|
import suwayomi.tachidesk.manga.impl.Category
|
||||||
|
import suwayomi.tachidesk.manga.impl.CategoryManga
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.AbstractBackupValidator.ValidationResult
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.models.Chapter
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.models.Manga
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.models.Track
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.proto.ProtoBackupValidator.validate
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.proto.models.BackupCategory
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.proto.models.BackupHistory
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.proto.models.BackupManga
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.proto.models.BackupSerializer
|
||||||
|
import suwayomi.tachidesk.manga.model.table.CategoryTable
|
||||||
|
import suwayomi.tachidesk.manga.model.table.ChapterTable
|
||||||
|
import suwayomi.tachidesk.manga.model.table.MangaTable
|
||||||
|
import java.io.InputStream
|
||||||
|
import java.lang.Integer.max
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
|
object ProtoBackupImport : ProtoBackupBase() {
|
||||||
|
private val logger = KotlinLogging.logger {}
|
||||||
|
|
||||||
|
private var restoreAmount = 0
|
||||||
|
|
||||||
|
private val errors = mutableListOf<Pair<Date, String>>()
|
||||||
|
|
||||||
|
suspend fun performRestore(sourceStream: InputStream): ValidationResult {
|
||||||
|
val backupString = sourceStream.source().gzip().buffer().use { it.readByteArray() }
|
||||||
|
val backup = parser.decodeFromByteArray(BackupSerializer, backupString)
|
||||||
|
|
||||||
|
val validationResult = validate(backup)
|
||||||
|
|
||||||
|
restoreAmount = backup.backupManga.size + 1 // +1 for categories
|
||||||
|
|
||||||
|
// Restore categories
|
||||||
|
if (backup.backupCategories.isNotEmpty()) {
|
||||||
|
restoreCategories(backup.backupCategories)
|
||||||
|
}
|
||||||
|
|
||||||
|
val categoryMapping = transaction {
|
||||||
|
backup.backupCategories.associate {
|
||||||
|
it.order to CategoryTable.select { CategoryTable.name eq it.name }.first()[CategoryTable.id].value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store source mapping for error messages
|
||||||
|
sourceMapping = backup.backupSources.map { it.sourceId to it.name }.toMap()
|
||||||
|
|
||||||
|
// Restore individual manga
|
||||||
|
backup.backupManga.forEach {
|
||||||
|
restoreManga(it, backup.backupCategories, categoryMapping)
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info {
|
||||||
|
"""
|
||||||
|
Restore Errors:
|
||||||
|
${errors.joinToString("\n") { "${it.first} - ${it.second}" }}
|
||||||
|
Restore Summary:
|
||||||
|
- Missing Sources:
|
||||||
|
${validationResult.missingSources.joinToString("\n ")}
|
||||||
|
- Missing Trackers:
|
||||||
|
${validationResult.missingTrackers.joinToString("\n ")}
|
||||||
|
""".trimIndent()
|
||||||
|
}
|
||||||
|
|
||||||
|
return validationResult
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun restoreCategories(backupCategories: List<BackupCategory>) {
|
||||||
|
val dbCategories = Category.getCategoryList()
|
||||||
|
|
||||||
|
// Iterate over them and create missing categories
|
||||||
|
backupCategories.forEach { category ->
|
||||||
|
if (dbCategories.none { it.name == category.name }) {
|
||||||
|
Category.createCategory(category.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun restoreManga(
|
||||||
|
backupManga: BackupManga,
|
||||||
|
backupCategories: List<BackupCategory>,
|
||||||
|
categoryMapping: Map<Int, Int>
|
||||||
|
) {
|
||||||
|
val manga = backupManga.getMangaImpl()
|
||||||
|
val chapters = backupManga.getChaptersImpl()
|
||||||
|
val categories = backupManga.categories
|
||||||
|
val history = backupManga.history
|
||||||
|
val tracks = backupManga.getTrackingImpl()
|
||||||
|
|
||||||
|
try {
|
||||||
|
restoreMangaData(manga, chapters, categories, history, tracks, backupCategories, categoryMapping)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
val sourceName = sourceMapping[manga.source] ?: manga.source.toString()
|
||||||
|
errors.add(Date() to "${manga.title} [$sourceName]: ${e.message}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED_PARAMETER") // TODO: remove
|
||||||
|
private fun restoreMangaData(
|
||||||
|
manga: Manga,
|
||||||
|
chapters: List<Chapter>,
|
||||||
|
categories: List<Int>,
|
||||||
|
history: List<BackupHistory>,
|
||||||
|
tracks: List<Track>,
|
||||||
|
backupCategories: List<BackupCategory>,
|
||||||
|
categoryMapping: Map<Int, Int>
|
||||||
|
) {
|
||||||
|
val dbManga = transaction {
|
||||||
|
MangaTable.select { (MangaTable.url eq manga.url) and (MangaTable.sourceReference eq manga.source) }
|
||||||
|
.firstOrNull()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dbManga == null) { // Manga not in database
|
||||||
|
transaction {
|
||||||
|
// insert manga to database
|
||||||
|
val mangaId = MangaTable.insertAndGetId {
|
||||||
|
it[url] = manga.url
|
||||||
|
it[title] = manga.title
|
||||||
|
|
||||||
|
it[artist] = manga.artist
|
||||||
|
it[author] = manga.author
|
||||||
|
it[description] = manga.description
|
||||||
|
it[genre] = manga.genre
|
||||||
|
it[status] = manga.status
|
||||||
|
it[thumbnail_url] = manga.thumbnail_url
|
||||||
|
|
||||||
|
it[sourceReference] = manga.source
|
||||||
|
|
||||||
|
it[initialized] = manga.description != null
|
||||||
|
|
||||||
|
it[inLibrary] = manga.favorite
|
||||||
|
}.value
|
||||||
|
|
||||||
|
// insert chapter data
|
||||||
|
val chaptersLength = chapters.size
|
||||||
|
chapters.forEach { chapter ->
|
||||||
|
ChapterTable.insert {
|
||||||
|
it[url] = chapter.url
|
||||||
|
it[name] = chapter.name
|
||||||
|
it[date_upload] = chapter.date_upload
|
||||||
|
it[chapter_number] = chapter.chapter_number
|
||||||
|
it[scanlator] = chapter.scanlator
|
||||||
|
|
||||||
|
it[chapterIndex] = chaptersLength - chapter.source_order
|
||||||
|
it[ChapterTable.manga] = mangaId
|
||||||
|
|
||||||
|
it[isRead] = chapter.read
|
||||||
|
it[lastPageRead] = chapter.last_page_read
|
||||||
|
it[isBookmarked] = chapter.bookmark
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert categories
|
||||||
|
categories.forEach { backupCategoryOrder ->
|
||||||
|
CategoryManga.addMangaToCategory(mangaId, categoryMapping[backupCategoryOrder]!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else { // Manga in database
|
||||||
|
transaction {
|
||||||
|
val mangaId = dbManga[MangaTable.id].value
|
||||||
|
|
||||||
|
// Merge manga data
|
||||||
|
MangaTable.update({ MangaTable.id eq mangaId }) {
|
||||||
|
it[artist] = manga.artist ?: dbManga[artist]
|
||||||
|
it[author] = manga.author ?: dbManga[author]
|
||||||
|
it[description] = manga.description ?: dbManga[description]
|
||||||
|
it[genre] = manga.genre ?: dbManga[genre]
|
||||||
|
it[status] = manga.status
|
||||||
|
it[thumbnail_url] = manga.thumbnail_url ?: dbManga[thumbnail_url]
|
||||||
|
|
||||||
|
it[initialized] = dbManga[initialized] || manga.description != null
|
||||||
|
|
||||||
|
it[inLibrary] = manga.favorite || dbManga[inLibrary]
|
||||||
|
}
|
||||||
|
|
||||||
|
// merge chapter data
|
||||||
|
val chaptersLength = chapters.size
|
||||||
|
val dbChapters = ChapterTable.select { ChapterTable.manga eq mangaId }
|
||||||
|
|
||||||
|
chapters.forEach { chapter ->
|
||||||
|
val dbChapter = dbChapters.find { it[ChapterTable.url] == chapter.url }
|
||||||
|
|
||||||
|
if (dbChapter == null) {
|
||||||
|
ChapterTable.insert {
|
||||||
|
it[url] = chapter.url
|
||||||
|
it[name] = chapter.name
|
||||||
|
it[date_upload] = chapter.date_upload
|
||||||
|
it[chapter_number] = chapter.chapter_number
|
||||||
|
it[scanlator] = chapter.scanlator
|
||||||
|
|
||||||
|
it[chapterIndex] = chaptersLength - chapter.source_order
|
||||||
|
it[ChapterTable.manga] = mangaId
|
||||||
|
|
||||||
|
it[isRead] = chapter.read
|
||||||
|
it[lastPageRead] = chapter.last_page_read
|
||||||
|
it[isBookmarked] = chapter.bookmark
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ChapterTable.update({ (ChapterTable.url eq dbChapter[ChapterTable.url]) and (ChapterTable.manga eq mangaId) }) {
|
||||||
|
it[isRead] = chapter.read || dbChapter[isRead]
|
||||||
|
it[lastPageRead] = max(chapter.last_page_read, dbChapter[lastPageRead])
|
||||||
|
it[isBookmarked] = chapter.bookmark || dbChapter[isBookmarked]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// merge categories
|
||||||
|
categories.forEach { backupCategoryOrder ->
|
||||||
|
CategoryManga.addMangaToCategory(mangaId, categoryMapping[backupCategoryOrder]!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: insert/merge history
|
||||||
|
|
||||||
|
// TODO: insert/merge tracking
|
||||||
|
}
|
||||||
|
}
|
||||||
+57
@@ -0,0 +1,57 @@
|
|||||||
|
package suwayomi.tachidesk.manga.impl.backup.proto
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import okio.buffer
|
||||||
|
import okio.gzip
|
||||||
|
import okio.source
|
||||||
|
import org.jetbrains.exposed.sql.select
|
||||||
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.AbstractBackupValidator
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.proto.models.Backup
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.proto.models.BackupSerializer
|
||||||
|
import suwayomi.tachidesk.manga.model.table.SourceTable
|
||||||
|
import java.io.InputStream
|
||||||
|
|
||||||
|
object ProtoBackupValidator : AbstractBackupValidator() {
|
||||||
|
fun validate(backup: Backup): ValidationResult {
|
||||||
|
if (backup.backupManga.isEmpty()) {
|
||||||
|
throw Exception("Backup does not contain any manga.")
|
||||||
|
}
|
||||||
|
|
||||||
|
val sources = backup.backupSources.map { it.sourceId to it.name }.toMap()
|
||||||
|
|
||||||
|
val missingSources = transaction {
|
||||||
|
sources
|
||||||
|
.filter { SourceTable.select { SourceTable.id eq it.key }.firstOrNull() == null }
|
||||||
|
.map { "${it.value} (${it.key})" }
|
||||||
|
.sorted()
|
||||||
|
}
|
||||||
|
|
||||||
|
// val trackers = backup.backupManga
|
||||||
|
// .flatMap { it.tracking }
|
||||||
|
// .map { it.syncId }
|
||||||
|
// .distinct()
|
||||||
|
|
||||||
|
val missingTrackers = listOf("")
|
||||||
|
// val missingTrackers = trackers
|
||||||
|
// .mapNotNull { trackManager.getService(it) }
|
||||||
|
// .filter { !it.isLogged }
|
||||||
|
// .map { context.getString(it.nameRes()) }
|
||||||
|
// .sorted()
|
||||||
|
|
||||||
|
return ValidationResult(missingSources, missingTrackers)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun validate(sourceStream: InputStream): ValidationResult {
|
||||||
|
val backupString = sourceStream.source().gzip().buffer().use { it.readByteArray() }
|
||||||
|
val backup = ProtoBackupImport.parser.decodeFromByteArray(BackupSerializer, backupString)
|
||||||
|
|
||||||
|
return validate(backup)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package suwayomi.tachidesk.manga.impl.backup.proto.models
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.protobuf.ProtoNumber
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Backup(
|
||||||
|
@ProtoNumber(1) val backupManga: List<BackupManga>,
|
||||||
|
@ProtoNumber(2) var backupCategories: List<BackupCategory> = emptyList(),
|
||||||
|
// Bump by 100 to specify this is a 0.x value
|
||||||
|
@ProtoNumber(100) var backupSources: List<BackupSource> = emptyList(),
|
||||||
|
)
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
package suwayomi.tachidesk.manga.impl.backup.proto.models
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.protobuf.ProtoNumber
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.models.Category
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.models.CategoryImpl
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
class BackupCategory(
|
||||||
|
@ProtoNumber(1) var name: String,
|
||||||
|
@ProtoNumber(2) var order: Int = 0,
|
||||||
|
// @ProtoNumber(3) val updateInterval: Int = 0, 1.x value not used in 0.x
|
||||||
|
// Bump by 100 to specify this is a 0.x value
|
||||||
|
@ProtoNumber(100) var flags: Int = 0,
|
||||||
|
) {
|
||||||
|
fun getCategoryImpl(): CategoryImpl {
|
||||||
|
return CategoryImpl().apply {
|
||||||
|
name = this@BackupCategory.name
|
||||||
|
flags = this@BackupCategory.flags
|
||||||
|
order = this@BackupCategory.order
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun copyFrom(category: Category): BackupCategory {
|
||||||
|
return BackupCategory(
|
||||||
|
name = category.name,
|
||||||
|
order = category.order,
|
||||||
|
flags = category.flags
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+56
@@ -0,0 +1,56 @@
|
|||||||
|
package suwayomi.tachidesk.manga.impl.backup.proto.models
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.protobuf.ProtoNumber
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.models.Chapter
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.models.ChapterImpl
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class BackupChapter(
|
||||||
|
// in 1.x some of these values have different names
|
||||||
|
// url is called key in 1.x
|
||||||
|
@ProtoNumber(1) var url: String,
|
||||||
|
@ProtoNumber(2) var name: String,
|
||||||
|
@ProtoNumber(3) var scanlator: String? = null,
|
||||||
|
@ProtoNumber(4) var read: Boolean = false,
|
||||||
|
@ProtoNumber(5) var bookmark: Boolean = false,
|
||||||
|
// lastPageRead is called progress in 1.x
|
||||||
|
@ProtoNumber(6) var lastPageRead: Int = 0,
|
||||||
|
@ProtoNumber(7) var dateFetch: Long = 0,
|
||||||
|
@ProtoNumber(8) var dateUpload: Long = 0,
|
||||||
|
// chapterNumber is called number is 1.x
|
||||||
|
@ProtoNumber(9) var chapterNumber: Float = 0F,
|
||||||
|
@ProtoNumber(10) var sourceOrder: Int = 0,
|
||||||
|
) {
|
||||||
|
fun toChapterImpl(): ChapterImpl {
|
||||||
|
return ChapterImpl().apply {
|
||||||
|
url = this@BackupChapter.url
|
||||||
|
name = this@BackupChapter.name
|
||||||
|
chapter_number = this@BackupChapter.chapterNumber
|
||||||
|
scanlator = this@BackupChapter.scanlator
|
||||||
|
read = this@BackupChapter.read
|
||||||
|
bookmark = this@BackupChapter.bookmark
|
||||||
|
last_page_read = this@BackupChapter.lastPageRead
|
||||||
|
date_fetch = this@BackupChapter.dateFetch
|
||||||
|
date_upload = this@BackupChapter.dateUpload
|
||||||
|
source_order = this@BackupChapter.sourceOrder
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun copyFrom(chapter: Chapter): BackupChapter {
|
||||||
|
return BackupChapter(
|
||||||
|
url = chapter.url,
|
||||||
|
name = chapter.name,
|
||||||
|
chapterNumber = chapter.chapter_number,
|
||||||
|
scanlator = chapter.scanlator,
|
||||||
|
read = chapter.read,
|
||||||
|
bookmark = chapter.bookmark,
|
||||||
|
lastPageRead = chapter.last_page_read,
|
||||||
|
dateFetch = chapter.date_fetch,
|
||||||
|
dateUpload = chapter.date_upload,
|
||||||
|
sourceOrder = chapter.source_order
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
package suwayomi.tachidesk.manga.impl.backup.proto.models
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
object BackupFull {
|
||||||
|
fun getDefaultFilename(): String {
|
||||||
|
val date = SimpleDateFormat("yyyy-MM-dd_HH-mm", Locale.getDefault()).format(Date())
|
||||||
|
return "tachiyomi_$date.proto.gz"
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
package suwayomi.tachidesk.manga.impl.backup.proto.models
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.protobuf.ProtoNumber
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class BackupHistory(
|
||||||
|
@ProtoNumber(0) var url: String,
|
||||||
|
@ProtoNumber(1) var lastRead: Long
|
||||||
|
)
|
||||||
+89
@@ -0,0 +1,89 @@
|
|||||||
|
package suwayomi.tachidesk.manga.impl.backup.proto.models
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.protobuf.ProtoNumber
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.models.ChapterImpl
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.models.Manga
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.models.MangaImpl
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.models.TrackImpl
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class BackupManga(
|
||||||
|
// in 1.x some of these values have different names
|
||||||
|
@ProtoNumber(1) var source: Long,
|
||||||
|
// url is called key in 1.x
|
||||||
|
@ProtoNumber(2) var url: String,
|
||||||
|
@ProtoNumber(3) var title: String = "",
|
||||||
|
@ProtoNumber(4) var artist: String? = null,
|
||||||
|
@ProtoNumber(5) var author: String? = null,
|
||||||
|
@ProtoNumber(6) var description: String? = null,
|
||||||
|
@ProtoNumber(7) var genre: List<String> = emptyList(),
|
||||||
|
@ProtoNumber(8) var status: Int = 0,
|
||||||
|
// thumbnailUrl is called cover in 1.x
|
||||||
|
@ProtoNumber(9) var thumbnailUrl: String? = null,
|
||||||
|
// @ProtoNumber(10) val customCover: String = "", 1.x value, not used in 0.x
|
||||||
|
// @ProtoNumber(11) val lastUpdate: Long = 0, 1.x value, not used in 0.x
|
||||||
|
// @ProtoNumber(12) val lastInit: Long = 0, 1.x value, not used in 0.x
|
||||||
|
@ProtoNumber(13) var dateAdded: Long = 0,
|
||||||
|
@ProtoNumber(14) var viewer: Int = 0, // Replaced by viewer_flags
|
||||||
|
// @ProtoNumber(15) val flags: Int = 0, 1.x value, not used in 0.x
|
||||||
|
@ProtoNumber(16) var chapters: List<BackupChapter> = emptyList(),
|
||||||
|
@ProtoNumber(17) var categories: List<Int> = emptyList(),
|
||||||
|
@ProtoNumber(18) var tracking: List<BackupTracking> = emptyList(),
|
||||||
|
// Bump by 100 for values that are not saved/implemented in 1.x but are used in 0.x
|
||||||
|
@ProtoNumber(100) var favorite: Boolean = true,
|
||||||
|
@ProtoNumber(101) var chapterFlags: Int = 0,
|
||||||
|
@ProtoNumber(102) var history: List<BackupHistory> = emptyList(),
|
||||||
|
@ProtoNumber(103) var viewer_flags: Int? = null
|
||||||
|
) {
|
||||||
|
fun getMangaImpl(): MangaImpl {
|
||||||
|
return MangaImpl().apply {
|
||||||
|
url = this@BackupManga.url
|
||||||
|
title = this@BackupManga.title
|
||||||
|
artist = this@BackupManga.artist
|
||||||
|
author = this@BackupManga.author
|
||||||
|
description = this@BackupManga.description
|
||||||
|
genre = this@BackupManga.genre.joinToString()
|
||||||
|
status = this@BackupManga.status
|
||||||
|
thumbnail_url = this@BackupManga.thumbnailUrl
|
||||||
|
favorite = this@BackupManga.favorite
|
||||||
|
source = this@BackupManga.source
|
||||||
|
date_added = this@BackupManga.dateAdded
|
||||||
|
viewer_flags = this@BackupManga.viewer_flags ?: this@BackupManga.viewer
|
||||||
|
chapter_flags = this@BackupManga.chapterFlags
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getChaptersImpl(): List<ChapterImpl> {
|
||||||
|
return chapters.map {
|
||||||
|
it.toChapterImpl()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getTrackingImpl(): List<TrackImpl> {
|
||||||
|
return tracking.map {
|
||||||
|
it.getTrackingImpl()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun copyFrom(manga: Manga): BackupManga {
|
||||||
|
return BackupManga(
|
||||||
|
url = manga.url,
|
||||||
|
title = manga.title,
|
||||||
|
artist = manga.artist,
|
||||||
|
author = manga.author,
|
||||||
|
description = manga.description,
|
||||||
|
genre = manga.getGenres() ?: emptyList(),
|
||||||
|
status = manga.status,
|
||||||
|
thumbnailUrl = manga.thumbnail_url,
|
||||||
|
favorite = manga.favorite,
|
||||||
|
source = manga.source,
|
||||||
|
dateAdded = manga.date_added,
|
||||||
|
viewer = manga.readingModeType,
|
||||||
|
viewer_flags = manga.viewer_flags,
|
||||||
|
chapterFlags = manga.chapter_flags
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
package suwayomi.tachidesk.manga.impl.backup.proto.models
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializer
|
||||||
|
|
||||||
|
@Serializer(forClass = Backup::class)
|
||||||
|
object BackupSerializer
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
package suwayomi.tachidesk.manga.impl.backup.proto.models
|
||||||
|
|
||||||
|
import eu.kanade.tachiyomi.source.Source
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.protobuf.ProtoNumber
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class BackupSource(
|
||||||
|
@ProtoNumber(0) var name: String = "",
|
||||||
|
@ProtoNumber(1) var sourceId: Long
|
||||||
|
) {
|
||||||
|
companion object {
|
||||||
|
fun copyFrom(source: Source): BackupSource {
|
||||||
|
return BackupSource(
|
||||||
|
name = source.name,
|
||||||
|
sourceId = source.id
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
package suwayomi.tachidesk.manga.impl.backup.proto.models
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.protobuf.ProtoNumber
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.models.Track
|
||||||
|
import suwayomi.tachidesk.manga.impl.backup.models.TrackImpl
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class BackupTracking(
|
||||||
|
// in 1.x some of these values have different types or names
|
||||||
|
// syncId is called siteId in 1,x
|
||||||
|
@ProtoNumber(1) var syncId: Int,
|
||||||
|
// LibraryId is not null in 1.x
|
||||||
|
@ProtoNumber(2) var libraryId: Long,
|
||||||
|
@ProtoNumber(3) var mediaId: Int = 0,
|
||||||
|
// trackingUrl is called mediaUrl in 1.x
|
||||||
|
@ProtoNumber(4) var trackingUrl: String = "",
|
||||||
|
@ProtoNumber(5) var title: String = "",
|
||||||
|
// lastChapterRead is called last read, and it has been changed to a float in 1.x
|
||||||
|
@ProtoNumber(6) var lastChapterRead: Float = 0F,
|
||||||
|
@ProtoNumber(7) var totalChapters: Int = 0,
|
||||||
|
@ProtoNumber(8) var score: Float = 0F,
|
||||||
|
@ProtoNumber(9) var status: Int = 0,
|
||||||
|
// startedReadingDate is called startReadTime in 1.x
|
||||||
|
@ProtoNumber(10) var startedReadingDate: Long = 0,
|
||||||
|
// finishedReadingDate is called endReadTime in 1.x
|
||||||
|
@ProtoNumber(11) var finishedReadingDate: Long = 0,
|
||||||
|
) {
|
||||||
|
fun getTrackingImpl(): TrackImpl {
|
||||||
|
return TrackImpl().apply {
|
||||||
|
sync_id = this@BackupTracking.syncId
|
||||||
|
media_id = this@BackupTracking.mediaId
|
||||||
|
library_id = this@BackupTracking.libraryId
|
||||||
|
title = this@BackupTracking.title
|
||||||
|
// convert from float to int because of 1.x types
|
||||||
|
last_chapter_read = this@BackupTracking.lastChapterRead.toInt()
|
||||||
|
total_chapters = this@BackupTracking.totalChapters
|
||||||
|
score = this@BackupTracking.score
|
||||||
|
status = this@BackupTracking.status
|
||||||
|
started_reading_date = this@BackupTracking.startedReadingDate
|
||||||
|
finished_reading_date = this@BackupTracking.finishedReadingDate
|
||||||
|
tracking_url = this@BackupTracking.trackingUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun copyFrom(track: Track): BackupTracking {
|
||||||
|
return BackupTracking(
|
||||||
|
syncId = track.sync_id,
|
||||||
|
mediaId = track.media_id,
|
||||||
|
// forced not null so its compatible with 1.x backup system
|
||||||
|
libraryId = track.library_id!!,
|
||||||
|
title = track.title,
|
||||||
|
// convert to float for 1.x
|
||||||
|
lastChapterRead = track.last_chapter_read.toFloat(),
|
||||||
|
totalChapters = track.total_chapters,
|
||||||
|
score = track.score,
|
||||||
|
status = track.status,
|
||||||
|
startedReadingDate = track.started_reading_date,
|
||||||
|
finishedReadingDate = track.finished_reading_date,
|
||||||
|
trackingUrl = track.tracking_url
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,10 +50,8 @@ object Extension {
|
|||||||
private val logger = KotlinLogging.logger {}
|
private val logger = KotlinLogging.logger {}
|
||||||
private val applicationDirs by DI.global.instance<ApplicationDirs>()
|
private val applicationDirs by DI.global.instance<ApplicationDirs>()
|
||||||
|
|
||||||
data class InstallableAPK(
|
private fun Any.isNsfw(): Boolean =
|
||||||
val apkFilePath: String,
|
this::class.annotations.any { it.toString() == "@eu.kanade.tachiyomi.annotations.Nsfw()" }
|
||||||
val pkgName: String
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun installExtension(pkgName: String): Int {
|
suspend fun installExtension(pkgName: String): Int {
|
||||||
logger.debug("Installing $pkgName")
|
logger.debug("Installing $pkgName")
|
||||||
@@ -114,7 +112,8 @@ object Extension {
|
|||||||
|
|
||||||
val isNsfw = packageInfo.applicationInfo.metaData.getString(METADATA_NSFW) == "1"
|
val isNsfw = packageInfo.applicationInfo.metaData.getString(METADATA_NSFW) == "1"
|
||||||
|
|
||||||
val className = packageInfo.packageName + packageInfo.applicationInfo.metaData.getString(METADATA_SOURCE_CLASS)
|
val className =
|
||||||
|
packageInfo.packageName + packageInfo.applicationInfo.metaData.getString(METADATA_SOURCE_CLASS)
|
||||||
|
|
||||||
logger.debug("Main class for extension is $className")
|
logger.debug("Main class for extension is $className")
|
||||||
|
|
||||||
@@ -125,10 +124,11 @@ object Extension {
|
|||||||
File(dexFilePath).delete()
|
File(dexFilePath).delete()
|
||||||
|
|
||||||
// collect sources from the extension
|
// collect sources from the extension
|
||||||
val sources: List<CatalogueSource> = when (val instance = loadExtensionSources(jarFilePath, className)) {
|
val extensionMainClassInstance = loadExtensionSources(jarFilePath, className)
|
||||||
is Source -> listOf(instance)
|
val sources: List<CatalogueSource> = when (extensionMainClassInstance) {
|
||||||
is SourceFactory -> instance.createSources()
|
is Source -> listOf(extensionMainClassInstance)
|
||||||
else -> throw RuntimeException("Unknown source class type! ${instance.javaClass}")
|
is SourceFactory -> extensionMainClassInstance.createSources()
|
||||||
|
else -> throw RuntimeException("Unknown source class type! ${extensionMainClassInstance.javaClass}")
|
||||||
}.map { it as CatalogueSource }
|
}.map { it as CatalogueSource }
|
||||||
|
|
||||||
val langs = sources.map { it.lang }.toSet()
|
val langs = sources.map { it.lang }.toSet()
|
||||||
@@ -159,7 +159,8 @@ object Extension {
|
|||||||
it[this.classFQName] = className
|
it[this.classFQName] = className
|
||||||
}
|
}
|
||||||
|
|
||||||
val extensionId = ExtensionTable.select { ExtensionTable.pkgName eq pkgName }.first()[ExtensionTable.id].value
|
val extensionId =
|
||||||
|
ExtensionTable.select { ExtensionTable.pkgName eq pkgName }.first()[ExtensionTable.id].value
|
||||||
|
|
||||||
sources.forEach { httpSource ->
|
sources.forEach { httpSource ->
|
||||||
SourceTable.insert {
|
SourceTable.insert {
|
||||||
@@ -167,8 +168,9 @@ object Extension {
|
|||||||
it[name] = httpSource.name
|
it[name] = httpSource.name
|
||||||
it[lang] = httpSource.lang
|
it[lang] = httpSource.lang
|
||||||
it[extension] = extensionId
|
it[extension] = extensionId
|
||||||
|
it[SourceTable.isNsfw] = isNsfw || extensionMainClassInstance.isNsfw()
|
||||||
}
|
}
|
||||||
logger.debug("Installed source ${httpSource.name} (${httpSource.lang}) with id:${httpSource.id}")
|
logger.debug { "Installed source ${httpSource.name} (${httpSource.lang}) with id:${httpSource.id}" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 201 // we installed successfully
|
return 201 // we installed successfully
|
||||||
@@ -234,7 +236,8 @@ object Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getExtensionIcon(apkName: String): Pair<InputStream, String> {
|
suspend fun getExtensionIcon(apkName: String): Pair<InputStream, String> {
|
||||||
val iconUrl = transaction { ExtensionTable.select { ExtensionTable.apkName eq apkName }.first() }[ExtensionTable.iconUrl]
|
val iconUrl =
|
||||||
|
transaction { ExtensionTable.select { ExtensionTable.apkName eq apkName }.first() }[ExtensionTable.iconUrl]
|
||||||
|
|
||||||
val saveDir = "${applicationDirs.extensionsRoot}/icon"
|
val saveDir = "${applicationDirs.extensionsRoot}/icon"
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ object GetHttpSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val sourceRecord = transaction {
|
val sourceRecord = transaction {
|
||||||
SourceTable.select { SourceTable.id eq sourceId }.first()
|
SourceTable.select { SourceTable.id eq sourceId }.firstOrNull()!!
|
||||||
}
|
}
|
||||||
|
|
||||||
val extensionId = sourceRecord[SourceTable.extension]
|
val extensionId = sourceRecord[SourceTable.extension]
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ object PackageTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* loads the extension main class called $className from the jar located at $jarPath
|
* loads the extension main class called [className] from the jar located at [jarPath]
|
||||||
* It may return an instance of HttpSource or SourceFactory depending on the extension.
|
* It may return an instance of HttpSource or SourceFactory depending on the extension.
|
||||||
*/
|
*/
|
||||||
fun loadExtensionSources(jarPath: String, className: String): Any {
|
fun loadExtensionSources(jarPath: String, className: String): Any {
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package suwayomi.tachidesk.manga.impl.util.lang
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import org.jetbrains.exposed.sql.Query
|
||||||
|
|
||||||
|
fun Query.isEmpty() = this.count() == 0L
|
||||||
|
|
||||||
|
fun Query.isNotEmpty() = !this.isEmpty()
|
||||||
@@ -26,9 +26,13 @@ data class MangaDataClass(
|
|||||||
val status: String = MangaStatus.UNKNOWN.name,
|
val status: String = MangaStatus.UNKNOWN.name,
|
||||||
val inLibrary: Boolean = false,
|
val inLibrary: Boolean = false,
|
||||||
val source: SourceDataClass? = null,
|
val source: SourceDataClass? = null,
|
||||||
|
|
||||||
|
/** meta data for clients */
|
||||||
val meta: Map<String, String> = emptyMap(),
|
val meta: Map<String, String> = emptyMap(),
|
||||||
|
|
||||||
val freshData: Boolean = false
|
val realUrl: String? = null,
|
||||||
|
|
||||||
|
val freshData: Boolean = false,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class PagedMangaListDataClass(
|
data class PagedMangaListDataClass(
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package suwayomi.tachidesk.manga.model.dataclass
|
package suwayomi.tachidesk.manga.model.dataclass
|
||||||
|
|
||||||
|
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) Contributors to the Suwayomi project
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
*
|
*
|
||||||
@@ -12,6 +14,13 @@ data class SourceDataClass(
|
|||||||
val name: String?,
|
val name: String?,
|
||||||
val lang: String?,
|
val lang: String?,
|
||||||
val iconUrl: String?,
|
val iconUrl: String?,
|
||||||
|
|
||||||
|
/** The Source provides a latest listing */
|
||||||
val supportsLatest: Boolean?,
|
val supportsLatest: Boolean?,
|
||||||
val isConfigurable: Boolean?
|
|
||||||
|
/** The Source implements [ConfigurableSource] */
|
||||||
|
val isConfigurable: Boolean?,
|
||||||
|
|
||||||
|
/** The Source class has a @Nsfw annotation */
|
||||||
|
val isNSFW: Boolean?,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -31,8 +31,11 @@ object MangaTable : IntIdTable() {
|
|||||||
val inLibrary = bool("in_library").default(false)
|
val inLibrary = bool("in_library").default(false)
|
||||||
val defaultCategory = bool("default_category").default(true)
|
val defaultCategory = bool("default_category").default(true)
|
||||||
|
|
||||||
// source is used by some ancestor of IntIdTable
|
// the [source] field name is used by some ancestor of IntIdTable
|
||||||
val sourceReference = long("source")
|
val sourceReference = long("source")
|
||||||
|
|
||||||
|
/** the real url of a manga used for the "open in WebView" feature */
|
||||||
|
val realUrl = varchar("real_url", 2048).nullable()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun MangaTable.toDataClass(mangaEntry: ResultRow) =
|
fun MangaTable.toDataClass(mangaEntry: ResultRow) =
|
||||||
@@ -52,7 +55,8 @@ fun MangaTable.toDataClass(mangaEntry: ResultRow) =
|
|||||||
mangaEntry[genre],
|
mangaEntry[genre],
|
||||||
Companion.valueOf(mangaEntry[status]).name,
|
Companion.valueOf(mangaEntry[status]).name,
|
||||||
mangaEntry[inLibrary],
|
mangaEntry[inLibrary],
|
||||||
meta = getMangaMetaMap(mangaEntry[id])
|
meta = getMangaMetaMap(mangaEntry[id].value),
|
||||||
|
realUrl = mangaEntry[realUrl],
|
||||||
)
|
)
|
||||||
|
|
||||||
enum class MangaStatus(val value: Int) {
|
enum class MangaStatus(val value: Int) {
|
||||||
|
|||||||
@@ -14,5 +14,5 @@ object SourceTable : IdTable<Long>() {
|
|||||||
val name = varchar("name", 128)
|
val name = varchar("name", 128)
|
||||||
val lang = varchar("lang", 10)
|
val lang = varchar("lang", 10)
|
||||||
val extension = reference("extension", ExtensionTable)
|
val extension = reference("extension", ExtensionTable)
|
||||||
val partOfFactorySource = bool("part_of_factory_source").default(false)
|
val isNsfw = bool("is_nsfw").default(false)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,31 +8,32 @@ package suwayomi.tachidesk.server
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
import com.typesafe.config.Config
|
import com.typesafe.config.Config
|
||||||
import xyz.nulldev.ts.config.ConfigModule
|
|
||||||
import xyz.nulldev.ts.config.GlobalConfigManager
|
import xyz.nulldev.ts.config.GlobalConfigManager
|
||||||
|
import xyz.nulldev.ts.config.SystemPropertyOverridableConfigModule
|
||||||
import xyz.nulldev.ts.config.debugLogsEnabled
|
import xyz.nulldev.ts.config.debugLogsEnabled
|
||||||
|
|
||||||
class ServerConfig(config: Config, moduleName: String = "") : ConfigModule(config, moduleName) {
|
private const val MODULE_NAME = "server"
|
||||||
val ip: String by overridableWithSysProperty
|
class ServerConfig(config: Config, moduleName: String = MODULE_NAME) : SystemPropertyOverridableConfigModule(config, moduleName) {
|
||||||
val port: Int by overridableWithSysProperty
|
val ip: String by overridableConfig
|
||||||
|
val port: Int by overridableConfig
|
||||||
|
|
||||||
// proxy
|
// proxy
|
||||||
val socksProxyEnabled: Boolean by overridableWithSysProperty
|
val socksProxyEnabled: Boolean by overridableConfig
|
||||||
|
|
||||||
val socksProxyHost: String by overridableWithSysProperty
|
val socksProxyHost: String by overridableConfig
|
||||||
val socksProxyPort: String by overridableWithSysProperty
|
val socksProxyPort: String by overridableConfig
|
||||||
|
|
||||||
// misc
|
// misc
|
||||||
val debugLogsEnabled: Boolean = debugLogsEnabled(GlobalConfigManager.config)
|
val debugLogsEnabled: Boolean = debugLogsEnabled(GlobalConfigManager.config)
|
||||||
val systemTrayEnabled: Boolean by overridableWithSysProperty
|
val systemTrayEnabled: Boolean by overridableConfig
|
||||||
|
|
||||||
// webUI
|
// webUI
|
||||||
val webUIEnabled: Boolean by overridableWithSysProperty
|
val webUIEnabled: Boolean by overridableConfig
|
||||||
val initialOpenInBrowserEnabled: Boolean by overridableWithSysProperty
|
val initialOpenInBrowserEnabled: Boolean by overridableConfig
|
||||||
val webUIInterface: String by overridableWithSysProperty
|
val webUIInterface: String by overridableConfig
|
||||||
val electronPath: String by overridableWithSysProperty
|
val electronPath: String by overridableConfig
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun register(config: Config) = ServerConfig(config.getConfig("server"), "server")
|
fun register(config: Config) = ServerConfig(config.getConfig(MODULE_NAME))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ fun applicationSetup() {
|
|||||||
logger.error("Exception while creating initial server.conf:\n", e)
|
logger.error("Exception while creating initial server.conf:\n", e)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fixes #119 , ref: https://github.com/Suwayomi/Tachidesk-Server/issues/119#issuecomment-894681292
|
// fixes #119 , ref: https://github.com/Suwayomi/Tachidesk-Server/issues/119#issuecomment-894681292 , source Id calculation depends on String.lowercase()
|
||||||
Locale.setDefault(Locale.ENGLISH)
|
Locale.setDefault(Locale.ENGLISH)
|
||||||
|
|
||||||
databaseUp()
|
databaseUp()
|
||||||
|
|||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
package suwayomi.tachidesk.server.database.migration
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import de.neonew.exposed.migrations.helpers.DropColumnMigration
|
||||||
|
|
||||||
|
@Suppress("ClassName", "unused")
|
||||||
|
class M0011_SourceDropPartOfFactorySource : DropColumnMigration(
|
||||||
|
"Source",
|
||||||
|
"part_of_factory_source",
|
||||||
|
)
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package suwayomi.tachidesk.server.database.migration
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import de.neonew.exposed.migrations.helpers.AddColumnMigration
|
||||||
|
|
||||||
|
@Suppress("ClassName", "unused")
|
||||||
|
class M0012_SourceIsNsfw : AddColumnMigration(
|
||||||
|
"Source",
|
||||||
|
"is_nsfw",
|
||||||
|
"BOOLEAN",
|
||||||
|
"FALSE"
|
||||||
|
)
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package suwayomi.tachidesk.server.database.migration
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import de.neonew.exposed.migrations.helpers.AddColumnMigration
|
||||||
|
|
||||||
|
@Suppress("ClassName", "unused")
|
||||||
|
class M0013_MangaRealUrl : AddColumnMigration(
|
||||||
|
"Manga",
|
||||||
|
"real_url",
|
||||||
|
"VARCHAR(2048)",
|
||||||
|
"NULL"
|
||||||
|
)
|
||||||
@@ -3,11 +3,16 @@ server.ip = "0.0.0.0"
|
|||||||
server.port = 4567
|
server.port = 4567
|
||||||
|
|
||||||
# Socks5 proxy
|
# Socks5 proxy
|
||||||
server.socksProxy = false
|
server.socksProxyEnabled = false
|
||||||
server.socksProxyHost = ""
|
server.socksProxyHost = ""
|
||||||
server.socksProxyPort = ""
|
server.socksProxyPort = ""
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
server.debugLogsEnabled = true
|
server.debugLogsEnabled = true
|
||||||
server.systemTrayEnabled = false
|
server.systemTrayEnabled = false
|
||||||
|
|
||||||
|
# webUI
|
||||||
|
server.webUIEnabled = true
|
||||||
server.initialOpenInBrowserEnabled = true
|
server.initialOpenInBrowserEnabled = true
|
||||||
|
server.webUIInterface = "browser" # "browser" or "electron"
|
||||||
|
server.electronPath = ""
|
||||||
|
|||||||
Reference in New Issue
Block a user