Skip to content

Commit

Permalink
https://github.com/WWBN/AVideo/issues/8576
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel authored and daniel committed Oct 26, 2023
1 parent 3199cb1 commit 05237b4
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 87 deletions.
100 changes: 56 additions & 44 deletions objects/functions.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

stream_context_set_default([
'ssl' => [
'verify_peer' => false,
Expand Down Expand Up @@ -405,10 +404,10 @@ function status($statusarray) {
}
} else {
echo json_encode(array_map(
function ($text) {
return nl2br($text);
},
$statusarray
function ($text) {
return nl2br($text);
},
$statusarray
));
}
}
Expand Down Expand Up @@ -447,26 +446,25 @@ function parseSecondsToDuration($seconds) {
return secondsToVideoTime($seconds);
}


function decideFromPlugin() {
$advancedCustom = getAdvancedCustomizedObjectData();
if (!empty($advancedCustom->showOnlyEncoderAutomaticResolutions)) {
return array("mp4" => 7, "webm" => 8);
}
if (
empty($advancedCustom->doNotShowEncoderResolutionLow) && empty($advancedCustom->doNotShowEncoderResolutionSD) && empty($advancedCustom->doNotShowEncoderResolutionHD)) {
empty($advancedCustom->doNotShowEncoderResolutionLow) && empty($advancedCustom->doNotShowEncoderResolutionSD) && empty($advancedCustom->doNotShowEncoderResolutionHD)) {
return array("mp4" => 80, "webm" => 87);
}
if (
empty($advancedCustom->doNotShowEncoderResolutionLow) && empty($advancedCustom->doNotShowEncoderResolutionSD)) {
empty($advancedCustom->doNotShowEncoderResolutionLow) && empty($advancedCustom->doNotShowEncoderResolutionSD)) {
return array("mp4" => 77, "webm" => 84);
}
if (
empty($advancedCustom->doNotShowEncoderResolutionLow) && empty($advancedCustom->doNotShowEncoderResolutionHD)) {
empty($advancedCustom->doNotShowEncoderResolutionLow) && empty($advancedCustom->doNotShowEncoderResolutionHD)) {
return array("mp4" => 79, "webm" => 86);
}
if (
empty($advancedCustom->doNotShowEncoderResolutionSD) && empty($advancedCustom->doNotShowEncoderResolutionHD)) {
empty($advancedCustom->doNotShowEncoderResolutionSD) && empty($advancedCustom->doNotShowEncoderResolutionHD)) {
return array("mp4" => 78, "webm" => 85);
}
if (empty($advancedCustom->doNotShowEncoderResolutionLow)) {
Expand Down Expand Up @@ -513,42 +511,42 @@ function decideFormatOrder() {
} elseif (empty($_POST['webm']) || $_POST['webm'] === 'false') {
// mp4 only
if (
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false' &&
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false' &&
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
) { // all resolutions
error_log("decideFormatOrder: MP4 All");
return (80);
} elseif (
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
) {
error_log("decideFormatOrder: MP4 Low - HD");
return (79);
} elseif (
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false' &&
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false' &&
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
) {
error_log("decideFormatOrder: MP4 SD - HD");
return (78);
} elseif (
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false'
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false'
) {
error_log("decideFormatOrder: MP4 Low SD");
return (77);
} elseif (
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
) {
error_log("decideFormatOrder: MP4 HD");
return (76);
} elseif (
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false'
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false'
) {
error_log("decideFormatOrder: MP4 SD");
return (75);
} elseif (
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false'
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false'
) {
error_log("decideFormatOrder: MP4 LOW");
return (74);
Expand All @@ -559,36 +557,36 @@ function decideFormatOrder() {
} else {
// mp4 and webm
if (
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false' &&
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false' &&
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
) { // all resolutions
return (87);
} elseif (
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
) {
return (86);
} elseif (
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false' &&
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false' &&
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
) {
return (85);
} elseif (
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false'
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false'
) {
return (84);
} elseif (
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
) {
return (83);
} elseif (
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false'
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false'
) {
return (82);
} elseif (
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false'
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false'
) {
return (81);
} else {
Expand Down Expand Up @@ -668,8 +666,8 @@ function zipDirectory($destinationFile) {
// Create recursive directory iterator
/** @var SplFileInfo[] $files */
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($rootPath),
RecursiveIteratorIterator::LEAVES_ONLY
new RecursiveDirectoryIterator($rootPath),
RecursiveIteratorIterator::LEAVES_ONLY
);

foreach ($files as $name => $file) {
Expand Down Expand Up @@ -1032,9 +1030,9 @@ function isURL200($url) {
$result = false;
foreach ($headers as $value) {
if (
strpos($value, '200') ||
strpos($value, '302') ||
strpos($value, '304')
strpos($value, '200') ||
strpos($value, '302') ||
strpos($value, '304')
) {
$result = true;
}
Expand Down Expand Up @@ -1105,8 +1103,8 @@ function isURLaVODVideo($url) {

// If the main playlist has an ENDLIST tag, it's a VOD
if (preg_match('/#EXT-X-ENDLIST/i', $content) ||
preg_match('/#EXT-X-PLAYLIST-TYPE:\s*VOD/i', $content) ||
preg_match('/URI=".+enc_[0-9a-z]+.key/i', $content)) {
preg_match('/#EXT-X-PLAYLIST-TYPE:\s*VOD/i', $content) ||
preg_match('/URI=".+enc_[0-9a-z]+.key/i', $content)) {
return true; // VOD content
}

Expand All @@ -1130,7 +1128,6 @@ function isURLaVODVideo($url) {
return true;
}


function _utf8_encode($string) {
global $global;

Expand Down Expand Up @@ -1172,7 +1169,7 @@ function _sys_get_temp_dir() {
return $dir;
}

function _get_temp_file($prefix='') {
function _get_temp_file($prefix = '') {
return tempnam(_sys_get_temp_dir(), $prefix);
}

Expand All @@ -1195,7 +1192,6 @@ function convertDates() {
}
}


function convertToServerDate($originalDateTime, $fromTimezone) {
$serverTimezone = date_default_timezone_get();
$dateTime = new DateTime($originalDateTime, new DateTimeZone($fromTimezone));
Expand All @@ -1206,3 +1202,19 @@ function convertToServerDate($originalDateTime, $fromTimezone) {
// Print the converted datetime
return $dateTime->format('Y-m-d H:i:s');
}

function getCategoriesSelect($id) {
?>
<select class="form-control categories_id" id="<?php echo $id; ?>" name="<?php echo $id; ?>">

<option value="0"><?php echo __('Category - Use site default'); ?></option>
<?php
array_multisort(array_column($_SESSION['login']->categories, 'hierarchyAndName'), SORT_ASC, $_SESSION['login']->categories);
foreach ($_SESSION['login']->categories as $key => $value) {
echo '<option value="' . $value->id . '">' . $value->hierarchyAndName . '</option>';
}
?>
</select>
<?php
}

26 changes: 6 additions & 20 deletions view/index_shareVideos.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,9 @@
?>
<div class="form-group">
<div style="display: flex;">
<select class="form-control categories_id" id="download_categories_id" name="download_categories_id">

<option value="0"><?php echo __('Category - Use site default'); ?></option>
<?php
array_multisort(array_column($_SESSION['login']->categories, 'hierarchyAndName'), SORT_ASC, $_SESSION['login']->categories);
foreach ($_SESSION['login']->categories as $key => $value) {
echo '<option value="' . $value->id . '">' . $value->hierarchyAndName . '</option>';
}
?>
</select>
<?php
echo getCategoriesSelect('download_categories_id');
?>
<?php
if (Login::canCreateCategory()) {
?>
Expand Down Expand Up @@ -148,16 +141,9 @@ function reloadIfIsNotEditingCategory() {
?>
<div class="form-group">
<div style="display: flex;">
<select class="form-control categories_id" id="bulk_categories_id" name="bulk_categories_id">

<option value="0"><?php echo __('Category - Use site default'); ?></option>
<?php
array_multisort(array_column($_SESSION['login']->categories, 'hierarchyAndName'), SORT_ASC, $_SESSION['login']->categories);
foreach ($_SESSION['login']->categories as $key => $value) {
echo '<option value="' . $value->id . '">' . $value->hierarchyAndName . '</option>';
}
?>
</select>
<?php
echo getCategoriesSelect('bulk_categories_id');
?>
<?php
if (Login::canCreateCategory()) {
?>
Expand Down
13 changes: 3 additions & 10 deletions view/jquery-file-upload/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,9 @@
?>
<div class="form-group">
<div style="display: flex;">
<select class="form-control categories_id" id="categories_id" name="categories_id">

<option value="0"><?php echo __('Category - Use site default'); ?></option>
<?php
array_multisort(array_column($_SESSION['login']->categories, 'hierarchyAndName'), SORT_ASC, $_SESSION['login']->categories);
foreach ($_SESSION['login']->categories as $key => $value) {
echo '<option value="' . $value->id . '">' . $value->hierarchyAndName . '</option>';
}
?>
</select>
<?php
echo getCategoriesSelect('categories_id_upload');
?>
<?php
if (Login::canCreateCategory()) {
?>
Expand Down
4 changes: 2 additions & 2 deletions view/jquery-file-upload/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ $(function () {
"inputAutoAudio": $('#inputAutoAudio').is(":checked"),
"title": $('#title').val(),
"description": $('#description').val(),
"categories_id": $('#categories_id').val(),
"categories_id": $('#categories_id_upload').val(),
"callback": $('#callback').val(),
"usergroups_id": $(".usergroups_id:checked").map(function () {
return $(this).val();
Expand Down Expand Up @@ -183,7 +183,7 @@ $(function () {
"inputAutoAudio": $('#inputAutoAudio').is(":checked"),
"title": $('#title').val(),
"description": $('#description').val(),
"categories_id": $('#categories_id').val(),
"categories_id": $('#categories_id_upload').val(),
"releaseDate": $('#releaseDate').val(),
"callback": $('#callback').val(),
"timezone": timezone,
Expand Down
2 changes: 1 addition & 1 deletion view/mini-upload-form/assets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ $(function () {
"inputHD": $('#inputHD').is(":checked"),
"title": $('#title').val(),
"description": $('#description').val(),
"categories_id": $('#categories_id').val(),
"categories_id": $('#categories_id_upload').val(),
"releaseDate": $('#releaseDate').val(),
"callback": $('#callback').val(),
"timezone": timezone,
Expand Down
14 changes: 4 additions & 10 deletions view/mini-upload-form/form.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- not used -->
<link href="view/mini-upload-form/assets/css/style.css" rel="stylesheet" />
<form id="upload" method="post" action="<?= $global['webSiteRootURL'] ?>upload" enctype="multipart/form-data">
<div class="form-group">
Expand All @@ -11,16 +12,9 @@
?>
<div class="form-group">
<div style="display: flex;">
<select class="form-control categories_id" id="categories_id" name="categories_id">

<option value="0"><?php echo __('Category - Use site default'); ?></option>
<?php
array_multisort(array_column($_SESSION['login']->categories, 'hierarchyAndName'), SORT_ASC, $_SESSION['login']->categories);
foreach ($_SESSION['login']->categories as $key => $value) {
echo '<option value="' . $value->id . '">' . $value->hierarchyAndName . '</option>';
}
?>
</select>
<?php
echo getCategoriesSelect('categories_id_miniupload');
?>
<?php
if (Login::canCreateCategory()) {
?>
Expand Down

0 comments on commit 05237b4

Please sign in to comment.