Skip to content

Commit

Permalink
Added support for codeberg
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacekun authored and C10udburst committed Jul 8, 2023
1 parent 5d21ca0 commit 68db721
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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%")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -106,4 +113,4 @@ fun ExtensionContainer.getCloudstream(): CloudstreamExtension {

fun ExtensionContainer.findCloudstream(): CloudstreamExtension? {
return findByName("cloudstream") as CloudstreamExtension?
}
}

0 comments on commit 68db721

Please sign in to comment.