Skip to content

Commit a467178

Browse files
committed
WIP: Being able to exclude assets which contain the tag: "exclude_immich_tv". You can use this to never show certain assets in the Recent/Random/Seasonal view/screensaver as well as in Albums/Folders. However, the tags are not exposed yet in the API so this potentially does require a backend change.
Being able to temporarily enable the sound for certain videos during screensaver playback by pressing the UP button on your remote. (#106)
1 parent 3b64145 commit a467178

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ android {
3030
applicationId "nl.giejay.android.tv.immich"
3131
minSdkVersion 24
3232
targetSdkVersion 35
33-
versionCode 79
34-
versionName "2.5.0"
33+
versionCode 80
34+
versionName "2.6.0"
3535

3636
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3737
testOptions.unitTests.includeAndroidResources = true

app/src/main/java/nl/giejay/android/tv/immich/api/ApiClient.kt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,24 @@ class ApiClient(private val config: ApiClientConfig) {
6565
return executeAPICall(200) {
6666
val response = service.listAssetsFromAlbum(albumId)
6767
val album = response.body()
68-
val assets = album!!.assets.map { Asset(it.id, it.type, it.deviceAssetId, it.exifInfo, it.fileModifiedAt, album.albumName, it.people) }
68+
val assets = album!!.assets.filter(excludeByTag())
69+
.map { Asset(it.id, it.type, it.deviceAssetId, it.exifInfo, it.fileModifiedAt, album.albumName, it.people, it.tags) }
6970
val updatedAlbum = AlbumDetails(album.albumName, album.description, album.id, album.albumThumbnailAssetId, assets)
7071
Response.success(updatedAlbum)
7172
}
7273
}
7374

7475
suspend fun recentAssets(page: Int, pageCount: Int, includeVideos: Boolean): Either<String, List<Asset>> {
7576
val now = LocalDateTime.now()
76-
return apiClient!!.listAssets(page, pageCount, true, "desc",
77+
return listAssets(page, pageCount, true, "desc",
7778
includeVideos = includeVideos, fromDate = now.minusMonths(PreferenceManager.recentAssetsMonthsBack().toLong()), endDate = now)
7879
.map { it.shuffled() }
7980
}
8081

8182
suspend fun similarAssets(page: Int, pageCount: Int, includeVideos: Boolean): Either<String, List<Asset>> {
8283
val now = LocalDateTime.now()
8384
val map: List<Either<String, List<Asset>>> = (0 until PreferenceManager.similarAssetsYearsBack()).toList().map {
84-
apiClient!!.listAssets(page,
85+
listAssets(page,
8586
pageCount,
8687
true,
8788
"desc",
@@ -110,11 +111,15 @@ class ApiClient(private val config: ApiClientConfig) {
110111
personIds,
111112
endDate?.format(dateTimeFormatter),
112113
fromDate?.format(dateTimeFormatter))
113-
return if (random) {
114+
return (if (random) {
114115
executeAPICall(200) { service.randomAssets(searchRequest) }
115116
} else {
116117
executeAPICall(200) { service.listAssets(searchRequest) }.map { res -> res.assets.items }
117-
}
118+
}).map { it.filter(excludeByTag()) }
119+
}
120+
121+
private fun excludeByTag() = { asset: Asset ->
122+
asset.tags?.none { t -> t.name == "exclude_immich_tv" } ?: true
118123
}
119124

120125
suspend fun listBuckets(albumId: String, order: PhotosOrder): Either<String, List<Bucket>> {
@@ -145,13 +150,13 @@ class ApiClient(private val config: ApiClientConfig) {
145150
return parent
146151
}
147152

148-
private fun createFolders(paths: List<String>, currentParent: Folder): Folder{
149-
if(paths.isEmpty()){
153+
private fun createFolders(paths: List<String>, currentParent: Folder): Folder {
154+
if (paths.isEmpty()) {
150155
return currentParent
151156
}
152157
val createdChild = Folder(paths.first(), mutableListOf(), currentParent)
153158
val alreadyOwnedChild = currentParent.hasPath(paths.first())
154-
if(alreadyOwnedChild != null){
159+
if (alreadyOwnedChild != null) {
155160
return createFolders(paths.drop(1), alreadyOwnedChild)
156161
}
157162
currentParent.children.add(createdChild)
@@ -161,7 +166,7 @@ class ApiClient(private val config: ApiClientConfig) {
161166
suspend fun listAssetsForFolder(folder: String): Either<String, List<Asset>> {
162167
return executeAPICall(200) {
163168
service.getAssetsForPath(folder)
164-
}
169+
}.map { it.filter(excludeByTag()) }
165170
}
166171
}
167172

app/src/main/java/nl/giejay/android/tv/immich/api/model/Asset.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,20 @@ data class AssetExifInfo(
1212
val dateTimeOriginal: Date?
1313
)
1414

15+
data class Tag(
16+
val color: String?,
17+
val createdAt: Date,
18+
val name: String,
19+
val value: String
20+
)
21+
1522
data class Asset(
1623
val id: String,
1724
val type: String,
1825
val deviceAssetId: String?,
1926
val exifInfo: AssetExifInfo?,
2027
val fileModifiedAt: Date?,
2128
val albumName: String?,
22-
val people: List<Person>?
29+
val people: List<Person>?,
30+
val tags: List<Tag>?
2331
)

0 commit comments

Comments
 (0)