diff --git a/shared/src/androidMain/kotlin/net/underdesk/circolapp/shared/server/porporato/SpecificPorporatoServer.kt b/shared/src/androidMain/kotlin/net/underdesk/circolapp/shared/server/porporato/SpecificPorporatoServer.kt index dfa3f38..16e74f5 100644 --- a/shared/src/androidMain/kotlin/net/underdesk/circolapp/shared/server/porporato/SpecificPorporatoServer.kt +++ b/shared/src/androidMain/kotlin/net/underdesk/circolapp/shared/server/porporato/SpecificPorporatoServer.kt @@ -31,13 +31,15 @@ actual class SpecificPorporatoServer actual constructor(private val porporatoSer val list = ArrayList() for (i in 0 until htmlList.size) { - list.add( - porporatoServer.generateFromString( - htmlList[i].text(), - htmlList[i].attr("href"), - i.toLong() + porporatoServer.generateFromString( + htmlList[i].text(), + htmlList[i].attr("href"), + i.toLong() + )?.let { + list.add( + it ) - ) + } } return list diff --git a/shared/src/commonMain/kotlin/net/underdesk/circolapp/shared/server/curie/CurieServer.kt b/shared/src/commonMain/kotlin/net/underdesk/circolapp/shared/server/curie/CurieServer.kt index 70b1e89..254cb06 100644 --- a/shared/src/commonMain/kotlin/net/underdesk/circolapp/shared/server/curie/CurieServer.kt +++ b/shared/src/commonMain/kotlin/net/underdesk/circolapp/shared/server/curie/CurieServer.kt @@ -67,7 +67,6 @@ class CurieServer(ktorClient: HttpClient) : Server(ktorClient) { return Pair(true, ServerAPI.Companion.Result.SUCCESS) } - @OptIn(ExperimentalStdlibApi::class) @Throws(IOException::class, CancellationException::class) private suspend fun retrieveDataFromServer(): Response { return ktorClient.get(ENDPOINT_URL) diff --git a/shared/src/commonMain/kotlin/net/underdesk/circolapp/shared/server/porporato/PorporatoServer.kt b/shared/src/commonMain/kotlin/net/underdesk/circolapp/shared/server/porporato/PorporatoServer.kt index 8324155..6397d97 100644 --- a/shared/src/commonMain/kotlin/net/underdesk/circolapp/shared/server/porporato/PorporatoServer.kt +++ b/shared/src/commonMain/kotlin/net/underdesk/circolapp/shared/server/porporato/PorporatoServer.kt @@ -75,7 +75,6 @@ class PorporatoServer(ktorClient: HttpClient) : Server(ktorClient) { return Pair(true, ServerAPI.Companion.Result.SUCCESS) } - @OptIn(ExperimentalStdlibApi::class) @Throws(IOException::class, CancellationException::class) private suspend fun parsePage(url: String): List { val response = retrieveDataFromServer(url) @@ -120,13 +119,12 @@ class PorporatoServer(ktorClient: HttpClient) : Server(ktorClient) { } } - @OptIn(ExperimentalStdlibApi::class) @Throws(IOException::class, CancellationException::class) private suspend fun retrieveDataFromServer(url: String): String { return ktorClient.request(url).readText(Charsets.ISO_8859_1) } - fun generateFromString(string: String, path: String, index: Long): Circular { + fun generateFromString(string: String, path: String, index: Long): Circular? { val fullUrl = baseUrl + path var title = string @@ -152,7 +150,7 @@ class PorporatoServer(ktorClient: HttpClient) : Server(ktorClient) { title = title.removeRange(dateMatcher.range) .removeSuffix(" (pubb.: )") - Circular(id, serverID, title, fullUrl, fullUrl, dateMatcher.value.replace("-", "/")) + if (title != "") Circular(id, serverID, title, fullUrl, fullUrl, dateMatcher.value.replace("-", "/")) else null } else { Circular(id, serverID, title, fullUrl, fullUrl, "") } diff --git a/shared/src/commonMain/kotlin/net/underdesk/circolapp/shared/server/prever/GenericPreverServer.kt b/shared/src/commonMain/kotlin/net/underdesk/circolapp/shared/server/prever/GenericPreverServer.kt index 92bfaeb..a1dd10b 100644 --- a/shared/src/commonMain/kotlin/net/underdesk/circolapp/shared/server/prever/GenericPreverServer.kt +++ b/shared/src/commonMain/kotlin/net/underdesk/circolapp/shared/server/prever/GenericPreverServer.kt @@ -59,7 +59,6 @@ abstract class GenericPreverServer(ktorClient: HttpClient) : Server(ktorClient) } } - @OptIn(ExperimentalStdlibApi::class) @Throws(IOException::class, CancellationException::class) private suspend fun parsePage(page: Int): List { val posts = retrievePageFromServer(page) @@ -83,7 +82,6 @@ abstract class GenericPreverServer(ktorClient: HttpClient) : Server(ktorClient) return Pair(true, ServerAPI.Companion.Result.SUCCESS) } - @OptIn(ExperimentalStdlibApi::class) @Throws(IOException::class, CancellationException::class) private suspend fun retrievePageFromServer(page: Int): List { return try { diff --git a/shared/src/iosMain/kotlin/net/underdesk/circolapp/shared/server/porporato/SpecificPorporatoServer.kt b/shared/src/iosMain/kotlin/net/underdesk/circolapp/shared/server/porporato/SpecificPorporatoServer.kt index 056b012..e254e50 100644 --- a/shared/src/iosMain/kotlin/net/underdesk/circolapp/shared/server/porporato/SpecificPorporatoServer.kt +++ b/shared/src/iosMain/kotlin/net/underdesk/circolapp/shared/server/porporato/SpecificPorporatoServer.kt @@ -35,13 +35,15 @@ actual class SpecificPorporatoServer actual constructor(private val porporatoSer return list for (i in htmlList.indices) { - list.add( - porporatoServer.generateFromString( - htmlList[i].textContent, - htmlList[i].attributes.objectForKey("href").toString(), - i.toLong() + porporatoServer.generateFromString( + htmlList[i].textContent, + htmlList[i].attributes.objectForKey("href").toString(), + i.toLong() + )?.let { + list.add( + it ) - ) + } } return list