]> _ Git - tortuga-home.git/commitdiff
.
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Sun, 16 Jul 2023 12:13:26 +0000 (14:13 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Sun, 16 Jul 2023 12:13:26 +0000 (14:13 +0200)
.docker/config/httpd/httpd.conf
.idea/workspace.xml
bin/updatedns.bat [new file with mode: 0644]
scripts/lib/kodi.php

index d559470fba6b1f077603b6d4145ce79c40ebf9b8..b5e6a9534148e57c67c69c99f51f73594f84f7f9 100644 (file)
@@ -297,7 +297,7 @@ RemoteIPInternalProxy nginx-proxy
 
 <Location />
    <RequireAny>
-        Require ip 127.0.0.0/8 192.168.0.0/16 172.0.0.0/8 172.27.13.0/24
+        Require ip 127.0.0.0/8 192.168.0.0/16 172.0.0.0/8 172.27.13.0/24 130.180.213.67
    </RequireAny>
 </Location>
 
index a6e545ca206369328db0f05698975d5b3ed0971f..bd93f09030ccab43bb262d130e53551f90260a1c 100644 (file)
@@ -5,8 +5,10 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
+      <change afterPath="$PROJECT_DIR$/bin/updatedns.bat" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/.docker/config/httpd/httpd.conf" beforeDir="false" afterPath="$PROJECT_DIR$/.docker/config/httpd/httpd.conf" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/config/dnsmasq.conf" beforeDir="false" afterPath="$PROJECT_DIR$/config/dnsmasq.conf" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/kodi.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/kodi.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
     &quot;deletionFromPopupRequiresConfirmation&quot;: &quot;false&quot;,
     &quot;git-widget-placeholder&quot;: &quot;master&quot;,
     &quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
-    &quot;last_opened_file_path&quot;: &quot;D:/Works/tortuga-home/scripts&quot;,
+    &quot;last_opened_file_path&quot;: &quot;D:/Works/tortuga-home/bin&quot;,
     &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
     &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
     &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
       <recent name="T:\Drive\Works\home\images\rooms" />
     </key>
   </component>
-  <component name="RunManager" selected="Shell Script.Docker terminal">
+  <component name="RunManager" selected="Shell Script.Update DNS">
     <configuration default="true" type="Applet">
       <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
       <method v="2">
       <envs />
       <method v="2" />
     </configuration>
+    <configuration name="Update DNS" type="ShConfigurationType">
+      <option name="SCRIPT_TEXT" value="" />
+      <option name="INDEPENDENT_SCRIPT_PATH" value="false" />
+      <option name="SCRIPT_PATH" value="$PROJECT_DIR$/bin/updatedns.bat" />
+      <option name="SCRIPT_OPTIONS" value="" />
+      <option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="false" />
+      <option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$/bin" />
+      <option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
+      <option name="INTERPRETER_PATH" value="" />
+      <option name="INTERPRETER_OPTIONS" value="" />
+      <option name="EXECUTE_IN_TERMINAL" value="true" />
+      <option name="EXECUTE_SCRIPT_FILE" value="true" />
+      <envs />
+      <method v="2" />
+    </configuration>
     <configuration name="adb-connect" type="ShConfigurationType" temporary="true">
       <option name="SCRIPT_TEXT" value="" />
       <option name="INDEPENDENT_SCRIPT_PATH" value="true" />
     </configuration>
     <list>
       <item itemvalue="Shell Script.Docker terminal" />
+      <item itemvalue="Shell Script.Update DNS" />
       <item itemvalue="Shell Script.adb-connect" />
     </list>
     <recent_temporary>
       <workItem from="1689380685431" duration="1796000" />
       <workItem from="1689413024548" duration="85000" />
       <workItem from="1689413321160" duration="1300000" />
+      <workItem from="1689419400638" duration="1484000" />
+      <workItem from="1689437591381" duration="1562000" />
     </task>
     <task id="LOCAL-00502" summary=".">
       <created>1641726946298</created>
       <option name="project" value="LOCAL" />
       <updated>1687259667913</updated>
     </task>
-    <option name="localTasksCounter" value="578" />
+    <option name="localTasksCounter" value="579" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
diff --git a/bin/updatedns.bat b/bin/updatedns.bat
new file mode 100644 (file)
index 0000000..186796b
--- /dev/null
@@ -0,0 +1,5 @@
+@echo off
+C:\tools\cygwin\bin\ssh.exe -tt root@192.168.13.6 '/usr/local/bin/updatedns'
+C:\tools\cygwin\bin\ssh.exe -tt root@192.168.13.7 '/usr/local/bin/updatedns'
+C:\tools\cygwin\bin\ssh.exe -tt root@192.168.13.64 '/usr/local/bin/updatedns'
+C:\tools\cygwin\bin\ssh.exe -tt root@192.168.13.67 '/usr/local/bin/updatedns'
\ No newline at end of file
index 21c968c0f3732463f71b5929b55562943ce46da5..ae2bcaab3cf4233b677b8893204d96abac49ab3f 100644 (file)
@@ -4,182 +4,186 @@ $kodiIP = ['salon' => '192.168.13.40', 'bureau' => '192.168.13.41', 'avion' => '
 $_tvshowallstatus = null;
 $_koditotmdb = null;
 
-function getKodiDBConnection()
-{
-    return mysqli_connect('kodidb.home.tortuga.enhydra.fr', "root", "4xNkxCDAyWrp5VVthtgS", "MyVideos121",3307);
+function getKodiDBConnection() {
+       return @mysqli_connect('192.168.13.7', "root", "4xNkxCDAyWrp5VVthtgS", "MyVideos121", 3307);
 }
 
-function kodiGetAllKodiToTmdb($force = false)
-{
-    global $_koditotmdb;
-    if ($force || null === $_koditotmdb) {
-        try {
-            $_koditotmdb = connectRedis()->igbget('kodi.koditotmdb');
-        } catch (Exception $e) {
-            $_koditotmdb = false;
-        }
-
-        if ($force || $_koditotmdb === false) {
-            $_koditotmdb = [];
-            $con = getKodiDBConnection();
-            $result = mysqli_query($con, "SELECT media_id,value FROM uniqueid WHERE `type`='tmdb'");
-            while ($r = $result->fetch_assoc()) {
-                $_koditotmdb[$r['media_id']] = $r['value'];
-            }
-            connectRedis()->igbsetex('kodi.koditotmdb', 7200, $_koditotmdb);
-        }
-    }
-    return $_koditotmdb;
+function kodiGetAllKodiToTmdb($force = false) {
+       global $_koditotmdb;
+       if ($force || null === $_koditotmdb) {
+               try {
+                       $_koditotmdb = connectRedis()->igbget('kodi.koditotmdb');
+               } catch (Exception $e) {
+                       $_koditotmdb = false;
+               }
+
+               if ($force || $_koditotmdb === false) {
+                       $_koditotmdb = [];
+                       $con = getKodiDBConnection();
+                       if(!$con){
+                               return [];
+                       }
+                       $result = mysqli_query($con, "SELECT media_id,value FROM uniqueid WHERE `type`='tmdb'");
+                       while ($r = $result->fetch_assoc()) {
+                               $_koditotmdb[$r['media_id']] = $r['value'];
+                       }
+                       connectRedis()->igbsetex('kodi.koditotmdb', 7200, $_koditotmdb);
+               }
+       }
+       return $_koditotmdb;
 }
 
-function kodiGetTVShowAllStatus($force = false)
-{
-    global $_tvshowallstatus;
-
-    if ($force || null === $_tvshowallstatus) {
-        try {
-            $_tvshowallstatus = connectRedis()->igbget('kodi.tvshow.status');
-        } catch (Exception $e) {
-            $_tvshowallstatus = false;
-        }
-
-        if ($force || $_tvshowallstatus === false) {
-            $con = getKodiDBConnection();
-            $result = mysqli_query($con, 'SELECT idShow,totalCount,watchedcount FROM tvshow_view');
-            if (!$result) {
-                print_r(mysqli_error_list($con));
-            }
-            $_tvshowallstatus = [];
-            while ($r = $result->fetch_assoc()) {
-                if ($r['watchedcount'] == null || !$r['watchedcount']) {
-                    $wc = 0;
-                } else {
-                    $wc = (int)$r['watchedcount'];
-                }
-
-                if ($r['totalCount'] == null || !$r['totalCount']) {
-                    $tc = 0;
-                } else {
-                    $tc = (int)$r['totalCount'];
-                }
-
-                if ($tc === 0) {
-                    $status = 3;
-                } else if ($wc >= $tc) {
-                    $status = 2;
-                } else if ($wc == 0) {
-                    $status = 1;
-                } else if ($wc < $tc) {
-                    $status = 0;
-                }
-                $_tvshowallstatus[kodiToTMDB($r['idShow'])] = $status;
-            }
-            connectRedis()->igbsetex('kodi.tvshow.status', 7200, $_tvshowallstatus);
-        }
-    }
-    return $_tvshowallstatus;
+function kodiGetTVShowAllStatus($force = false) {
+       global $_tvshowallstatus;
+
+       if ($force || null === $_tvshowallstatus) {
+               try {
+                       $_tvshowallstatus = connectRedis()->igbget('kodi.tvshow.status');
+               } catch (Exception $e) {
+                       $_tvshowallstatus = false;
+               }
+
+               if ($force || $_tvshowallstatus === false) {
+                       $con = getKodiDBConnection();
+                       if(!$con){
+                               return [];
+                       }
+                       $result = mysqli_query($con, 'SELECT idShow,totalCount,watchedcount FROM tvshow_view');
+                       if (!$result) {
+                               print_r(mysqli_error_list($con));
+                       }
+                       $_tvshowallstatus = [];
+                       while ($r = $result->fetch_assoc()) {
+                               if ($r['watchedcount'] == null || !$r['watchedcount']) {
+                                       $wc = 0;
+                               } else {
+                                       $wc = (int)$r['watchedcount'];
+                               }
+
+                               if ($r['totalCount'] == null || !$r['totalCount']) {
+                                       $tc = 0;
+                               } else {
+                                       $tc = (int)$r['totalCount'];
+                               }
+
+                               if ($tc === 0) {
+                                       $status = 3;
+                               } else if ($wc >= $tc) {
+                                       $status = 2;
+                               } else if ($wc == 0) {
+                                       $status = 1;
+                               } else if ($wc < $tc) {
+                                       $status = 0;
+                               }
+                               $_tvshowallstatus[kodiToTMDB($r['idShow'])] = $status;
+                       }
+                       connectRedis()->igbsetex('kodi.tvshow.status', 7200, $_tvshowallstatus);
+               }
+       }
+       return $_tvshowallstatus;
 }
 
-function kodiGetTVShowStatus($id)
-{
-    $allstatus = kodiGetTVShowAllStatus();
-    return $allstatus[$id] ?? 2;
+function kodiGetTVShowStatus($id) {
+       $allstatus = kodiGetTVShowAllStatus();
+       return $allstatus[$id] ?? 2;
 }
 
-function kodiToTMDB($id)
-{
-    $all = kodiGetAllKodiToTmdb();
-    return $all[$id] ?? null;
+function kodiToTMDB($id) {
+       $all = kodiGetAllKodiToTmdb();
+       return $all[$id] ?? null;
 }
 
-function kodiSyncPlayedStatus()
-{
-    $con = getKodiDBConnection();
-
-    $seen = connectRedis()->igbget('mediaseen');
-    $seenChanged = false;
-
-    $useen = [];
-
-    foreach ($seen as $item => $true) {
-        $useen[_normalizeSeenFile($item)] = true;
-    }
-
-    connectRedis()->igbset('mediaseen', $useen);
-    $seen = $useen;
-
-    $result = mysqli_query($con, 'SELECT * FROM path');
-    $paths = [];
-    while ($path = $result->fetch_assoc()) {
-        $p = _normalizeSeenFile($path['strPath']);
-
-        $paths[$path['idPath']] = $p;
-    }
-
-    $result = mysqli_query($con, 'SELECT * FROM files');
-    $files = [];
-    $playCounts = [];
-    while ($file = $result->fetch_assoc()) {
-        if (!isset($paths[$file['idPath']])) {
-            continue;
-        }
-        $filename = $paths[$file['idPath']] . $file['strFilename'];
-        $files[$filename] = $file['idFile'];
-        $playCounts[$filename] = $file['playCount'];
-        if (null !== $file['playCount'] && !isset($seen[$filename])) {
-            $seen[$filename] = true;
-            $seenChanged = true;
-        }
-    }
-
-    // Update seen if needed
-    if ($seenChanged) {
-        echo 'seen changed' . "<br>";
-        connectRedis()->igbset('mediaseen', $seen);
-    }
-    // Update kodi database
-    foreach ($seen as $file => $s) {
-        $file = str_replace('//', '/', $file);
-        $e = explode('.', $file);
-        $ext = array_pop($e);
-        array_push($e, 'x264');
-        array_push($e, $ext);
-        $x264 = implode('.', $e);
-
-        foreach ([$file, $x264] as $f) {
-            if (!array_key_exists($f, $playCounts) || ($playCounts[$f] && $playCounts[$f] >= 0)) {
-                continue;
-            }
-            $fileId = $files[$f];
-            mysqli_query($con, 'UPDATE files SET playCount=1,lastPlayed=NOW() WHERE idFile=' . $fileId);
-        }
-    }
+function kodiSyncPlayedStatus() {
+       $con = getKodiDBConnection();
+       if(!$con){
+               return;
+       }
+
+       $seen = connectRedis()->igbget('mediaseen');
+       $seenChanged = false;
+
+       $useen = [];
+
+       foreach ($seen as $item => $true) {
+               $useen[_normalizeSeenFile($item)] = true;
+       }
+
+       connectRedis()->igbset('mediaseen', $useen);
+       $seen = $useen;
+
+       $result = mysqli_query($con, 'SELECT * FROM path');
+       $paths = [];
+       while ($path = $result->fetch_assoc()) {
+               $p = _normalizeSeenFile($path['strPath']);
+
+               $paths[$path['idPath']] = $p;
+       }
+
+       $result = mysqli_query($con, 'SELECT * FROM files');
+       $files = [];
+       $playCounts = [];
+       while ($file = $result->fetch_assoc()) {
+               if (!isset($paths[$file['idPath']])) {
+                       continue;
+               }
+               $filename = $paths[$file['idPath']] . $file['strFilename'];
+               $files[$filename] = $file['idFile'];
+               $playCounts[$filename] = $file['playCount'];
+               if (null !== $file['playCount'] && !isset($seen[$filename])) {
+                       $seen[$filename] = true;
+                       $seenChanged = true;
+               }
+       }
+
+       // Update seen if needed
+       if ($seenChanged) {
+               echo 'seen changed' . "<br>";
+               connectRedis()->igbset('mediaseen', $seen);
+       }
+       // Update kodi database
+       foreach ($seen as $file => $s) {
+               $file = str_replace('//', '/', $file);
+               $e = explode('.', $file);
+               $ext = array_pop($e);
+               array_push($e, 'x264');
+               array_push($e, $ext);
+               $x264 = implode('.', $e);
+
+               foreach ([$file, $x264] as $f) {
+                       if (!array_key_exists($f, $playCounts) || ($playCounts[$f] && $playCounts[$f] >= 0)) {
+                               continue;
+                       }
+                       $fileId = $files[$f];
+                       mysqli_query($con, 'UPDATE files SET playCount=1,lastPlayed=NOW() WHERE idFile=' . $fileId);
+               }
+       }
 }
 
-function _normalizeSeenFile($p)
-{
-    $p = str_replace('nfs://192.168.13.3/', '/', $p);
-    $p = str_replace(NAS_ROOT, '/volume1/Share/', $p);
-    $p = str_replace(NAS_PWD_ROOT, '/volume1/Share/', $p);
-    $p = str_replace('smb://Share:dcfyjbcyckwydtgufjx@192.168.13.4/Share//', '/volume1/Share/', $p);
-    $p = str_replace('smb://nas.home.tortuga.enhydra.fr/1.42.6-25556/', '/volume1/Share/', $p);
-    $p = str_replace('.x264.', '.', $p);
-    return $p;
+function _normalizeSeenFile($p) {
+       $p = str_replace('nfs://192.168.13.3/', '/', $p);
+       $p = str_replace(NAS_ROOT, '/volume1/Share/', $p);
+       $p = str_replace(NAS_PWD_ROOT, '/volume1/Share/', $p);
+       $p = str_replace('smb://Share:dcfyjbcyckwydtgufjx@192.168.13.4/Share//', '/volume1/Share/', $p);
+       $p = str_replace('smb://nas.home.tortuga.enhydra.fr/1.42.6-25556/', '/volume1/Share/', $p);
+       $p = str_replace('.x264.', '.', $p);
+       return $p;
 }
 
-function tmdbToKodiId($tmdbId, $type = 'tvshow')
-{
-    $result = mysqli_query(getKodiDBConnection(), 'SELECT `media_id` FROM `uniqueid` WHERE `value`="' . $tmdbId . '" AND `type`="tmdb"');
-    while ($r = $result->fetch_assoc()) {
-        return $r['media_id'];
-    }
+function tmdbToKodiId($tmdbId, $type = 'tvshow') {
+       $con=getKodiDBConnection();
+       if(!$con){
+               return false;
+       }
+       $result = mysqli_query($con, 'SELECT `media_id` FROM `uniqueid` WHERE `value`="' . $tmdbId . '" AND `type`="tmdb"');
+       while ($r = $result->fetch_assoc()) {
+               return $r['media_id'];
+       }
 }
 
-function kodiOpenTVShow($device, $tmdbId, $season = 1, $episode = 1)
-{
-    global $kodiIP;
+function kodiOpenTVShow($device, $tmdbId, $season = 1, $episode = 1) {
+       global $kodiIP;
 
-    $ip = $kodiIP[$device];
-    $json = '{"jsonrpc":"2.0","id":"1","method":"GUI.ActivateWindow","params":["videos",["videodb://tvshows/titles/' . tmdbToKodiId($tmdbId) . '/' . $season . '","return"]]}';
-    `curl 'http://$ip:8754/jsonrpc' --data-raw '$json'`;
+       $ip = $kodiIP[$device];
+       $json = '{"jsonrpc":"2.0","id":"1","method":"GUI.ActivateWindow","params":["videos",["videodb://tvshows/titles/' . tmdbToKodiId($tmdbId) . '/' . $season . '","return"]]}';
+       `curl 'http://$ip:8754/jsonrpc' --data-raw '$json'`;
 }
\ No newline at end of file