Repository navigation
Expand file tree
/
Copy pathqueue.php
More file actions
98 lines (89 loc) · 3.23 KB
/
Copy pathqueue.php
File metadata and controls
98 lines (89 loc) · 3.23 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
header('Content-Type: application/json');
require_once dirname(__FILE__) . '/../videos/configuration.php';
require_once '../objects/Encoder.php';
require_once '../objects/Login.php';
session_write_close();
if (empty($_POST['fileURI'])) {
die("File URI Not found");
}
if (!empty($_POST['user']) && !empty($_POST['pass']) && !empty($_POST['notifyURL'])) {
error_log("login.json: Login::run");
$error = "Sent Login variables try to login";
if (isCommandLineInterface()) {
echo $error . PHP_EOL;
}
error_log($error);
Login::run($_POST['user'], $_POST['pass'], $_POST['notifyURL'], isCommandLineInterface() ? false : true);
}
$e = new Encoder(@$_POST['id']);
if (empty($e->getId())) {
if (!Login::canUpload()) {
$error = "This user can not upload files User=" . Login::getStreamerUser() . " URL=" . Login::getStreamerURL();
if (isCommandLineInterface()) {
echo $error . PHP_EOL;
}
error_log($error);
exit;
}
if (!($streamers_id = Login::getStreamerId())) {
$error = "There is no streamer site";
if (isCommandLineInterface()) {
echo $error . PHP_EOL;
}
error_log($error);
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']);
if (!empty($_POST['videoDownloadedLink'])) {
$e->setVideoDownloadedLink($_POST['videoDownloadedLink']);
}
$e->setFilename($_POST['filename']);
$e->setTitle($path_parts['filename']);
$e->setPriority($s->getPriority());
if (strtolower(pathinfo($_POST['fileURI'], PATHINFO_EXTENSION)) === 'mp3') {
$e->setFormats_idFromOrder(89); //Audio to MP4
}else 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();
error_log("queue : Encoder::sendFile");
$response = Encoder::sendFile('', 0, $format, $e);
error_log("queue : Encoder::sendFile done");
//var_dump($response);exit;
if (!empty($response->response->video_id)) {
$obj->videos_id = $response->response->video_id;
}
if (!empty($response->response->video_id_hash)) {
$obj->video_id_hash = $response->response->video_id_hash;
}
}
$e->setReturn_vars(json_encode($obj));
error_log("queue: will save");
$id = $e->save();
error_log("queue: save done [$id]");
} else {
$e->setStatus(Encoder::STATUS_QUEUE);
$id = $e->save();
$obj = Encoder::getVideosId($id);
}
// start queue now
execRun();
echo json_encode($id);