mirror of
https://github.com/recloudstream/cloudstream.git
synced 2026-07-13 00:13:17 +00:00
Compare commits
1 commit
master
...
fix-repo-d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9290cec8ea |
2 changed files with 37 additions and 35 deletions
|
|
@ -141,13 +141,11 @@ object RepositoryManager {
|
||||||
}
|
}
|
||||||
} else if (fixedUrl.matches("^[a-zA-Z0-9!_-]+$".toRegex())) {
|
} else if (fixedUrl.matches("^[a-zA-Z0-9!_-]+$".toRegex())) {
|
||||||
safeAsync {
|
safeAsync {
|
||||||
app.get("https://cutt.ly/${fixedUrl}", allowRedirects = false).let { it2 ->
|
val response = app.get("https://cutt.ly/${fixedUrl}", allowRedirects = false)
|
||||||
it2.headers["Location"]?.let { url ->
|
val url = response.headers["Location"] ?: return@safeAsync null
|
||||||
if (url.startsWith("https://cutt.ly/404")) return@safeAsync null
|
if (url.startsWith("https://cutt.ly/404")) return@safeAsync null
|
||||||
if (url.removeSuffix("/") == "https://cutt.ly") return@safeAsync null
|
if (url.removeSuffix("/") == "https://cutt.ly") return@safeAsync null
|
||||||
return@safeAsync url
|
return@safeAsync url
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else null
|
} else null
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -275,42 +275,46 @@ class ExtensionsFragment : BaseFragment<FragmentExtensionsBinding>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.applyBtt.setOnClickListener secondListener@{
|
binding.applyBtt.setOnClickListener secondListener@{
|
||||||
val name = binding.repoNameInput.text?.toString()
|
val name = binding.repoNameInput.text?.toString()
|
||||||
val urlInput = binding.repoUrlInput.text?.toString()
|
val urlInput = binding.repoUrlInput.text?.toString()
|
||||||
ioSafe {
|
if (urlInput.isNullOrEmpty()) {
|
||||||
val url = urlInput?.let { it1 -> RepositoryManager.parseRepoUrl(it1) }
|
showToast(R.string.error_invalid_url, Toast.LENGTH_SHORT)
|
||||||
if (url.isNullOrBlank()) {
|
return@secondListener
|
||||||
main {
|
}
|
||||||
showToast(R.string.error_invalid_data, Toast.LENGTH_SHORT)
|
ioSafe {
|
||||||
}
|
val url = RepositoryManager.parseRepoUrl(urlInput)
|
||||||
} else {
|
if (url.isNullOrBlank()) {
|
||||||
val repository = RepositoryManager.parseRepository(url)
|
showToast(R.string.error_invalid_data, Toast.LENGTH_SHORT)
|
||||||
|
return@ioSafe
|
||||||
// Exit if wrong repository
|
}
|
||||||
if (repository == null) {
|
val repository = RepositoryManager.parseRepository(url)
|
||||||
showToast(R.string.no_repository_found_error, Toast.LENGTH_LONG)
|
|
||||||
return@ioSafe
|
// Exit if wrong repository
|
||||||
}
|
if (repository == null) {
|
||||||
|
showToast(R.string.no_repository_found_error, Toast.LENGTH_LONG)
|
||||||
val fixedName = if (!name.isNullOrBlank()) name
|
return@ioSafe
|
||||||
else repository.name
|
}
|
||||||
val newRepo = RepositoryData(repository.iconUrl, fixedName, url)
|
|
||||||
RepositoryManager.addRepository(newRepo)
|
val fixedName = if (!name.isNullOrBlank()) name
|
||||||
extensionViewModel.loadStats()
|
else repository.name
|
||||||
extensionViewModel.loadRepositories()
|
val newRepo = RepositoryData(repository.iconUrl, fixedName, url)
|
||||||
|
RepositoryManager.addRepository(newRepo)
|
||||||
val plugins = RepositoryManager.getRepoPlugins(newRepo)
|
extensionViewModel.loadStats()
|
||||||
if (plugins.isNullOrEmpty()) {
|
extensionViewModel.loadRepositories()
|
||||||
showToast(R.string.no_plugins_found_error, Toast.LENGTH_LONG)
|
|
||||||
} else {
|
dialog.dismissSafe(activity) // Only dismiss if the repo was added
|
||||||
this@ExtensionsFragment.activity?.addRepositoryDialog(
|
|
||||||
newRepo
|
val plugins = RepositoryManager.getRepoPlugins(newRepo)
|
||||||
)
|
if (plugins.isNullOrEmpty()) {
|
||||||
}
|
showToast(R.string.no_plugins_found_error, Toast.LENGTH_LONG)
|
||||||
}
|
return@ioSafe
|
||||||
|
}
|
||||||
|
|
||||||
|
this@ExtensionsFragment.activity?.addRepositoryDialog(
|
||||||
|
newRepo
|
||||||
|
)
|
||||||
}
|
}
|
||||||
dialog.dismissSafe(activity)
|
|
||||||
}
|
}
|
||||||
binding.cancelBtt.setOnClickListener {
|
binding.cancelBtt.setOnClickListener {
|
||||||
dialog.dismissSafe(activity)
|
dialog.dismissSafe(activity)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue