Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the worker cronjob and add functionality to discover cronjob #1265

Merged
19 changes: 5 additions & 14 deletions app/controllers/redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,14 @@ private function getLtiCustomTool($video, $action) {
break;

case 'editor':
// $preview = $video->preview ? json_decode($video->preview, true) : null;
// if (!empty($preview) && isset($preview['has_previews']) && $preview['has_previews']) {
$custom_tool = "/editor-ui/index.html?id={$video->episode}";
// }
$custom_tool = "/editor-ui/index.html?id={$video->episode}";
break;

case 'share':
case 'video':
$preview = $video->preview ? json_decode($video->preview, true) : null;
if (!empty($preview)) {
$video->views += 1;
$video->store();
$custom_tool = "/play/{$video->episode}";
}
$video->views += 1;
$video->store();
$custom_tool = "/play/{$video->episode}";
break;
case 'livestream':
if (!empty($video->livestream_link)) {
Expand Down Expand Up @@ -222,12 +216,9 @@ public function preview_action($token)
}

// get preview image
$previews = json_decode($video->preview, true);
$preview = $previews['player'] ?: $previews['search'];

$api_events = ApiEventsClient::getInstance($video->config_id);

$image = $preview ?
$image = $video->preview ?
: URLHelper::getURL($this->plugin->getPluginUrl() . '/assets/images/default-preview.png');

$response = $api_events->fileRequest($image);
Expand Down
2 changes: 1 addition & 1 deletion courseware/vueapp/components/VideoRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
tabindex="0"
>
<td class="oc--playercontainer">
<span v-if="event.publication && event.preview && (event.available && event.available != '0' && !isProcessing)">
<span v-if="event.publication && (event.available && event.available != '0' && !isProcessing)">
<span class="oc--previewimage">
<img class="oc--previewimage"
:src="getImageSrc"
Expand Down
282 changes: 158 additions & 124 deletions cronjobs/opencast_discover_videos.php

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions cronjobs/opencast_sync_acls.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
require_once __DIR__.'/../vendor/autoload.php';

use Opencast\Models\Config;
use Opencast\Models\VideoSync;
use Opencast\Models\Videos;
use Opencast\Models\ScheduleHelper;
use Opencast\Models\REST\ApiEventsClient;
use Opencast\Models\REST\ApiPlaylistsClient;
use Opencast\Models\REST\Config as OCConfig;

class OpencastSyncAcls extends CronJob
Expand Down
209 changes: 0 additions & 209 deletions cronjobs/opencast_worker.php

This file was deleted.

14 changes: 0 additions & 14 deletions lib/Models/ScheduleHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use Opencast\Models\Videos;
use Opencast\Models\Helpers;
use Opencast\Models\PlaylistVideos;
use Opencast\Models\VideoSync;
use Opencast\Models\PlaylistSeminarVideos;

class ScheduleHelper
Expand Down Expand Up @@ -1191,19 +1190,6 @@ public static function createOrUpdateLivestreamVideo($config_id, $course_id, $ev
$psv->store();
}
}

// we put a worker on this video to make sure everything goes as usual.
if (empty(VideoSync::findByVideo_id($video->id))) {
$task = new VideoSync;

$task->setData([
'video_id' => $video->id,
'state' => 'scheduled',
'scheduled' => date('Y-m-d H:i:s')
]);

$task->store();
}
}
}

Expand Down
13 changes: 0 additions & 13 deletions lib/Models/VideoSync.php

This file was deleted.

30 changes: 17 additions & 13 deletions lib/Models/Videos.php
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ public function updateAcl($new_vis = null, $current_acl = null)
}

/**
* Extract data from the OC event and adds it to the videos db entry
* Extract data from the OC event and add it to the videos db entry
*
* @Notification OpencastVideoSync
*
Expand All @@ -943,7 +943,6 @@ public function updateAcl($new_vis = null, $current_acl = null)
public static function parseEvent($eventType, $episode, $video)
{
if (!empty($episode->publications[0]->attachments)) {
$presentation_preview = false;
$preview = false;
$presenter_download = [];
$presentation_download = [];
Expand All @@ -953,13 +952,22 @@ public static function parseEvent($eventType, $episode, $video)
$track_link = '';
$livestream_link = '';

foreach ((array) $episode->publications[0]->attachments as $attachment) {
if ($attachment->flavor === "presenter/search+preview" || $attachment->type === "presenter/search+preview") {
$preview = $attachment->url;
}
if ($attachment->flavor === "presentation/player+preview" || $attachment->type === "presentation/player+preview") {
$presentation_preview = $attachment->url;
$possible_previews = [
'presentation/search+preview',
'presentation/player+preview',
'presenter/search+preview',
'presenter/player+preview',
];

foreach ($possible_previews as $preview_type) {
foreach ((array) $episode->publications[0]->attachments as $attachment) {
if (!empty($attachment->flavor) && $attachment->flavor === $preview_type) {
$preview = $attachment->url;
break;
}
}

if (!empty($preview)) break;
}

foreach ($episode->publications[0]->media as $track) {
Expand Down Expand Up @@ -1047,11 +1055,7 @@ public static function parseEvent($eventType, $episode, $video)
$video->presenters = implode(', ', (array)$episode->presenter);
$video->contributors = implode(', ', (array)$episode->contributor);

$video->preview = json_encode([
'search' => $preview,
'player' => $presentation_preview,
'has_previews' => $episode->has_previews ?: false
]);
$video->preview = $preview;

$video->publication = json_encode([
'downloads' => [
Expand Down
Loading