From 20d623c8f32558b0aa192a72496d85b9ece4d7fb Mon Sep 17 00:00:00 2001 From: Dennis Benz Date: Wed, 4 Dec 2024 14:50:48 +0100 Subject: [PATCH] Update playlist in opencast when changing metadata --- lib/Models/Playlists.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/Models/Playlists.php b/lib/Models/Playlists.php index e53501a7..50391b6f 100644 --- a/lib/Models/Playlists.php +++ b/lib/Models/Playlists.php @@ -499,15 +499,25 @@ public function update(array $json) ) { // Load playlist from Opencast $playlist_client = ApiPlaylistsClient::getInstance($this->config_id); - $oc_playlist = $playlist_client->getPlaylist($this->service_playlist_id); - if ($oc_playlist) { - self::checkPlaylistACL($oc_playlist, $this); - } else { - // Load or update failed in Opencast + // Update playlist in Opencast + $oc_update_data = []; + foreach (['title', 'description', 'creator'] as $key) { + if (array_key_exists($key, $json)) { + $oc_update_data[$key] = $json[$key]; + } + } + + $oc_playlist = $playlist_client->updatePlaylist($this->service_playlist_id, $oc_update_data); + + if (!$oc_playlist) { + // Update failed in Opencast return false; } + // Ensure playlist acls are correct + self::checkPlaylistACL($oc_playlist, $this); + // Ensure playlist data is consistent $json['title'] = $oc_playlist->title; $json['description'] = $oc_playlist->description;