mirror of
https://github.com/bbara04/Purefin.git
synced 2026-07-23 19:26:50 +00:00
feat(jellyfin): add functionality to mark media as watched/unwatched
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
package hu.bbara.purefin.jellyfin
|
||||||
|
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
|
interface JellyfinMediaMetadataUpdater {
|
||||||
|
suspend fun markAsWatched(mediaId: UUID, watched: Boolean)
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package hu.bbara.purefin.data.jellyfin
|
||||||
|
|
||||||
|
import hu.bbara.purefin.data.jellyfin.client.JellyfinApiClient
|
||||||
|
import hu.bbara.purefin.jellyfin.JellyfinMediaMetadataUpdater
|
||||||
|
import java.util.UUID
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class JellyfinMediaMetadataUpdaterImpl @Inject constructor(
|
||||||
|
private val jellyfinApiClient: JellyfinApiClient
|
||||||
|
) : JellyfinMediaMetadataUpdater {
|
||||||
|
|
||||||
|
override suspend fun markAsWatched(mediaId: UUID, watched: Boolean) {
|
||||||
|
if (watched) {
|
||||||
|
jellyfinApiClient.markAsWatched(mediaId)
|
||||||
|
} else {
|
||||||
|
jellyfinApiClient.markAsUnwatched(mediaId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -322,6 +322,30 @@ class JellyfinApiClient @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun markAsWatched(mediaId: UUID) = withContext(Dispatchers.IO) {
|
||||||
|
logApiFailure("markAsWatched($mediaId)") {
|
||||||
|
if (!ensureConfigured()) {
|
||||||
|
return@logApiFailure
|
||||||
|
}
|
||||||
|
api.playStateApi.markPlayedItem(
|
||||||
|
itemId = mediaId,
|
||||||
|
userId = getUserId(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun markAsUnwatched(mediaId: UUID) = withContext(Dispatchers.IO) {
|
||||||
|
logApiFailure("markAsUnwatched($mediaId)") {
|
||||||
|
if (!ensureConfigured()) {
|
||||||
|
return@logApiFailure
|
||||||
|
}
|
||||||
|
api.playStateApi.markUnplayedItem(
|
||||||
|
itemId = mediaId,
|
||||||
|
userId = getUserId(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun getMediaSources(mediaId: UUID): List<MediaSourceInfo> = withContext(Dispatchers.IO) {
|
suspend fun getMediaSources(mediaId: UUID): List<MediaSourceInfo> = withContext(Dispatchers.IO) {
|
||||||
logApiFailure("getMediaSources($mediaId)") {
|
logApiFailure("getMediaSources($mediaId)") {
|
||||||
if (!ensureConfigured()) {
|
if (!ensureConfigured()) {
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ import hu.bbara.purefin.data.SearchManager
|
|||||||
import hu.bbara.purefin.data.catalog.InMemoryAppContentRepository
|
import hu.bbara.purefin.data.catalog.InMemoryAppContentRepository
|
||||||
import hu.bbara.purefin.data.catalog.InMemoryLocalMediaRepository
|
import hu.bbara.purefin.data.catalog.InMemoryLocalMediaRepository
|
||||||
import hu.bbara.purefin.data.catalog.OfflineLocalMediaRepository
|
import hu.bbara.purefin.data.catalog.OfflineLocalMediaRepository
|
||||||
|
import hu.bbara.purefin.data.jellyfin.JellyfinMediaMetadataUpdaterImpl
|
||||||
import hu.bbara.purefin.data.jellyfin.SearchManagerImpl
|
import hu.bbara.purefin.data.jellyfin.SearchManagerImpl
|
||||||
|
import hu.bbara.purefin.jellyfin.JellyfinMediaMetadataUpdater
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
@InstallIn(SingletonComponent::class)
|
@InstallIn(SingletonComponent::class)
|
||||||
@@ -29,6 +31,9 @@ abstract class MediaRepositoryModule {
|
|||||||
@Binds
|
@Binds
|
||||||
abstract fun bindHomeRepository(impl: InMemoryAppContentRepository): HomeRepository
|
abstract fun bindHomeRepository(impl: InMemoryAppContentRepository): HomeRepository
|
||||||
|
|
||||||
|
@Binds
|
||||||
|
abstract fun bindJellyfinMediaMetadataUpdater(impl: JellyfinMediaMetadataUpdaterImpl): JellyfinMediaMetadataUpdater
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
abstract fun bindSearchManager(impl: SearchManagerImpl): SearchManager
|
abstract fun bindSearchManager(impl: SearchManagerImpl): SearchManager
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user