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,14 +141,12 @@ object RepositoryManager {
|
|||
}
|
||||
} else if (fixedUrl.matches("^[a-zA-Z0-9!_-]+$".toRegex())) {
|
||||
safeAsync {
|
||||
app.get("https://cutt.ly/${fixedUrl}", allowRedirects = false).let { it2 ->
|
||||
it2.headers["Location"]?.let { url ->
|
||||
val response = app.get("https://cutt.ly/${fixedUrl}", allowRedirects = false)
|
||||
val url = response.headers["Location"] ?: return@safeAsync null
|
||||
if (url.startsWith("https://cutt.ly/404")) return@safeAsync null
|
||||
if (url.removeSuffix("/") == "https://cutt.ly") return@safeAsync null
|
||||
return@safeAsync url
|
||||
}
|
||||
}
|
||||
}
|
||||
} else null
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -278,13 +278,16 @@ class ExtensionsFragment : BaseFragment<FragmentExtensionsBinding>(
|
|||
binding.applyBtt.setOnClickListener secondListener@{
|
||||
val name = binding.repoNameInput.text?.toString()
|
||||
val urlInput = binding.repoUrlInput.text?.toString()
|
||||
ioSafe {
|
||||
val url = urlInput?.let { it1 -> RepositoryManager.parseRepoUrl(it1) }
|
||||
if (url.isNullOrBlank()) {
|
||||
main {
|
||||
showToast(R.string.error_invalid_data, Toast.LENGTH_SHORT)
|
||||
if (urlInput.isNullOrEmpty()) {
|
||||
showToast(R.string.error_invalid_url, Toast.LENGTH_SHORT)
|
||||
return@secondListener
|
||||
}
|
||||
ioSafe {
|
||||
val url = RepositoryManager.parseRepoUrl(urlInput)
|
||||
if (url.isNullOrBlank()) {
|
||||
showToast(R.string.error_invalid_data, Toast.LENGTH_SHORT)
|
||||
return@ioSafe
|
||||
}
|
||||
} else {
|
||||
val repository = RepositoryManager.parseRepository(url)
|
||||
|
||||
// Exit if wrong repository
|
||||
|
|
@ -300,18 +303,19 @@ class ExtensionsFragment : BaseFragment<FragmentExtensionsBinding>(
|
|||
extensionViewModel.loadStats()
|
||||
extensionViewModel.loadRepositories()
|
||||
|
||||
dialog.dismissSafe(activity) // Only dismiss if the repo was added
|
||||
|
||||
val plugins = RepositoryManager.getRepoPlugins(newRepo)
|
||||
if (plugins.isNullOrEmpty()) {
|
||||
showToast(R.string.no_plugins_found_error, Toast.LENGTH_LONG)
|
||||
} else {
|
||||
return@ioSafe
|
||||
}
|
||||
|
||||
this@ExtensionsFragment.activity?.addRepositoryDialog(
|
||||
newRepo
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
dialog.dismissSafe(activity)
|
||||
}
|
||||
binding.cancelBtt.setOnClickListener {
|
||||
dialog.dismissSafe(activity)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue