Added support for codeberg

This commit is contained in:
Jace 2023-07-07 14:39:12 +08:00 committed by Cloudburst
parent 5d21ca00d5
commit 68db7215ec

View file

@ -33,6 +33,7 @@ abstract class CloudstreamExtension @Inject constructor(project: Project) {
when {
type == "github" -> setRepo(user, repo, "https://github.com/${user}/${repo}", "https://raw.githubusercontent.com/${user}/${repo}/%branch%/%filename%")
type == "gitlab" -> setRepo(user, repo, "https://gitlab.com/${user}/${repo}", "https://gitlab.com/${user}/${repo}/-/raw/%branch%/%filename%")
type == "codeberg" -> setRepo(user, repo, "https://codeberg.org/${user}/${repo}", "https://codeberg.org/${user}/${repo}/raw/branch/%branch%/%filename%")
type.startsWith("gitlab-") -> {
val domain = type.removePrefix("gitlab-")
setRepo(user, repo, "https://${domain}/${user}/${repo}", "https://${domain}/${user}/${repo}/-/raw/%branch%/%filename%")
@ -60,6 +61,12 @@ abstract class CloudstreamExtension @Inject constructor(project: Project) {
.removePrefix("https://")
.removePrefix("gitlab.com")
}
url.startsWith("https://codeberg.org") -> {
type = "codeberg"
url
.removePrefix("https://")
.removePrefix("codeberg.org")
}
!url.startsWith("https://") -> { // assume default as github
type = "github"
url
@ -106,4 +113,4 @@ fun ExtensionContainer.getCloudstream(): CloudstreamExtension {
fun ExtensionContainer.findCloudstream(): CloudstreamExtension? {
return findByName("cloudstream") as CloudstreamExtension?
}
}