This commit is contained in:
Marek Lenczewski
2026-04-07 17:55:30 +02:00
parent 8f15f51bce
commit ca988345e9
19 changed files with 201 additions and 203 deletions

View File

@@ -4,10 +4,10 @@ data class Video(
val id: Int,
val title: String,
val youtuber: String,
val thumbnail_url: String,
val youtube_url: String,
val is_downloaded: Boolean,
val profile_ids: List<Int> = emptyList()
val thumbnailUrl: String,
val youtubeUrl: String,
val isDownloaded: Boolean,
val profileIds: List<Int> = emptyList()
)
data class Profile(

View File

@@ -7,10 +7,10 @@ import retrofit2.http.Query
interface VideoApi {
@GET("videos")
suspend fun getAllVideos(@Query("profile_id") profileId: Int? = null): List<Video>
suspend fun getAllVideos(@Query("profileId") profileId: Int? = null): List<Video>
@GET("videos/downloaded")
suspend fun getDownloadedVideos(@Query("profile_id") profileId: Int? = null): List<Video>
suspend fun getDownloadedVideos(@Query("profileId") profileId: Int? = null): List<Video>
@POST("videos/{id}/download")
suspend fun triggerDownload(@Path("id") id: Int): Map<String, String>

View File

@@ -19,7 +19,7 @@ class VideoRepository(private val api: VideoApi = ApiClient.api) {
}
suspend fun cleanupVideos(profileId: Int, excludeIds: List<Int>): Result<Int> = runCatching {
val body = mapOf("profile_id" to profileId, "exclude_ids" to excludeIds)
val body = mapOf("profileId" to profileId, "excludeIds" to excludeIds)
val response = api.cleanupVideos(body)
response["deleted"] ?: 0
}

View File

@@ -40,7 +40,7 @@ fun VideoCard(video: Video, onClick: () -> Unit) {
) {
Column {
AsyncImage(
model = video.thumbnail_url,
model = video.thumbnailUrl,
contentDescription = video.title,
contentScale = ContentScale.Crop,
modifier = Modifier

View File

@@ -83,7 +83,7 @@ fun VideoDetailScreen(
Column(modifier = Modifier.fillMaxSize()) {
AsyncImage(
model = video.thumbnail_url,
model = video.thumbnailUrl,
contentDescription = video.title,
contentScale = ContentScale.Crop,
modifier = Modifier
@@ -121,7 +121,7 @@ private fun VideoInfo(
Text(
text = when {
isLocal -> "Lokal gespeichert"
video.is_downloaded -> "Auf Server heruntergeladen"
video.isDownloaded -> "Auf Server heruntergeladen"
else -> "Noch nicht heruntergeladen"
},
style = MaterialTheme.typography.bodySmall,

View File

@@ -140,7 +140,7 @@ class VideoViewModel : ViewModel() {
delay(2000)
val videosResult = repository.getAllVideos()
val video = videosResult.getOrNull()?.find { it.id == videoId }
if (video?.is_downloaded == true) break
if (video?.isDownloaded == true) break
attempts++
}
if (attempts >= 150) throw Exception("Download fehlgeschlagen")