[FIX] Fix slowness of webUI

This commit is contained in:
Boris 2021-09-25 15:30:19 +02:00
parent 1121d8c9fd
commit 624de324ca
1 changed files with 13 additions and 7 deletions

View File

@ -2,6 +2,12 @@
require_once('conf.php'); require_once('conf.php');
require_once('functions.php'); require_once('functions.php');
$i = 0;
$div = 9;
$r = rand(0, ($div - 1));
$j = 0;
$maxElt = 16;
// require('php-ipfs-api/vendor/autoload.php'); // require('php-ipfs-api/vendor/autoload.php');
// use Cloutier\PhpIpfsApi\IPFS; // use Cloutier\PhpIpfsApi\IPFS;
// $ipfs = new IPFS("astroport", "8181", IPFS_API_PORT); // $ipfs = new IPFS("astroport", "8181", IPFS_API_PORT);
@ -12,6 +18,7 @@ require_once('functions.php');
$uriParams = []; $uriParams = [];
$videosList = array(); $videosList = array();
$videosListURIs = array();
$search = isset($_GET['search']) ? urldecode($_GET['search']) : ""; $search = isset($_GET['search']) ? urldecode($_GET['search']) : "";
exec("/bin/bash -c './get_astrxbian_index.sh \"*\" \"". $search . "\"'", $videos); exec("/bin/bash -c './get_astrxbian_index.sh \"*\" \"". $search . "\"'", $videos);
exec("/bin/bash -c './get_PIN.sh'", $pinnedVideos); exec("/bin/bash -c './get_PIN.sh'", $pinnedVideos);
@ -23,10 +30,6 @@ exec("/bin/bash -c './get_PIN.sh'", $pinnedVideos);
// echo shell_exec('whoami'); // Pour savoir quel utilisateur système exécute les scripts PHP // echo shell_exec('whoami'); // Pour savoir quel utilisateur système exécute les scripts PHP
// echo '<pre>'; var_dump($videos); echo '</pre>'; exit; // echo '<pre>'; var_dump($videos); echo '</pre>'; exit;
$i = 0;
$div = 9;
$r = rand(0, ($div - 1));
$j = 0;
$tagsMenu = array(); $tagsMenu = array();
$narrowingTags = array(); $narrowingTags = array();
$show = isset($_GET['show']) ? $_GET['show'] : 'pinned'; $show = isset($_GET['show']) ? $_GET['show'] : 'pinned';
@ -49,7 +52,7 @@ foreach ($videos as $v) {
list($contentType, $videoID, $year, $filename, $saison, $tagsStr, $ipnsHash, $definition, $videoURI) = explode(";", $v); list($contentType, $videoID, $year, $filename, $saison, $tagsStr, $ipnsHash, $definition, $videoURI) = explode(";", $v);
if (in_array_column($videoURI, 'uri', $videosList)) { if (in_array($videoURI, $videosListURIs)) {
continue; continue;
} }
@ -76,7 +79,6 @@ foreach ($videos as $v) {
if ($keepVideo) { if ($keepVideo) {
$narrowingTags = array_merge($narrowingTags, $videoTags); $narrowingTags = array_merge($narrowingTags, $videoTags);
/* /*
++$i; ++$i;
if ($i % $div != $r) { if ($i % $div != $r) {
@ -84,11 +86,12 @@ foreach ($videos as $v) {
} }
++$j; ++$j;
if ($j > 9) { if ($j > $maxElt) {
break; break;
} }
*/ */
$duration = NULL; $duration = NULL;
$thumbURL = ''; $thumbURL = '';
$videoTitle = NULL; $videoTitle = NULL;
@ -96,6 +99,7 @@ foreach ($videos as $v) {
if (($contentType == 'youtube') and ($videoSource == 'www.youtube.com')) { if (($contentType == 'youtube') and ($videoSource == 'www.youtube.com')) {
$thumbURL = sprintf(YOUTUBE_THUMB, $videoID); $thumbURL = sprintf(YOUTUBE_THUMB, $videoID);
// $thumbURL = '';
// $json = getVideoJson($ipnsHash); // $json = getVideoJson($ipnsHash);
@ -115,6 +119,8 @@ foreach ($videos as $v) {
$thumbURL = 'styles/'. THEME .'/font-awesome/film.white.90x90.png'; $thumbURL = 'styles/'. THEME .'/font-awesome/film.white.90x90.png';
} }
$videosListURIs[] = $videoURI;
$videosList[] = [ $videosList[] = [
'duration' => $duration, 'duration' => $duration,
'thumbURL' => $thumbURL, 'thumbURL' => $thumbURL,