Skip to content

Commit

Permalink
Let submitter specify the desired video status
Browse files Browse the repository at this point in the history
This adds a drop-down menu in upload interface so that the video
status after upload can be specified. Default is to let the streamer
configuration do the job, as it does without the modification.

This requires a forthcoming modification to AVideo so that the
request is honoured.
  • Loading branch information
manu0401 committed Feb 11, 2021
1 parent 5cf7d64 commit 6272cfe
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 3 deletions.
4 changes: 3 additions & 1 deletion install/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ CREATE TABLE IF NOT EXISTS `encoder_queue` (
`videoDownloadedLink` VARCHAR(255) NULL,
`downloadedFileName` VARCHAR(255) NULL,
`streamers_id` INT NOT NULL,
`override_status` VARCHAR(45) NULL
`status` VARCHAR(45) NULL,
`formats_id` INT NOT NULL,
`created` DATETIME NULL,
`modified` DATETIME NULL,
Expand Down Expand Up @@ -150,4 +152,4 @@ INSERT INTO `formats` VALUES (31,'Dynamic MP4','-vf scale=-2:{$resolution} -movf
INSERT INTO `formats` VALUES (32,'Dynamic WEBM','-vf scale=-2:{$resolution} -movflags +faststart -preset veryfast -f webm -c:v libvpx -b:v 1M -acodec libvorbis -b:a {$autioBitrate}k -y {$destinationFile}',now(),now(),'webm','mp4',8);
INSERT INTO `formats` VALUES (33,'Audio to HLS','',now(),now(),'m3u8','mp3',88);
INSERT INTO `formats` VALUES (34,'Audio to MP4','',now(),now(),'mp4','mp3',89);
INSERT INTO `formats` VALUES (35,'Audio to WEBM','',now(),now(),'webm','mp3',90);
INSERT INTO `formats` VALUES (35,'Audio to WEBM','',now(),now(),'webm','mp3',90);
27 changes: 26 additions & 1 deletion objects/Encoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class Encoder extends ObjectYPT {

protected $id, $fileURI, $filename, $status, $status_obs, $return_vars, $worker_pid, $priority, $created, $modified, $formats_id, $title, $videoDownloadedLink, $downloadedFileName, $streamers_id;
protected $id, $fileURI, $filename, $status, $status_obs, $return_vars, $worker_pid, $priority, $created, $modified, $formats_id, $title, $videoDownloadedLink, $downloadedFileName, $streamers_id, $override_status;

static function getSearchFieldsNames() {
return array('filename');
Expand Down Expand Up @@ -198,6 +198,14 @@ function setStreamers_id($streamers_id) {
$this->streamers_id = $streamers_id;
}

function getOverride_status() {
return $this->override_status;
}

function setOverride_status($override_status) {
$this->override_status = $override_status;
}

function setFormats_id($formats_id) {
if (!preg_match('/^[0-9]+$/', $formats_id)) {
$formats_id = Format::createIfNotExists($formats_id);
Expand Down Expand Up @@ -679,6 +687,10 @@ private function notifyVideoIsDone($fail = 0) {
'password' => $pass,
'fail' => $fail
);

if (!empty($this->override_status))
$postFields['overrideStatus'] = $this->override_status;

$obj->postFields = $postFields;

$curl = curl_init();
Expand Down Expand Up @@ -935,6 +947,19 @@ static function sendFile($file, $videos_id, $format, $encoder = null, $resolutio
'encoderURL' => $global['webSiteRootURL'],
'keepEncoding' => $keep_encoding ? "1" : "0",
);

if (!empty($encoder->override_status)) {
$override_status = $encoder->override_status;

// If unfinished progressive upload, status is
// active and coding (k) if active (a) was requested
// or encoding (e) otherwise.
if ($keep_encoding)
$override_status = $override_status == 'a' ? 'k' : 'e';

$postFields['overrideStatus'] = $override_status;
}

$count = 0;
foreach ($usergroups_id as $value) {
$postFields["usergroups_id[{$count}]"] = $value;
Expand Down
1 change: 1 addition & 0 deletions update/updateDb.v3.5.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ CREATE TABLE IF NOT EXISTS `upload_queue` (
ON UPDATE CASCADE)
ENGINE = InnoDB;

ALTER TABLE `encoder_queue` ADD COLUMN `override_status` VARCHAR(45) NULL;

SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
Expand Down
11 changes: 11 additions & 0 deletions view/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,15 @@ function checkProgress() {

}
});
<div class="form-group">
<select class="form-control" id="override_status" name="override_status">

<option value="">Override status - Use site default</option>
<option value="a">Active</option>
<option value="i">Inactive</option>
<option value="u">Unlisted</option>
</select>
</div>
}

function createQueueItem(queueItem, queueItemAfter) {
Expand Down Expand Up @@ -724,6 +733,7 @@ function (isConfirm) {
"audioOnly": $('#inputAudioOnly').is(":checked"),
"spectrum": $('#inputAudioSpectrum').is(":checked"),
"webm": $('#inputWebM').is(":checked"),
"override_status": $('#override_status').val(),
"inputHLS": $('#inputHLS').is(":checked"),
"inputLow": $('#inputLow').is(":checked"),
"inputSD": $('#inputSD').is(":checked"),
Expand Down Expand Up @@ -786,6 +796,7 @@ function (isConfirm) {
"audioOnly": $('#inputAudioOnly').is(":checked"),
"spectrum": $('#inputAudioSpectrum').is(":checked"),
"webm": $('#inputWebM').is(":checked"),
"override_status": $('#override_status').val(),
"inputHLS": $('#inputHLS').is(":checked"),
"inputLow": $('#inputLow').is(":checked"),
"inputSD": $('#inputSD').is(":checked"),
Expand Down
2 changes: 2 additions & 0 deletions view/jquery-file-upload/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ $(function () {
"audioOnly": $('#inputAudioOnly').is(":checked"),
"spectrum": $('#inputAudioSpectrum').is(":checked"),
"webm": $('#inputWebM').is(":checked"),
"override_status": $('#override_status').val(),
"inputHLS": $('#inputHLS').is(":checked"),
"inputLow": $('#inputLow').is(":checked"),
"inputSD": $('#inputSD').is(":checked"),
Expand All @@ -141,6 +142,7 @@ $(function () {
"audioOnly": $('#inputAudioOnly').is(":checked"),
"spectrum": $('#inputAudioSpectrum').is(":checked"),
"webm": $('#inputWebM').is(":checked"),
"override_status": $('#override_status').val(),
"inputHLS": $('#inputHLS').is(":checked"),
"inputLow": $('#inputLow').is(":checked"),
"inputSD": $('#inputSD').is(":checked"),
Expand Down
3 changes: 2 additions & 1 deletion view/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@
$e->setFormats_id(3);
}
}

if (!empty($_POST['override_status']))
$e->setOverride_status($_POST['override_status']);

$obj = new stdClass();
$f = new Format($e->getFormats_id());
Expand Down

0 comments on commit 6272cfe

Please sign in to comment.