forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aVideoEncoderNotifyIsDone.json.php
78 lines (69 loc) · 2.26 KB
/
aVideoEncoderNotifyIsDone.json.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
$obj = new stdClass();
$obj->error = true;
global $global, $config;
if(!isset($global['systemRootPath'])){
require_once '../videos/configuration.php';
}
require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'objects/video.php';
$_POST['videos_id'] = intval($_POST['videos_id']);
if (empty($_POST)) {
$obj->msg = __("Your POST data is empty may be your vide file is too big for the host");
_error_log($obj->msg);
die(json_encode($obj));
}
// pass admin user and pass
$user = new User("", @$_POST['user'], @$_POST['password']);
$user->login(false, true);
if (!User::canUpload()) {
$obj->msg = __("Permission denied to Notify Done: " . print_r($_POST, true));
_error_log($obj->msg);
die(json_encode($obj));
}
if(!Video::canEdit($_POST['videos_id'])){
$obj->msg = __("Permission denied to edit a video: " . print_r($_POST, true));
_error_log($obj->msg);
die(json_encode($obj));
}
// check if there is en video id if yes update if is not create a new one
$video = new Video("", "", $_POST['videos_id']);
$obj->video_id = $_POST['videos_id'];
if(empty($_POST['fail'])){
$status = $video->getStatus();
// if status is not unlisted
if($status!=='u' && $status !== 'a'){
if(empty($advancedCustom->makeVideosInactiveAfterEncode)){
// set active
$video->setStatus('a');
}else if(empty($advancedCustom->makeVideosUnlistedAfterEncode)){
// set active
$video->setStatus('u');
}else{
$video->setStatus('i');
}
}
}else{
$video->setStatus('i');
}
$video_id = $video->save();
if(empty($_POST['fail'])){
AVideoPlugin::afterNewVideo($_POST['videos_id']);
}
$obj->error = false;
$obj->video_id = $video_id;
Video::updateFilesize($video_id);
// delete original files if any
$originalFilePath = "{$global['systemRootPath']}videos/original_" . $video->getFilename();
if(file_exists($originalFilePath)){
unlink($originalFilePath);
}
_error_log("Video is done notified {$video_id}: " . $video->getTitle());
die(json_encode($obj));
/*
_error_log(print_r($_POST, true));
_error_log(print_r($_FILES, true));
var_dump($_POST, $_FILES);
*/