mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
Move seer-api into app
This commit is contained in:
parent
b87d81513a
commit
d08bd40a68
11 changed files with 70 additions and 78 deletions
|
|
@ -15,6 +15,7 @@ plugins {
|
|||
alias(libs.plugins.protobuf)
|
||||
alias(libs.plugins.kotlin.plugin.serialization)
|
||||
alias(libs.plugins.aboutLibraries)
|
||||
id("org.openapi.generator") version "7.17.0"
|
||||
}
|
||||
|
||||
val isCI = if (System.getenv("CI") != null) System.getenv("CI").toBoolean() else false
|
||||
|
|
@ -70,6 +71,14 @@ android {
|
|||
jvmTarget = JvmTarget.JVM_11
|
||||
javaParameters = true
|
||||
}
|
||||
// sourceSets {
|
||||
// main {
|
||||
// java.srcDirs +=
|
||||
// kotlin {
|
||||
// srcDirs += files("$buildDir/generated/seerr_api/src/main/kotlin")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
|
|
@ -144,6 +153,12 @@ android {
|
|||
isUniversalApk = true
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
getByName("main") {
|
||||
kotlin.srcDirs("$buildDir/generated/seerr_api/src/main/kotlin")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protobuf {
|
||||
|
|
@ -175,6 +190,30 @@ aboutLibraries {
|
|||
}
|
||||
}
|
||||
|
||||
openApiGenerate {
|
||||
generatorName.set("kotlin")
|
||||
inputSpec.set("$projectDir/src/main/seerr-api.yml")
|
||||
outputDir.set("$buildDir/generated/seerr_api")
|
||||
apiPackage.set("com.github.damontecres.wholphin.api.seerr")
|
||||
modelPackage.set("com.github.damontecres.wholphin.api.seerr.model")
|
||||
groupId.set("com.github.damontecres.wholphin.api.seerr")
|
||||
id.set("seerr-api")
|
||||
packageName.set("com.github.damontecres.wholphin.api.seerr")
|
||||
additionalProperties.apply {
|
||||
put("serializationLibrary", "kotlinx_serialization")
|
||||
put("sortModelPropertiesByRequiredFlag", true)
|
||||
put("sortParamsByRequiredFlag", true)
|
||||
put("useCoroutines", true)
|
||||
put("enumPropertyNaming", "UPPERCASE")
|
||||
put("modelMutable", false)
|
||||
put("supportAndroidApiLevel25AndBelow", true)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("preBuild") {
|
||||
dependsOn.add(tasks.named("openApiGenerate"))
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.androidx.core.ktx)
|
||||
implementation(libs.androidx.appcompat)
|
||||
|
|
@ -238,6 +277,8 @@ dependencies {
|
|||
implementation(libs.acra.limiter)
|
||||
compileOnly(libs.auto.service.annotations)
|
||||
ksp(libs.auto.service.ksp)
|
||||
implementation(platform(libs.okhttp.bom))
|
||||
implementation(libs.okhttp)
|
||||
|
||||
androidTestImplementation(platform(libs.androidx.compose.bom))
|
||||
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
|
||||
|
|
@ -248,5 +289,5 @@ dependencies {
|
|||
implementation(files("libs/lib-decoder-ffmpeg-release.aar"))
|
||||
}
|
||||
|
||||
implementation(project(":seerr-api"))
|
||||
// implementation(project(":seerr-api"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
package com.github.damontecres.wholphin.api.seerr
|
||||
|
||||
import com.github.damontecres.wholphin.api.seerr.infrastructure.ApiClient
|
||||
import okhttp3.Call
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
class SeerrApiClient(
|
||||
val baseUrl: String,
|
||||
val apiKey: String,
|
||||
okHttpClient: OkHttpClient,
|
||||
) {
|
||||
private val client =
|
||||
okHttpClient
|
||||
.newBuilder()
|
||||
.addInterceptor {
|
||||
it.proceed(
|
||||
it
|
||||
.request()
|
||||
.newBuilder()
|
||||
.header("X-Api-Key", apiKey)
|
||||
.build(),
|
||||
)
|
||||
}.build()
|
||||
|
||||
private fun <T : ApiClient> create(initializer: (String, Call.Factory) -> T): Lazy<T> =
|
||||
lazy {
|
||||
initializer.invoke(baseUrl, client)
|
||||
}
|
||||
|
||||
val authApi by create(::AuthApi)
|
||||
val blacklistApi by create(::BlacklistApi)
|
||||
val collectionApi by create(::CollectionApi)
|
||||
val issueApi by create(::IssueApi)
|
||||
val mediaApi by create(::MediaApi)
|
||||
val moviesApi by create(::MoviesApi)
|
||||
val otherApi by create(::OtherApi)
|
||||
val overrideruleApi by create(::OverrideruleApi)
|
||||
val personApi by create(::PersonApi)
|
||||
val publicApi by create(::PublicApi)
|
||||
val requestApi by create(::RequestApi)
|
||||
val searchApi by create(::SearchApi)
|
||||
val serviceApi by create(::ServiceApi)
|
||||
val settingsApi by create(::SettingsApi)
|
||||
val tmdbApi by create(::TmdbApi)
|
||||
val tvApi by create(::TvApi)
|
||||
val usersApi by create(::UsersApi)
|
||||
val watchlistApi by create(::WatchlistApi)
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ package com.github.damontecres.wholphin.services
|
|||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import com.github.damontecres.api.seerr.SeerrApiClient
|
||||
import com.github.damontecres.wholphin.api.seerr.SeerrApiClient
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ class SeerrApi(
|
|||
|
||||
var api: SeerrApiClient =
|
||||
SeerrApiClient(
|
||||
prefs.getString("baseUrl", null)!!,
|
||||
prefs.getString("baseUrl", null)!! + "/api/v1",
|
||||
prefs.getString("apiKey", null)!!,
|
||||
okHttpClient,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.github.damontecres.wholphin.services
|
||||
|
||||
import com.github.damontecres.api.seerr.SeerrApiClient
|
||||
import com.github.damontecres.api.seerr.model.SearchGet200ResponseResultsInner
|
||||
import com.github.damontecres.wholphin.api.seerr.SeerrApiClient
|
||||
import com.github.damontecres.wholphin.api.seerr.model.SearchGet200ResponseResultsInner
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
|
|
|||
|
|
@ -243,13 +243,12 @@ fun DestinationContent(
|
|||
DebugPage(preferences, modifier)
|
||||
}
|
||||
|
||||
Destination.Discover ->
|
||||
Destination.Discover -> {
|
||||
SeerrDiscoverPage(
|
||||
preferences = preferences,
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -188,6 +188,13 @@ sealed interface NavDrawerItem {
|
|||
|
||||
override fun name(context: Context): String = context.getString(R.string.more)
|
||||
}
|
||||
|
||||
object Discover : NavDrawerItem {
|
||||
override val id: String
|
||||
get() = "a_discover"
|
||||
|
||||
override fun name(context: Context): String = context.getString(R.string.discover)
|
||||
}
|
||||
}
|
||||
|
||||
data class ServerNavDrawerItem(
|
||||
|
|
@ -262,6 +269,13 @@ fun NavDrawer(
|
|||
setShowMore(!showMore)
|
||||
}
|
||||
|
||||
NavDrawerItem.Discover -> {
|
||||
viewModel.setIndex(index)
|
||||
viewModel.navigationManager.navigateToFromDrawer(
|
||||
Destination.Discover,
|
||||
)
|
||||
}
|
||||
|
||||
is ServerNavDrawerItem -> {
|
||||
viewModel.setIndex(index)
|
||||
viewModel.navigationManager.navigateToFromDrawer(item.destination)
|
||||
|
|
@ -606,6 +620,11 @@ fun NavigationDrawerScope.NavItem(
|
|||
R.string.fa_ellipsis
|
||||
}
|
||||
|
||||
NavDrawerItem.Discover -> {
|
||||
// TODO seerr
|
||||
R.string.fa_list_ul
|
||||
}
|
||||
|
||||
is ServerNavDrawerItem -> {
|
||||
when (library.type) {
|
||||
CollectionType.MOVIES -> R.string.fa_film
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import androidx.lifecycle.MutableLiveData
|
|||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.tv.material3.Text
|
||||
import com.github.damontecres.api.seerr.model.MovieResult
|
||||
import com.github.damontecres.wholphin.api.seerr.model.MovieResult
|
||||
import com.github.damontecres.wholphin.preferences.UserPreferences
|
||||
import com.github.damontecres.wholphin.services.SeerrService
|
||||
import com.github.damontecres.wholphin.ui.launchIO
|
||||
|
|
|
|||
7760
app/src/main/seerr-api.yml
Normal file
7760
app/src/main/seerr-api.yml
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue