forked from WWBN/AVideo-Encoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueue.php
71 lines (64 loc) · 2.27 KB
/
queue.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
<?php
header('Content-Type: application/json');
require_once dirname(__FILE__) . '/../videos/configuration.php';
require_once '../objects/Encoder.php';
require_once '../objects/Login.php';
if(empty($_POST['fileURI'])){
die("File URI Not found");
}
if(!empty($_POST['user']) && !empty($_POST['pass']) && !empty($_POST['notifyURL'])){
error_log("Sent Login variables try to login");
Login::run($_POST['user'], $_POST['pass'], $_POST['notifyURL'], true);
}
$e = new Encoder(@$_POST['id']);
if(empty($e->getId())){
if(!Login::canUpload()){
error_log("This user can not upload files");
exit;
}
if (!($streamers_id = Login::getStreamerId())) {
error_log("There is no streamer site");
exit;
}
$e->setStreamers_id($streamers_id);
$s = new Streamer($streamers_id);
$path_parts = pathinfo($_POST['fileURI']);
if(empty($_POST['filename'])){
$_POST['filename'] = $path_parts['basename'];
}
$e->setFileURI($_POST['fileURI']);
$e->setFilename($_POST['filename']);
$e->setTitle($path_parts['filename']);
$e->setPriority($s->getPriority());
if (!empty($_POST['audioOnly']) && $_POST['audioOnly']!=='false') {
if (!empty($_POST['spectrum']) && $_POST['spectrum']!=='false') {
$e->setFormats_idFromOrder(70); // video to spectrum [(6)MP4 to MP3] -> [(5)MP3 to spectrum] -> [(2)MP4 to webm]
} else {
$e->setFormats_idFromOrder(71);
}
} else {
$e->setFormats_idFromOrder(decideFormatOrder());
}
$obj = new stdClass();
$obj->videos_id = @$_POST['videos_id'];
// notify streamer if need
if(empty($obj->videos_id)){
$f = new Format($e->getFormats_id());
$format = $f->getExtension();
$response = Encoder::sendFile('', 0, $format, $e);
//var_dump($response);exit;
if(!empty($response->response->video_id)){
$obj->videos_id = $response->response->video_id;
}
}
$e->setReturn_vars(json_encode($obj));
$id = $e->save();
}else{
$e->setStatus('queue');
$id = $e->save();
}
// start queue now
$cmd = PHP_BINDIR."/php -f {$global['systemRootPath']}view/run.php > /dev/null 2>/dev/null &";
//echo "** executing command {$cmd}\n";
exec($cmd);
echo json_encode($id);