mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 08:01:20 +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
|
|
@ -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