From a52375b3461bbb03435a47f7c69434689855852e Mon Sep 17 00:00:00 2001 From: Cloudburst <18114966+C10udburst@users.noreply.github.com> Date: Wed, 31 Aug 2022 10:26:20 +0200 Subject: [PATCH] fix url stuff --- .../gradle/CloudstreamExtension.kt | 31 ++++++++++--------- .../lagradost/cloudstream3/gradle/Utils.kt | 2 +- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/main/kotlin/com/lagradost/cloudstream3/gradle/CloudstreamExtension.kt b/src/main/kotlin/com/lagradost/cloudstream3/gradle/CloudstreamExtension.kt index a0ff01b..dc65362 100644 --- a/src/main/kotlin/com/lagradost/cloudstream3/gradle/CloudstreamExtension.kt +++ b/src/main/kotlin/com/lagradost/cloudstream3/gradle/CloudstreamExtension.kt @@ -16,6 +16,8 @@ abstract class CloudstreamExtension @Inject constructor(project: Project) { var repository: Repo? = null internal set + + var buildBranch: String = "builds" fun overrideUrlPrefix(url: String) { if (apkinfo == null) { @@ -43,31 +45,32 @@ abstract class CloudstreamExtension @Inject constructor(project: Project) { } } fun setRepo(url: String) { - when { - url.startsWith("https://github.com") -> { - val split = url + var type: String? = null + + var split = when { + url.startsWith("https://github.com") -> { + type = "github" + url .removePrefix("https://") .removePrefix("github.com") - .removeSurrounding("/") - .split("/") - setRepo(split[0], split[1], "github") } url.startsWith("https://gitlab.com") -> { - val split = url + type = "gitlab" + url .removePrefix("https://") .removePrefix("gitlab.com") - .removeSurrounding("/") - .split("/") - setRepo(split[0], split[1], "gitlab") } !url.startsWith("https://") -> { // assume default as github - val split = url - .removeSurrounding("/") - .split("/") - setRepo(split[0], split[1], "github") + type = "github" + url } else -> throw IllegalArgumentException("Unknown domain, please set repository via setRepo(user, repo, type)") } + .removePrefix("/") + .removeSuffix("/") + .split("/") + + setRepo(split[0], split[1], type) } internal var pluginClassName: String? = null diff --git a/src/main/kotlin/com/lagradost/cloudstream3/gradle/Utils.kt b/src/main/kotlin/com/lagradost/cloudstream3/gradle/Utils.kt index 30829e1..f4ed1b2 100644 --- a/src/main/kotlin/com/lagradost/cloudstream3/gradle/Utils.kt +++ b/src/main/kotlin/com/lagradost/cloudstream3/gradle/Utils.kt @@ -36,7 +36,7 @@ fun Project.makePluginEntry(): PluginEntry { val repo = extension.repository return PluginEntry( - url = (if (repo == null) "" else repo.getRawLink("${this.name}.cs3", "builds")), + url = (if (repo == null) "" else repo.getRawLink("${this.name}.cs3", extension.buildBranch)), status = extension.status, version = version ?: -1, name = this.name,