mirror of https://github.com/readrops/Readrops.git
Update kotlin-xml-builder dependency
This commit is contained in:
parent
47b40ac0eb
commit
783276a27b
|
@ -4,42 +4,54 @@ import com.gitlab.mvysny.konsumexml.konsumeXml
|
|||
import com.readrops.api.utils.exceptions.ParseException
|
||||
import com.readrops.db.entities.Feed
|
||||
import com.readrops.db.entities.Folder
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.redundent.kotlin.xml.xml
|
||||
import java.io.InputStream
|
||||
import java.io.OutputStream
|
||||
|
||||
object OPMLParser {
|
||||
|
||||
suspend fun read(stream: InputStream): Map<Folder?, List<Feed>> {
|
||||
suspend fun read(stream: InputStream): Map<Folder?, List<Feed>> = withContext(Dispatchers.IO) {
|
||||
try {
|
||||
val adapter = OPMLAdapter()
|
||||
val opml = adapter.fromXml(stream.konsumeXml())
|
||||
|
||||
stream.close()
|
||||
return opml
|
||||
opml
|
||||
} catch (e: Exception) {
|
||||
throw ParseException(e.message)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun write(foldersAndFeeds: Map<Folder?, List<Feed>>, outputStream: OutputStream) {
|
||||
val opml = xml("opml") {
|
||||
attribute("version", "2.0")
|
||||
suspend fun write(foldersAndFeeds: Map<Folder?, List<Feed>>, outputStream: OutputStream) =
|
||||
withContext(Dispatchers.IO) {
|
||||
val opml = xml("opml") {
|
||||
attribute("version", "2.0")
|
||||
|
||||
"head" {
|
||||
-"Subscriptions"
|
||||
}
|
||||
"head" {
|
||||
-"Subscriptions"
|
||||
}
|
||||
|
||||
"body" {
|
||||
for (folderAndFeeds in foldersAndFeeds) {
|
||||
if (folderAndFeeds.key != null) { // feeds with folder
|
||||
"outline" {
|
||||
folderAndFeeds.key?.name?.let {
|
||||
attribute("title", it)
|
||||
attribute("text", it)
|
||||
"body" {
|
||||
for (folderAndFeeds in foldersAndFeeds) {
|
||||
if (folderAndFeeds.key != null) { // feeds with folder
|
||||
"outline" {
|
||||
folderAndFeeds.key?.name?.let {
|
||||
attribute("title", it)
|
||||
attribute("text", it)
|
||||
}
|
||||
|
||||
for (feed in folderAndFeeds.value) {
|
||||
"outline" {
|
||||
feed.name?.let { attribute("title", it) }
|
||||
attribute("xmlUrl", feed.url!!)
|
||||
feed.siteUrl?.let { attribute("htmlUrl", it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (feed in folderAndFeeds.value) {
|
||||
} else {
|
||||
for (feed in folderAndFeeds.value) { // feeds without folder
|
||||
"outline" {
|
||||
feed.name?.let { attribute("title", it) }
|
||||
attribute("xmlUrl", feed.url!!)
|
||||
|
@ -47,21 +59,12 @@ object OPMLParser {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (feed in folderAndFeeds.value) { // feeds without folder
|
||||
"outline" {
|
||||
feed.name?.let { attribute("title", it) }
|
||||
attribute("xmlUrl", feed.url!!)
|
||||
feed.siteUrl?.let { attribute("htmlUrl", it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outputStream.write(opml.toString().toByteArray())
|
||||
outputStream.flush()
|
||||
outputStream.close()
|
||||
}
|
||||
outputStream.write(opml.toString().toByteArray())
|
||||
outputStream.flush()
|
||||
outputStream.close()
|
||||
}
|
||||
}
|
|
@ -80,7 +80,7 @@ aboutlibraries = { module = "com.mikepenz.aboutlibraries.plugin:aboutlibraries-p
|
|||
aboutlibraries-composem3 = { module = "com.mikepenz:aboutlibraries-compose-m3", version.ref = "about_libraries" }
|
||||
|
||||
konsumexml = "com.gitlab.mvysny.konsume-xml:konsume-xml:1.1"
|
||||
kotlinxmlbuilder = "org.redundent:kotlin-xml-builder:1.7.3" #TODO update this
|
||||
kotlinxmlbuilder = "org.redundent:kotlin-xml-builder:1.9.1"
|
||||
|
||||
jdk-desugar = "com.android.tools:desugar_jdk_libs_nio:2.1.2"
|
||||
|
||||
|
|
Loading…
Reference in New Issue