|
@@ -90,13 +90,14 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
|
|
|
val mText = text.trim()
|
|
val mText = text.trim()
|
|
|
when {
|
|
when {
|
|
|
mText.isJsonObject() -> {
|
|
mText.isJsonObject() -> {
|
|
|
- val json = JsonPath.parse(mText)
|
|
|
|
|
- val urls = json.read<List<String>>("$.sourceUrls")
|
|
|
|
|
- if (!urls.isNullOrEmpty()) {
|
|
|
|
|
- urls.forEach {
|
|
|
|
|
|
|
+ kotlin.runCatching {
|
|
|
|
|
+ val json = JsonPath.parse(mText)
|
|
|
|
|
+ json.read<List<String>>("$.sourceUrls")
|
|
|
|
|
+ }.onSuccess {
|
|
|
|
|
+ it.forEach {
|
|
|
importSourceUrl(it)
|
|
importSourceUrl(it)
|
|
|
}
|
|
}
|
|
|
- } else {
|
|
|
|
|
|
|
+ }.onFailure {
|
|
|
BookSource.fromJson(mText).getOrThrow().let {
|
|
BookSource.fromJson(mText).getOrThrow().let {
|
|
|
allSources.add(it)
|
|
allSources.add(it)
|
|
|
}
|
|
}
|