diff --git a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt index 93cc32bc0..248a78276 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt @@ -90,13 +90,14 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) { val mText = text.trim() when { mText.isJsonObject() -> { - val json = JsonPath.parse(mText) - val urls = json.read>("$.sourceUrls") - if (!urls.isNullOrEmpty()) { - urls.forEach { + kotlin.runCatching { + val json = JsonPath.parse(mText) + json.read>("$.sourceUrls") + }.onSuccess { + it.forEach { importSourceUrl(it) } - } else { + }.onFailure { BookSource.fromJson(mText).getOrThrow().let { allSources.add(it) }