mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 08:01:20 +02:00
WIP update open api spec
This commit is contained in:
parent
6e597f0509
commit
b87d81513a
10 changed files with 594 additions and 449 deletions
|
|
@ -46,7 +46,7 @@ class NavDrawerItemRepository
|
|||
setOf()
|
||||
}
|
||||
|
||||
val builtins = listOf(NavDrawerItem.Favorites)
|
||||
val builtins = listOf(NavDrawerItem.Favorites, NavDrawerItem.Discover)
|
||||
val libraries =
|
||||
userViews
|
||||
.filter { it.collectionType in supportedCollectionTypes || it.id in recordingFolders }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
package com.github.damontecres.wholphin.services
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import com.github.damontecres.api.seerr.SeerrApiClient
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
class SeerrApi(
|
||||
@param:ApplicationContext private val context: Context,
|
||||
private val okHttpClient: OkHttpClient,
|
||||
) {
|
||||
private val prefs: SharedPreferences =
|
||||
context.getSharedPreferences("seerr", Context.MODE_PRIVATE)
|
||||
|
||||
var api: SeerrApiClient =
|
||||
SeerrApiClient(
|
||||
prefs.getString("baseUrl", null)!!,
|
||||
prefs.getString("apiKey", null)!!,
|
||||
okHttpClient,
|
||||
)
|
||||
private set
|
||||
|
||||
fun update(
|
||||
baseUrl: String,
|
||||
apiKey: String,
|
||||
) {
|
||||
api = SeerrApiClient(baseUrl, apiKey, okHttpClient)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,42 @@
|
|||
package com.github.damontecres.wholphin.services
|
||||
|
||||
import com.github.damontecres.api.seerr.SeerrApiClient
|
||||
import com.github.damontecres.api.seerr.model.SearchGet200ResponseResultsInner
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
class SeerrService constructor(
|
||||
private val api: SeerrApiClient,
|
||||
) {
|
||||
fun init() {
|
||||
api.searchApi.discoverTvGet(1)
|
||||
typealias SearchResult = SearchGet200ResponseResultsInner
|
||||
|
||||
@Singleton
|
||||
class SeerrService
|
||||
@Inject
|
||||
constructor(
|
||||
private val seerApi: SeerrApi,
|
||||
) {
|
||||
private val api: SeerrApiClient get() = seerApi.api
|
||||
|
||||
suspend fun init() {
|
||||
api.searchApi.discoverTvGet(1)
|
||||
}
|
||||
|
||||
suspend fun search(
|
||||
query: String,
|
||||
page: Int = 1,
|
||||
): List<SearchResult> =
|
||||
api.searchApi
|
||||
.searchGet(query = query, page = page)
|
||||
.results
|
||||
.orEmpty()
|
||||
|
||||
suspend fun discoverTv(page: Int = 1) =
|
||||
api.searchApi
|
||||
.discoverTvGet(page = page)
|
||||
.results
|
||||
.orEmpty()
|
||||
|
||||
suspend fun discoverMovies(page: Int = 1) =
|
||||
api.searchApi
|
||||
.discoverMoviesGet(page = page)
|
||||
.results
|
||||
.orEmpty()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.github.damontecres.wholphin.data.ServerRepository
|
|||
import com.github.damontecres.wholphin.preferences.AppPreferences
|
||||
import com.github.damontecres.wholphin.preferences.UserPreferences
|
||||
import com.github.damontecres.wholphin.preferences.updateInterfacePreferences
|
||||
import com.github.damontecres.wholphin.services.SeerrApi
|
||||
import com.github.damontecres.wholphin.util.ExceptionHandler
|
||||
import com.github.damontecres.wholphin.util.RememberTabManager
|
||||
import dagger.Module
|
||||
|
|
@ -182,4 +183,11 @@ object AppModule {
|
|||
@Singleton
|
||||
@IoCoroutineScope
|
||||
fun ioCoroutineScope(): CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun seerrApi(
|
||||
@ApplicationContext context: Context,
|
||||
@StandardOkHttpClient okHttpClient: OkHttpClient,
|
||||
) = SeerrApi(context, okHttpClient)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,6 +117,9 @@ sealed class Destination(
|
|||
@Serializable
|
||||
data object Favorites : Destination(false)
|
||||
|
||||
@Serializable
|
||||
data object Discover : Destination(false)
|
||||
|
||||
@Serializable
|
||||
data object UpdateApp : Destination(true)
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import com.github.damontecres.wholphin.ui.main.HomePage
|
|||
import com.github.damontecres.wholphin.ui.main.SearchPage
|
||||
import com.github.damontecres.wholphin.ui.playback.PlaybackPage
|
||||
import com.github.damontecres.wholphin.ui.preferences.PreferencesPage
|
||||
import com.github.damontecres.wholphin.ui.seerr.SeerrDiscoverPage
|
||||
import com.github.damontecres.wholphin.ui.setup.InstallUpdatePage
|
||||
import com.github.damontecres.wholphin.ui.setup.SwitchServerContent
|
||||
import com.github.damontecres.wholphin.ui.setup.SwitchUserContent
|
||||
|
|
@ -241,6 +242,14 @@ fun DestinationContent(
|
|||
Destination.Debug -> {
|
||||
DebugPage(preferences, modifier)
|
||||
}
|
||||
|
||||
Destination.Discover ->
|
||||
SeerrDiscoverPage(
|
||||
preferences = preferences,
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
package com.github.damontecres.wholphin.ui.seerr
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.lazy.LazyRow
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
|
||||
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.preferences.UserPreferences
|
||||
import com.github.damontecres.wholphin.services.SeerrService
|
||||
import com.github.damontecres.wholphin.ui.launchIO
|
||||
import com.github.damontecres.wholphin.ui.setValueOnMain
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
class SeerrDiscoverViewModel
|
||||
@Inject
|
||||
constructor(
|
||||
val seerrService: SeerrService,
|
||||
) : ViewModel() {
|
||||
val discoverMovies = MutableLiveData<List<MovieResult>>(listOf())
|
||||
|
||||
init {
|
||||
viewModelScope.launchIO {
|
||||
val movies = seerrService.discoverMovies()
|
||||
discoverMovies.setValueOnMain(movies)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SeerrDiscoverPage(
|
||||
preferences: UserPreferences,
|
||||
modifier: Modifier = Modifier,
|
||||
viewModel: SeerrDiscoverViewModel = hiltViewModel(),
|
||||
) {
|
||||
val movies by viewModel.discoverMovies.observeAsState(listOf())
|
||||
Column(
|
||||
modifier = modifier,
|
||||
) {
|
||||
LazyRow(
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) {
|
||||
items(movies) { movie ->
|
||||
Text(
|
||||
text = movie.title,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -354,6 +354,7 @@
|
|||
<string name="automatic">Automatic</string>
|
||||
<string name="username_or_password">Use username/password</string>
|
||||
<string name="login">Login</string>
|
||||
<string name="discover">Discover</string>
|
||||
|
||||
<string-array name="theme_song_volume">
|
||||
<item>Disabled</item>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue