From 480f571f1343038ae2ea3191c9e0ac0c3a0f5884 Mon Sep 17 00:00:00 2001 From: Claudemirovsky <63046606+Claudemirovsky@users.noreply.github.com> Date: Wed, 14 Feb 2024 07:41:12 -0300 Subject: [PATCH 1/3] fix(inspector): Add forgotten class - Fixes crash with jellyfin --- .../eu/kanade/tachiyomi/animesource/UnmeteredSource.kt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 inspector/src/main/kotlin/eu/kanade/tachiyomi/animesource/UnmeteredSource.kt diff --git a/inspector/src/main/kotlin/eu/kanade/tachiyomi/animesource/UnmeteredSource.kt b/inspector/src/main/kotlin/eu/kanade/tachiyomi/animesource/UnmeteredSource.kt new file mode 100644 index 0000000..840a223 --- /dev/null +++ b/inspector/src/main/kotlin/eu/kanade/tachiyomi/animesource/UnmeteredSource.kt @@ -0,0 +1,8 @@ +package eu.kanade.tachiyomi.animesource + +/** + * A source that explicitly doesn't require traffic considerations. + * + * This typically applies for self-hosted sources. + */ +interface UnmeteredSource From 301d842d626018f3b439843ef791e2c177415669 Mon Sep 17 00:00:00 2001 From: Claudemirovsky <63046606+Claudemirovsky@users.noreply.github.com> Date: Wed, 14 Feb 2024 08:00:47 -0300 Subject: [PATCH 2/3] feat(inspector): Inspect extensions in parallel --- inspector/src/main/kotlin/inspector/Main.kt | 17 ++++++++++++----- .../kotlin/inspector/util/AnimeExtension.kt | 2 +- .../main/kotlin/inspector/util/PackageTools.kt | 5 ++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/inspector/src/main/kotlin/inspector/Main.kt b/inspector/src/main/kotlin/inspector/Main.kt index 55be0e5..03cd558 100644 --- a/inspector/src/main/kotlin/inspector/Main.kt +++ b/inspector/src/main/kotlin/inspector/Main.kt @@ -12,6 +12,9 @@ import eu.kanade.tachiyomi.App import eu.kanade.tachiyomi.animesource.online.AnimeHttpSource import inspector.util.AnimeExtension import io.github.oshai.kotlinlogging.KotlinLogging +import kotlinx.coroutines.async +import kotlinx.coroutines.awaitAll +import kotlinx.coroutines.coroutineScope import kotlinx.serialization.Serializable import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json @@ -47,11 +50,15 @@ suspend fun main(args: Array) { logger.info { "Found ${extensions.size} extensions" } - val extensionsInfo = extensions.associate { - logger.debug { "Installing $it" } - val (pkgName, sources) = AnimeExtension.installApk(tmpDir) { it.toFile() } - pkgName to sources.map(::SourceJson) - } + val extensionsInfo = coroutineScope { + extensions.map { + async { + logger.debug { "Installing $it" } + val (pkgName, sources) = AnimeExtension.installApk(tmpDir) { it.toFile() } + pkgName to sources.map(::SourceJson) + } + }.awaitAll() + }.toMap() File(outputPath).writeText(Json.encodeToString(extensionsInfo)) } diff --git a/inspector/src/main/kotlin/inspector/util/AnimeExtension.kt b/inspector/src/main/kotlin/inspector/util/AnimeExtension.kt index 55a27b2..7504759 100644 --- a/inspector/src/main/kotlin/inspector/util/AnimeExtension.kt +++ b/inspector/src/main/kotlin/inspector/util/AnimeExtension.kt @@ -57,7 +57,7 @@ object AnimeExtension { dex2jar(apkFile, jarFile) // collect sources from the extension - return packageInfo.packageName to when (val instance = loadExtensionSources(jarFile.absolutePath, className)) { + return packageInfo.packageName to when (val instance = loadExtensionSources(jarFile, className)) { is AnimeSource -> listOf(instance).filterIsInstance() is AnimeSourceFactory -> instance.createSources().filterIsInstance() else -> throw RuntimeException("Unknown source class type! ${instance.javaClass}") diff --git a/inspector/src/main/kotlin/inspector/util/PackageTools.kt b/inspector/src/main/kotlin/inspector/util/PackageTools.kt index 198932e..afa38a4 100644 --- a/inspector/src/main/kotlin/inspector/util/PackageTools.kt +++ b/inspector/src/main/kotlin/inspector/util/PackageTools.kt @@ -21,7 +21,6 @@ import org.w3c.dom.Node import xyz.nulldev.androidcompat.pm.InstalledPackage.Companion.toList import xyz.nulldev.androidcompat.pm.toPackageInfo import java.io.File -import java.net.URL import java.net.URLClassLoader import java.nio.file.Files import javax.xml.parsers.DocumentBuilderFactory @@ -107,8 +106,8 @@ object PackageTools { * loads the extension main class called $className from the jar located at $jarPath * It may return an instance of AnimeHttpSource or AnimeSourceFactory depending on the extension. */ - fun loadExtensionSources(jarPath: String, className: String): Any { - val classLoader = URLClassLoader(arrayOf(URL("file:$jarPath"))) + fun loadExtensionSources(jarFile: File, className: String): Any { + val classLoader = URLClassLoader(arrayOf(jarFile.toURI().toURL())) val classToLoad = Class.forName(className, false, classLoader) return classToLoad.getDeclaredConstructor().newInstance() } From 7cf1569359c0907d1a0a4f818d2cedf4ac7d87d8 Mon Sep 17 00:00:00 2001 From: Claudemirovsky <63046606+Claudemirovsky@users.noreply.github.com> Date: Wed, 14 Feb 2024 08:04:46 -0300 Subject: [PATCH 3/3] chore: Bump version --- inspector/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inspector/build.gradle.kts b/inspector/build.gradle.kts index 20c9004..8555d25 100644 --- a/inspector/build.gradle.kts +++ b/inspector/build.gradle.kts @@ -40,7 +40,7 @@ sourceSets { } // should be bumped with each stable release -val inspectorVersion = "v1.4.3" +val inspectorVersion = "v1.4.4" // counts commit count on master val inspectorRevision = runCatching {