mirror of
https://git.mihon.tech/mihonapp/mihon
synced 2024-11-24 14:15:54 +03:00
parent
76dcf90340
commit
22d8aad598
3 changed files with 9 additions and 9 deletions
|
@ -19,6 +19,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
|
||||||
|
|
||||||
### Improved
|
### Improved
|
||||||
- Bangumi search now shows the score and summary of a search result ([@MajorTanya](https://github.com/MajorTanya)) ([#1396](https://github.com/mihonapp/mihon/pull/1396))
|
- Bangumi search now shows the score and summary of a search result ([@MajorTanya](https://github.com/MajorTanya)) ([#1396](https://github.com/mihonapp/mihon/pull/1396))
|
||||||
|
- Extension repo URLs are now auto-formatted ([@AntsyLich](https://github.com/AntsyLich), [@MajorTanya](https://github.com/MajorTanya))
|
||||||
|
|
||||||
## [v0.17.0] - 2024-10-26
|
## [v0.17.0] - 2024-10-26
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -5,6 +5,7 @@ import mihon.domain.extensionrepo.exception.SaveExtensionRepoException
|
||||||
import mihon.domain.extensionrepo.model.ExtensionRepo
|
import mihon.domain.extensionrepo.model.ExtensionRepo
|
||||||
import mihon.domain.extensionrepo.repository.ExtensionRepoRepository
|
import mihon.domain.extensionrepo.repository.ExtensionRepoRepository
|
||||||
import mihon.domain.extensionrepo.service.ExtensionRepoService
|
import mihon.domain.extensionrepo.service.ExtensionRepoService
|
||||||
|
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||||
import tachiyomi.core.common.util.system.logcat
|
import tachiyomi.core.common.util.system.logcat
|
||||||
|
|
||||||
class CreateExtensionRepo(
|
class CreateExtensionRepo(
|
||||||
|
@ -13,12 +14,13 @@ class CreateExtensionRepo(
|
||||||
) {
|
) {
|
||||||
private val repoRegex = """^https://.*/index\.min\.json$""".toRegex()
|
private val repoRegex = """^https://.*/index\.min\.json$""".toRegex()
|
||||||
|
|
||||||
suspend fun await(repoUrl: String): Result {
|
suspend fun await(indexUrl: String): Result {
|
||||||
if (!repoUrl.matches(repoRegex)) {
|
val formattedIndexUrl = indexUrl.toHttpUrlOrNull()
|
||||||
return Result.InvalidUrl
|
?.toString()
|
||||||
}
|
?.takeIf { it.matches(repoRegex) }
|
||||||
|
?: return Result.InvalidUrl
|
||||||
|
|
||||||
val baseUrl = repoUrl.removeSuffix("/index.min.json")
|
val baseUrl = formattedIndexUrl.removeSuffix("/index.min.json")
|
||||||
return service.fetchRepoDetails(baseUrl)?.let { insert(it) } ?: Result.InvalidUrl
|
return service.fetchRepoDetails(baseUrl)?.let { insert(it) } ?: Result.InvalidUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package mihon.domain.extensionrepo.service
|
package mihon.domain.extensionrepo.service
|
||||||
|
|
||||||
import androidx.core.net.toUri
|
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||||
import eu.kanade.tachiyomi.network.awaitSuccess
|
import eu.kanade.tachiyomi.network.awaitSuccess
|
||||||
|
@ -21,11 +20,9 @@ class ExtensionRepoService(
|
||||||
repo: String,
|
repo: String,
|
||||||
): ExtensionRepo? {
|
): ExtensionRepo? {
|
||||||
return withIOContext {
|
return withIOContext {
|
||||||
val url = "$repo/repo.json".toUri()
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
with(json) {
|
with(json) {
|
||||||
client.newCall(GET(url.toString()))
|
client.newCall(GET("$repo/repo.json"))
|
||||||
.awaitSuccess()
|
.awaitSuccess()
|
||||||
.parseAs<ExtensionRepoMetaDto>()
|
.parseAs<ExtensionRepoMetaDto>()
|
||||||
.toExtensionRepo(baseUrl = repo)
|
.toExtensionRepo(baseUrl = repo)
|
||||||
|
|
Loading…
Reference in a new issue