</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" />
"deletionFromPopupRequiresConfirmation": "false",
"git-widget-placeholder": "master",
"ignore.virus.scanning.warn.message": "true",
- "last_opened_file_path": "D:/Works/tortuga-home/scripts",
+ "last_opened_file_path": "D:/Works/tortuga-home/bin",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
<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">
$_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