mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-27 03:18:25 +01:00
Extension API: change fallback source and logic (#7400)
* Extension API: change fallback source and logic
* remove ghproxy
(cherry picked from commit 284445c364
)
This commit is contained in:
parent
33500e5b69
commit
6024f6175b
@ -27,14 +27,17 @@ internal class ExtensionGithubApi {
|
|||||||
|
|
||||||
suspend fun findExtensions(): List<Extension.Available> {
|
suspend fun findExtensions(): List<Extension.Available> {
|
||||||
return withIOContext {
|
return withIOContext {
|
||||||
val response = try {
|
val githubResponse = if (requiresFallbackSource) null else try {
|
||||||
networkService.client
|
networkService.client
|
||||||
.newCall(GET("${REPO_URL_PREFIX}index.min.json"))
|
.newCall(GET("${REPO_URL_PREFIX}index.min.json"))
|
||||||
.await()
|
.await()
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
logcat(LogPriority.ERROR, e) { "Failed to get extensions from GitHub" }
|
logcat(LogPriority.ERROR, e) { "Failed to get extensions from GitHub" }
|
||||||
requiresFallbackSource = true
|
requiresFallbackSource = true
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
|
val response = githubResponse ?: run {
|
||||||
networkService.client
|
networkService.client
|
||||||
.newCall(GET("${FALLBACK_REPO_URL_PREFIX}index.min.json"))
|
.newCall(GET("${FALLBACK_REPO_URL_PREFIX}index.min.json"))
|
||||||
.await()
|
.await()
|
||||||
@ -129,7 +132,7 @@ internal class ExtensionGithubApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private const val REPO_URL_PREFIX = "https://raw.githubusercontent.com/tachiyomiorg/tachiyomi-extensions/repo/"
|
private const val REPO_URL_PREFIX = "https://raw.githubusercontent.com/tachiyomiorg/tachiyomi-extensions/repo/"
|
||||||
private const val FALLBACK_REPO_URL_PREFIX = "https://fastly.jsdelivr.net/gh/tachiyomiorg/tachiyomi-extensions@repo/"
|
private const val FALLBACK_REPO_URL_PREFIX = "https://gcore.jsdelivr.net/gh/tachiyomiorg/tachiyomi-extensions@repo/"
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
private data class ExtensionJsonObject(
|
private data class ExtensionJsonObject(
|
||||||
|
Loading…
Reference in New Issue
Block a user