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

Add subtitle upload #355 #702

Merged
merged 10 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/contents.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ public function index_action()
PageLayout::setBodyElementId('opencast-plugin');

$this->studip_version = $this->getStudIPVersion();
$this->languages = json_encode($GLOBALS['CONTENT_LANGUAGES']);
}
}
1 change: 1 addition & 0 deletions app/controllers/course.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function index_action()
PageLayout::setBodyElementId('opencast-plugin');

$this->studip_version = $this->getStudIPVersion();
$this->languages = json_encode($GLOBALS['CONTENT_LANGUAGES']);

$this->render_template('course/index', $GLOBALS['template_factory']->open('layouts/base.php'));
}
Expand Down
17 changes: 17 additions & 0 deletions assets/css/opencast.scss
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,23 @@ h2.oc--loadingbar, .oc--loadingbar-title {
}
}

/* * * * * * * * * * * * * * * * * * */
/* U P L O A D E L E M E N T S */
/* * * * * * * * * * * * * * * * * * */

label.oc--file-upload {
cursor: pointer;
color: $base-color;

input[type=file] {
display: none;
}
.filename {
padding-left: 0.5em;
color: $light-gray-color-80;
}
}

/* * * * * * * * * * * * * * * * * * * * * */
/* S C R E E N S I Z E C L A S S E S */
/* * * * * * * * * * * * * * * * * * * * * */
Expand Down
18 changes: 18 additions & 0 deletions lib/Models/REST/ApiEventsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,22 @@ public function deleteEpisode($episode_id)
$response = $this->opencastApi->eventsApi->delete($episode_id);
return $response['code'] < 400;
}

/**
* Return media files
*
* @param
*
* @return array
*/
public function getMedia($eventId)
{
$response = $this->opencastApi->eventsApi->getMedia($eventId);

if ($response['code'] == 200) {
return $response['body'];
}

return false;
}
}
18 changes: 17 additions & 1 deletion lib/Models/Videos.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ public static function parseEvent($eventType, $episode, $video)
$presenter_download = [];
$presentation_download = [];
$audio_download = [];
$caption_download = [];
$annotation_tool = false;
$duration = 0;

Expand Down Expand Up @@ -664,6 +665,20 @@ public static function parseEvent($eventType, $episode, $video)
}
}

// Get caption files
$api_event_client = ApiEventsClient::getInstance($video->config_id);
$media_tracks = $api_event_client->getMedia($episode->identifier);

foreach($media_tracks as $track) {
if (substr($track->flavor, 0, 9) === 'captions/' &&
$track->mimetype === 'text/vtt')
{
$caption_download[$track->flavor] = [
'url' => $track->uri
];
}
}

foreach ($episode->publications as $publication) {
if ($publication->channel == 'engage-player') {
$track_link = $publication->url;
Expand All @@ -689,7 +704,8 @@ public static function parseEvent($eventType, $episode, $video)
'downloads' => [
'presenter' => $presenter_download,
'presentation' => $presentation_download,
'audio' => $audio_download
'audio' => $audio_download,
'caption' => $caption_download
],
'annotation_tool' => $annotation_tool,
'track_link' => $track_link
Expand Down
13 changes: 7 additions & 6 deletions lib/Routes/Config/SimpleConfigList.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ public function __invoke(Request $request, Response $response, $args)

foreach ($config as $conf) {
$config_list[$conf->id] = [
'id' => $conf->id,
'name' => $conf->service_url,
'version' => $conf->service_version,
'ingest' => reset(Endpoints::findBySql("config_id = ? AND service_type = 'ingest'", [$conf->id]))->service_url,
'studio' => $conf->service_url . '/studio/index.html',
'lti_num' => sizeof(LtiHelper::getLtiLinks($conf->id)) // used to iterate over all Opencast nodes
'id' => $conf->id,
'name' => $conf->service_url,
'version' => $conf->service_version,
'ingest' => reset(Endpoints::findBySql("config_id = ? AND service_type = 'ingest'", [$conf->id]))->service_url,
'apievents' => reset(Endpoints::findBySql("config_id = ? AND service_type = 'apievents'", [$conf->id]))->service_url,
'studio' => $conf->service_url . '/studio/index.html',
'lti_num' => sizeof(LtiHelper::getLtiLinks($conf->id)) // used to iterate over all Opencast nodes
];
}

Expand Down
40 changes: 31 additions & 9 deletions vueapp/common/upload.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,41 @@ class UploadService {
let obj = this;
return files.reduce(function(promise, file) {
return promise.then(function (mediaPackage) {
return obj.addTrack(mediaPackage, file, onProgress);

var data = new FormData();
data.append('mediaPackage', mediaPackage);
data.append('flavor', file.flavor);
data.append('tags', '');
data.append('BODY', file.file, file.file.name);

return obj.addTrack(data, "/addTrack", onProgress);
});
}, Promise.resolve(mediaPackage))
}

addTrack(mediaPackage, track, onProgress) {
var media = track.file;
var data = new FormData();
data.append('mediaPackage', mediaPackage);
data.append('flavor', track.flavor);
data.append('tags', '');
data.append('BODY', media, media.name);
async uploadCaptions(files, episode_id, options) {
this.fixFilenames(files);
let onProgress = options.uploadProgress;
let uploadDone = options.uploadDone;

let obj = this;
return files.reduce(function(promise, file) {
return promise.then(function () {

var data = new FormData();
data.append('flavor', file.flavor);
data.append('overwriteExisting', file.overwriteExisting);
data.append('track', file.file);

return obj.addTrack(data, "/" + episode_id + "/track", onProgress);
});
}, Promise.resolve())
.then(() => {
uploadDone();
})
}

addTrack(data, url_path, onProgress) {
var fnOnProgress = function (event) {
onProgress(track, event.loaded, event.total);
};
Expand All @@ -191,7 +213,7 @@ class UploadService {
obj.request = axios.CancelToken.source();

return axios({
url: obj.service_url + "/addTrack",
url: obj.service_url + url_path,
method: "POST",
data: data,
processData: false,
Expand Down
Loading