]> _ Git - tortuga-home.git/commitdiff
.
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 20 Jun 2024 14:30:48 +0000 (16:30 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 20 Jun 2024 14:30:48 +0000 (16:30 +0200)
.idea/workspace.xml
scripts/import.php
scripts/lib/insteon.php [deleted file]
scripts/lib/lib.php
scripts/lib/medialibrary.php
scripts/lib/profile.php
scripts/lib/tmdb.php
scripts/tmdb.php

index 182d281db3a86a1d032e4421e7086276b4104e2c..6abd2748bcf53c0852b0681849fe7462d5d1b140 100644 (file)
@@ -5,12 +5,14 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
-      <change beforePath="$PROJECT_DIR$/.docker/docker-compose.yml" beforeDir="false" afterPath="$PROJECT_DIR$/.docker/docker-compose.yml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/.docker/update" beforeDir="false" afterPath="$PROJECT_DIR$/.docker/update" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/.idea/dataSources.local.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources.local.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/bin/restarthome" beforeDir="false" afterPath="$PROJECT_DIR$/bin/restarthome" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/config/global.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/global.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/import.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/import.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/insteon.php" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/lib.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/lib.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/medialibrary.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/medialibrary.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/profile.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/profile.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/tmdb.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/tmdb.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/tmdb.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/tmdb.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
       <workItem from="1715586628163" duration="670000" />
       <workItem from="1716389152246" duration="475000" />
       <workItem from="1718608940684" duration="1876000" />
-      <workItem from="1718867770014" duration="2012000" />
+      <workItem from="1718867770014" duration="2055000" />
+      <workItem from="1718880511423" duration="3678000" />
+      <workItem from="1718889258103" duration="4286000" />
     </task>
     <task id="LOCAL-00502" summary=".">
       <created>1641726946298</created>
       <option name="project" value="LOCAL" />
       <updated>1687259667913</updated>
     </task>
-    <option name="localTasksCounter" value="617" />
+    <option name="localTasksCounter" value="618" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
index da6175048fd3bed013cfa09e1073b20827713da4..eb9aee85a2e762d496336204cd1505b163273180 100644 (file)
@@ -1,11 +1,18 @@
 <?php
 
+require_once __DIR__ . '/lib/profile.php';
+
 session_set_cookie_params(3600 * 24 * 365, '/', '.enhydra.fr', true);
 session_start();
 
+profile('init session', __FILE__, __LINE__);
+
 require_once __DIR__ . '/environment.php';
+profile('Load environment', __FILE__, __LINE__);
 require_once ROOT . "/vendor/autoload.php";
+profile('Load vendor dependencies', __FILE__, __LINE__);
 require_once ROOT . "/scripts/lib/lib.php";
+profile('Load libraries', __FILE__, __LINE__);
 
 if (defined('TIMELIMIT')) {
     set_time_limit(TIMELIMIT);
@@ -26,6 +33,7 @@ $include = ROOT . "/config/" . getCurrentConfig() . '.php';
 if (file_exists($include)) {
     require_once $include;
 }
+profile('Load configuration', __FILE__, __LINE__);
 
 if (isset($_GET['im'])) {
     returnHttpResponse();
diff --git a/scripts/lib/insteon.php b/scripts/lib/insteon.php
deleted file mode 100644 (file)
index 1a6c129..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-<?php
-
-$insteonBaseURL = 'http://192.168.13.83:25105';
-$insteonAuth = array('t1Kx8wuNWG', 'NA4Hq3v9cM');
-$insteonCommandTimeout = 15;
-$insteonHasKnocked = false;
-
-function insteonCommand($command)
-{
-    $redis = connectRedis();
-    $queue = $redis->igbget('insteon_queue');
-    if (!is_array($queue)) {
-        $queue = [];
-    }
-    $queue[] = $command;
-    $redis->igbset('insteon_queue', $queue);
-    $redis->publish('insteon_event', 'handle_queue');
-}
-
-function runInsteonCommand($command, $attempts = 10)
-{
-    if ($attempts <= 0) {
-        return;
-    }
-
-    insteonClearBuffer();
-    echo "\n" . '-- Command ' . $command . ' attempt #' . $attempts . ' --' . "\n";
-    echo "command : " . _insteonCommand($command) . "\n";
-    for ($i = 1; $i <= 100; $i++) {
-        usleep(1000000 * 0.05);
-        $buff = insteonBuffer();
-        echo $buff . "\n";
-        if (stristr($buff, '0250') || stristr($buff, '0258')) {
-            insteonClearBuffer();
-            return;
-        }
-    }
-    runInsteonCommand($command, $attempts - 1);
-}
-
-function _insteonCommand($command)
-{
-    global $insteonHasKnocked;
-    if (!$insteonHasKnocked) {
-        insteonKnock();
-    }
-    return __insteonCommand($command);
-}
-
-function insteonKnock()
-{
-    global $insteonHasKnocked;
-    $insteonHasKnocked = true;
-    __insteonCommand('1cjdW20oprxzHDZ.htm');
-}
-
-
-function __insteonCommand($command)
-{
-    global $insteonBaseURL, $insteonAuth, $insteonCommandTimeout;
-    return getUrlContent($insteonBaseURL . '/' . $command, $insteonCommandTimeout, $insteonAuth);
-}
-
-function insteonClearBuffer()
-{
-    return _insteonCommand('1?XB=M=1');
-}
-
-function _insteonBufferEmpty()
-{
-    return trim(insteonBuffer(), '0') === '';
-}
-
-function insteonBuffer()
-{
-    global $insteonHasKnocked;
-    $x = _insteonCommand('buffstatus.xml');
-    if ($x !== false && is_object($x)) {
-        $xml = simplexml_load_string($x);
-        return (string)($xml->BS);
-    } else {
-        $insteonHasKnocked = false;
-        insteonKnock();
-        return '';
-    }
-}
\ No newline at end of file
index cabf00199ab1c86d1bfc4eae9f641a176b9d0421..fba0d8478f42b0f20951e6b839964c07b11fc525 100644 (file)
@@ -1,13 +1,9 @@
 <?php
-$insteonQueue = [];
-$insteonLastCallTime = 0;
-$insteonProcessingQueue = false;
 $harmonyClient = null;
 $endQueue = [];
 
 
 require_once ROOT . '/vendor/autoload.php';
-require_once ROOT . '/scripts/lib/profile.php';
 require_once ROOT . "/config/global.php";
 require_once ROOT . '/config/rooms.php';
 require_once ROOT . '/scripts/lib/automodes.php';
index 38062c2c46c30ddc09626698e0442e523536f5a6..05af39bdef3709663a104f125f21c2d282f49515 100644 (file)
@@ -192,7 +192,7 @@ function transcodeOneVideo()
             echo $to . '/exists :' . file_exists($to) . '/size:' . filesize($to) . "\n\n";
         }
 
-        set_time_limit(0);
+        set_time_limit(120);
         ignore_user_abort(true);
 
         if (!getNightMode()) {
index 6596a54105b4d67e88322c2695d49d8f8544682d..ba2f2f4b9cca44dd22b8129a3c0082806daf7b59 100644 (file)
@@ -1,27 +1,69 @@
 <?php
+register_shutdown_function('endProfile');
+$profileStart = $_SERVER['REQUEST_TIME_FLOAT'] ?? microtime(true);
 
-use Illuminate\Support\Str;
+$u = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
 
-require_once ROOT . '/vendor/autoload.php';
+$n = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : '-';
+$n = str_replace('.php', '', $n);
+$n = str_replace('/home/tortugahome/www/', '', $n);
+$n = str_replace('/application/', '', $n);
+$n = str_replace('/', '-', $n);
+$n = trim($n, '/ -');
 
-//$u = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
-//
-//$n = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : '-';
-//$n = str_replace('.php', '', $n);
-//$n = str_replace('/home/tortugahome/www/', '', $n);
-//$n = str_replace('/application/', '', $n);
-//$n = str_replace('/', '-', $n);
-//$n = trim($n, '/ ');
-//
-//$profileFp = fopen('/var/log/tortugahome/profiles/' . Str::slug($n) . '.log', 'a+b');
-//$profileStart = microtime(true);
-//fwrite($profileFp, "\r\n\r\n------------\r\n" . 'URL : ' . $u . "\r\nDate : " . date('Y-m-d H:i:s') . "\r\n" . print_r($_REQUEST, true) . "\r\n\r\n");
+$n = ($_SERVER['HTTP_HOST'] ?? '') . '-' . $n;
 
+
+$dir = '/var/log/tortugahome/profiles/';
+if (!file_exists($dir)) {
+    mkdir($dir, 077, true);
+}
+$f = $dir . slugify($n) . '.log';
+
+$profileFp = fopen($f, 'wb');
+
+fwrite($profileFp, "\r\n\r\n------------\r\n" . 'URL : ' . $u . "\r\nDate : " . date('Y-m-d H:i:s') . "\r\n" . print_r($_REQUEST, true) . "\r\n" . print_r($_SERVER, true) . "\r\n\r\n");
+profile('init profiling', __FILE__, __LINE__);
 function profile($desc, $file = 'unset', $line = 'unset')
 {
-//    global $profileStart, $profileFp;
-//    if (is_resource($profileFp)) {
-//        $ms = round((microtime(true) - $profileStart) * 1000) . 'ms';
-//        fwrite($profileFp, $ms . ';' . $desc . ';' . $file . ';' . $line . "\r\n");
-//    }
+    $mt = microtime(true);
+    global $profileStart, $profileFp;
+    if (is_resource($profileFp)) {
+        $ms = (($mt - $profileStart) * 1000) . 'ms';
+        fwrite($profileFp, $ms . ';' . $mt . ';' . $desc . ';' . $file . ';' . $line . "\r\n");
+    }
+}
+
+function endProfile()
+{
+    global $profileFp;
+    profile('END profile', __FILE__, __LINE__);
+    fclose($profileFp);
+}
+
+function slugify($text, string $divider = '-')
+{
+    // replace non letter or digits by divider
+    $text = preg_replace('~[^\pL\d]+~u', $divider, $text);
+
+    // transliterate
+    $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
+
+    // remove unwanted characters
+    $text = preg_replace('~[^-\w]+~', '', $text);
+
+    // trim
+    $text = trim($text, $divider);
+
+    // remove duplicate divider
+    $text = preg_replace('~-+~', $divider, $text);
+
+    // lowercase
+    $text = strtolower($text);
+
+    if (empty($text)) {
+        return 'n-a';
+    }
+
+    return $text;
 }
\ No newline at end of file
index 7d5e78a731be7feaf4ff9a1ef134cb4fc4dc8891..bdc383947f46f8c3d00e1909531bdc147ac7b063 100644 (file)
@@ -261,7 +261,7 @@ class tvShowLibrary extends mediaLibrary
     {
         global $videoExt;
 
-        set_time_limit(0);
+        set_time_limit(10);
 
         $e = explode(':', $tvShow['dir']);
         if ($e[0] === 'netflix') {
index f6c3c00726489ec8958e913321e04992bdb5ce35..24e8dcc3d02cc34e630ca8087fdf5fcf6a9d7993 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 ob_start();
 require_once 'import.php';
-set_time_limit(0);
+set_time_limit(120);
 kodiGetTVShowAllStatus(true);
 kodiGetAllKodiToTmdb(true);
 _getTVShows(true, false);