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