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())) {
|
||||
safeAsync {
|
||||
app.get("https://cutt.ly/${fixedUrl}", allowRedirects = false).let { it2 ->
|
||||
it2.headers["Location"]?.let { url ->
|
||||
if (url.startsWith("https://cutt.ly/404")) return@safeAsync null
|
||||
if (url.removeSuffix("/") == "https://cutt.ly") return@safeAsync null
|
||||
return@safeAsync 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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -275,42 +275,46 @@ class ExtensionsFragment : BaseFragment<FragmentExtensionsBinding>(
|
|||
}
|
||||
}
|
||||
|
||||
binding.applyBtt.setOnClickListener secondListener@{
|
||||
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)
|
||||
}
|
||||
} else {
|
||||
val repository = RepositoryManager.parseRepository(url)
|
||||
|
||||
// Exit if wrong repository
|
||||
if (repository == null) {
|
||||
showToast(R.string.no_repository_found_error, Toast.LENGTH_LONG)
|
||||
return@ioSafe
|
||||
}
|
||||
|
||||
val fixedName = if (!name.isNullOrBlank()) name
|
||||
else repository.name
|
||||
val newRepo = RepositoryData(repository.iconUrl, fixedName, url)
|
||||
RepositoryManager.addRepository(newRepo)
|
||||
extensionViewModel.loadStats()
|
||||
extensionViewModel.loadRepositories()
|
||||
|
||||
val plugins = RepositoryManager.getRepoPlugins(newRepo)
|
||||
if (plugins.isNullOrEmpty()) {
|
||||
showToast(R.string.no_plugins_found_error, Toast.LENGTH_LONG)
|
||||
} else {
|
||||
this@ExtensionsFragment.activity?.addRepositoryDialog(
|
||||
newRepo
|
||||
)
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
val repository = RepositoryManager.parseRepository(url)
|
||||
|
||||
// Exit if wrong repository
|
||||
if (repository == null) {
|
||||
showToast(R.string.no_repository_found_error, Toast.LENGTH_LONG)
|
||||
return@ioSafe
|
||||
}
|
||||
|
||||
val fixedName = if (!name.isNullOrBlank()) name
|
||||
else repository.name
|
||||
val newRepo = RepositoryData(repository.iconUrl, fixedName, url)
|
||||
RepositoryManager.addRepository(newRepo)
|
||||
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)
|
||||
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