Skip to content

Commit

Permalink
Update playlist in opencast when changing metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
dennis531 committed Dec 4, 2024
1 parent 34181c6 commit 20d623c
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lib/Models/Playlists.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 20d623c

Please sign in to comment.