Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
GrakovNe committed Nov 11, 2024
1 parent 841e5ba commit 410922f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.grakovne.lissen.channel.audiobookshelf

import org.grakovne.lissen.channel.audiobookshelf.common.CommonAudiobookshelfChannel
import org.grakovne.lissen.channel.audiobookshelf.common.UnknownAudiobookshelfChannel
import org.grakovne.lissen.channel.audiobookshelf.common.api.AudiobookshelfAuthService
import org.grakovne.lissen.channel.audiobookshelf.library.LibraryAudiobookshelfChannel
import org.grakovne.lissen.channel.audiobookshelf.podcast.PodcastAudiobookshelfChannel
Expand All @@ -17,7 +17,7 @@ import javax.inject.Singleton
class AudiobookshelfChannelProvider @Inject constructor(
private val podcastAudiobookshelfChannel: PodcastAudiobookshelfChannel,
private val libraryAudiobookshelfChannel: LibraryAudiobookshelfChannel,
private val commonAudiobookshelfChannel: CommonAudiobookshelfChannel,
private val unknownAudiobookshelfChannel: UnknownAudiobookshelfChannel,
private val audiobookshelfAuthService: AudiobookshelfAuthService,
private val sharedPreferences: LissenSharedPreferences
) : ChannelProvider {
Expand All @@ -31,7 +31,7 @@ class AudiobookshelfChannelProvider @Inject constructor(
return when (libraryType) {
LibraryType.LIBRARY -> libraryAudiobookshelfChannel
LibraryType.PODCAST -> podcastAudiobookshelfChannel
LibraryType.UNKNOWN -> commonAudiobookshelfChannel
LibraryType.UNKNOWN -> unknownAudiobookshelfChannel
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class CommonAudiobookshelfChannel @Inject constructor(
class UnknownAudiobookshelfChannel @Inject constructor(
dataRepository: AudioBookshelfDataRepository,
mediaRepository: AudioBookshelfMediaRepository,
recentListeningResponseConverter: RecentListeningResponseConverter,
Expand All @@ -37,9 +37,19 @@ class CommonAudiobookshelfChannel @Inject constructor(

override fun getLibraryType(): LibraryType = LibraryType.UNKNOWN

override suspend fun fetchBooks(libraryId: String, pageSize: Int, pageNumber: Int): ApiResult<PagedItems<Book>> = ApiResult.Error(ApiError.UnsupportedError)
override suspend fun fetchBooks(
libraryId: String,
pageSize: Int,
pageNumber: Int
): ApiResult<PagedItems<Book>> = ApiResult.Error(ApiError.UnsupportedError)

override suspend fun searchBooks(libraryId: String, query: String, limit: Int): ApiResult<List<Book>> = ApiResult.Error(ApiError.UnsupportedError)
override suspend fun searchBooks(
libraryId: String,
query: String,
limit: Int
): ApiResult<List<Book>> = ApiResult.Error(ApiError.UnsupportedError)

override suspend fun fetchBook(bookId: String): ApiResult<DetailedItem> = ApiResult.Error(ApiError.UnsupportedError)
override suspend fun fetchBook(
bookId: String
): ApiResult<DetailedItem> = ApiResult.Error(ApiError.UnsupportedError)
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ class AudiobookshelfAuthService @Inject constructor(
)
}

override fun getAuthType(): AuthType = AuthType.AUDIOBOOKSHELF_CREDENTIALS
override fun getAuthType(): AuthType = AuthType.CREDENTIALS
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package org.grakovne.lissen.channel.common

enum class AuthType {
AUDIOBOOKSHELF_CREDENTIALS
CREDENTIALS
}
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,13 @@ class LissenMediaProvider @Inject constructor(
return page.copy(items = items)
}

fun provideAuthService(): ChannelAuthService {
return channels[sharedPreferences.getChannel()]
?.provideChannelAuth()
?: throw IllegalStateException("Selected auth service has been requested but not selected")
}
fun provideAuthService(): ChannelAuthService = channels[sharedPreferences.getChannel()]
?.provideChannelAuth()
?: throw IllegalStateException("Selected auth service has been requested but not selected")

fun providePreferredChannel(): MediaChannel {
return channels[sharedPreferences.getChannel()]
?.provideMediaChannel()
?: throw IllegalStateException("Selected auth service has been requested but not selected")
}
fun providePreferredChannel(): MediaChannel = channels[sharedPreferences.getChannel()]
?.provideMediaChannel()
?: throw IllegalStateException("Selected auth service has been requested but not selected")

companion object {

Expand Down

0 comments on commit 410922f

Please sign in to comment.