From: Vincent Date: Tue, 13 Apr 2021 19:10:47 +0000 (+0200) Subject: . X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=400e82cea88cd09aa046f0cc63cadb4af9fd873d;p=tortuga-home.git . --- diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c4326d5..df3c981 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,13 +2,16 @@ - - - - - - + + + + + + + + + diff --git a/config/global.php b/config/global.php index 7f15aaa..efc0ae0 100644 --- a/config/global.php +++ b/config/global.php @@ -43,7 +43,13 @@ $phones = [ 'ip' => '192.168.13.32', 'key' => 'dmGYolpN-k4:APA91bEcMcfkZ0jZViEvyqyVWoT71-vQko9DE0wwg-vzPkZ5-lHwiVJDH38dXfIoWrHWTrtEiMsv-6TrebFR-dNOLhVoVUb3rCsehmLi-Ew17lkP75Yqds3KsWEiyF_yx-i-9dc_4ewV', 'password' => '4pyA?Rnyeyc1$44M' + ], + 'salon' => [ + 'ip' => '192.168.13.32', + 'key' => 'dmGYolpN-k4:APA91bEcMcfkZ0jZViEvyqyVWoT71-vQko9DE0wwg-vzPkZ5-lHwiVJDH38dXfIoWrHWTrtEiMsv-6TrebFR-dNOLhVoVUb3rCsehmLi-Ew17lkP75Yqds3KsWEiyF_yx-i-9dc_4ewV', + 'password' => '4pyA?Rnyeyc1$44M' ] + //dOQilKX5CVQ:APA91bGOo1g2Hk2p7A4qYNg0wuKjvDeU3quKi6r73ae6rxVqSXmztMIDRn00DOZmXP1q1fBS0hLEd7xZo_Rr3LQMrRIHJpgy0FxnH7G_OV3kxFmGqWu1yOg5tBUEPlEybH_JkjlEgGof ]; $squeezeboxPlayersByRoom = [ diff --git a/config/salon.php b/config/salon.php index 8ef1cba..5a680a9 100644 --- a/config/salon.php +++ b/config/salon.php @@ -8,6 +8,10 @@ config('VOLUME_DEVICE', 'DenonAVR'); config('VIDEOPLAYER_DEVICE', 'salon'); config('HIDEMASK_TIMEOUT', 250); config('THEME','#7a6854'); +config('SLEEPSCREEN', 15); +config('SCREENSAVER_BRIGHTNESS', 100); +config('SLEEPTYPE', 'screensaver'); +config('SCREENSAVER','weatherstationoroff'); if (DISPLAYINTERFACE) { $c = salon(); diff --git a/scripts/lib/denon.php b/scripts/lib/denon.php index 5a16719..1a01255 100644 --- a/scripts/lib/denon.php +++ b/scripts/lib/denon.php @@ -28,9 +28,9 @@ function denonAVRVolume($volume, $increase = '') return $current . '->' . $volume; } -function denonAVROn($input = 'Media Player') +function denonAVROn($input = 'Media Player', $force = false) { - if (!denonAVRGetPowerState()) { + if ($force || !denonAVRGetPowerState()) { _denonTelnet('ZMON'); } denonAVRInput($input); @@ -48,19 +48,19 @@ function denonAVRInput($input) if (denonAVRGetInput() !== $cmd) { _denonTelnet($cmd); sleep(1); + $volumes = ['Media Player' => 60, 'HEOS Music' => 50, 'CD' => 30, 'AUX' => 26]; + if (isset($volumes[$input])) { + denonAVRVolume($volumes[$input], ''); + usleep(1000000 * 1); + } } - $audioMode = ['Media Player' => 'DOLBY DIGITAL', 'AUX' => 'DOLBY DIGITAL', 'CD' => 'DOLBY DIGITAL']; - if (isset($audioMode[$input])) { - denonAVRSetAudioMode($audioMode[$input]); - usleep(1000000 * 1); - } +// $audioMode = ['Media Player' => 'DOLBY DIGITAL', 'AUX' => 'DOLBY DIGITAL', 'CD' => 'DOLBY DIGITAL']; +// if (isset($audioMode[$input])) { +// denonAVRSetAudioMode($audioMode[$input]); +// usleep(1000000 * 1); +// } - $volumes = ['Media Player' => 60, 'HEOS Music' => 50, 'CD' => 30, 'AUX' => 26]; - if (isset($volumes[$input])) { - denonAVRVolume($volumes[$input], ''); - usleep(1000000 * 1); - } //denonAVRSetSpeakerPreset(1); } @@ -145,7 +145,7 @@ function epson($on = true, $force = false) sshCommand('/usr/local/bin/ir Epson ' . $cmd, 'salon'); setState('EpsonPowerState', $on ? '1' : '0'); if ($currentState !== $on && $on) { - sleep(26); + sleep(30); } } diff --git a/scripts/lib/kodi.php b/scripts/lib/kodi.php index 595e0d0..9dae7af 100644 --- a/scripts/lib/kodi.php +++ b/scripts/lib/kodi.php @@ -1,4 +1,7 @@ '192.168.13.40', 'bureau' => '192.168.13.41', 'avion' => '192.168.13.5', 'cuisine' => '192.168.13.32']; + function getKodiDBConnection() { return mysqli_connect('localhost', "kodi", "atacama", "MyVideos119"); @@ -51,7 +54,31 @@ function kodiSyncPlayedStatus() $fileId = $files[$f]; mysqli_query($con, 'UPDATE files SET playCount=1,lastPlayed=NOW() WHERE idFile=' . $fileId); } + } +} + +function tmdbToKodiId($tmdbId, $type = 'tvshow') +{ + + $con = getKodiDBConnection(); + if ($type === 'tvshow') { + $tvdb = tmdbToTvdb($tmdbId); + } + $result = mysqli_query($con, 'SELECT `media_id` FROM `uniqueid` WHERE `media_type` = "' . $type . '" AND `value`="' . $tvdb . '" ORDER BY `media_id` ASC '); + $files = []; + $playCounts = []; + while ($file = $result->fetch_assoc()) { } +} + +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/' . $kodiId . '/' . $season . '","return"]]}'; + `curl 'http://$ip:8754/jsonrpc' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Accept-Language: fr-FR,en;q=0.5' --compressed -H 'Connection: keep-alive' -H 'Upgrade-Insecure-Requests: 1' -H 'Cache-Control: max-age=0, no-cache' -H 'Pragma: no-cache' --data-raw '$json'`; } \ No newline at end of file diff --git a/scripts/lib/mediarasp.php b/scripts/lib/mediarasp.php index 62c62b9..aafdbe7 100644 --- a/scripts/lib/mediarasp.php +++ b/scripts/lib/mediarasp.php @@ -208,7 +208,7 @@ function remoteCmdMedia($cmd, $device = null, $playing = null) } if ($key == 'rewind' || $key == 'fast-rewind') { $way = '-'; - } else if ($key == 'forward' || $key = 'fast-forward') { + } else if ($key == 'forward' || $key == 'fast-forward') { $way = '+'; } $res = VLCCmd(['command' => 'seek', 'val' => $way . $amount . 's'], $device); diff --git a/scripts/lib/off.php b/scripts/lib/off.php index 4791505..6fb734c 100644 --- a/scripts/lib/off.php +++ b/scripts/lib/off.php @@ -32,6 +32,8 @@ function offSalon() denonAVROff(); shieldKillAll('salon'); shieldSleep('salon'); + sleep(2); + epson(false, true); } function offBureau() diff --git a/scripts/lib/shield.php b/scripts/lib/shield.php index 636d93f..2e973e6 100644 --- a/scripts/lib/shield.php +++ b/scripts/lib/shield.php @@ -33,15 +33,15 @@ function shieldWakeup($device = null) //`curl 'http://192.168.13.60:9000/plugins/Extensions/settings/plugins/CastBridge/settings/basic.html?playerid=b8%3A27%3Aeb%3Af6%3A1d%3A30' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Accept-Language: fr-FR,en;q=0.5' --compressed -H 'Content-Type: application/x-www-form-urlencoded' -H 'Origin: http://192.168.13.60:9000' -H 'Connection: keep-alive' -H 'Referer: http://192.168.13.60:9000/plugins/Extensions/settings/plugins/CastBridge/settings/basic.html' -H 'Cookie: Squeezebox-player=b8%3A27%3Aeb%3Af6%3A1d%3A30; Squeezebox-enableHiDPI=1; Squeezebox-expandPlayerControl=true; Squeezebox-expanded-MY_MUSIC=0; Squeezebox-expanded-RADIO=1; Squeezebox-expanded-PLUGIN_MY_APPS_MODULE_NAME=1; Squeezebox-expanded-FAVORITES=1; Squeezebox-expanded-PLUGINS=0; Squeezebox-playersettings=settings/player/basic.html%3F; Squeezebox-advancedsettings=plugins/CastBridge/settings/basic.html%3F; Squeezebox-expanded-activePlugins=1; Squeezebox-expanded-inactivePlugins=1; Squeezebox-expanded-otherPlugins0=1; securitytoken=1b5a6a8ddf493f1bf1f0787e0de41708' -H 'Upgrade-Insecure-Requests: 1' --data-raw 'saveSettings=1&useAJAX=0&page=PLUGIN_CASTBRIDGE&playerid=b8%3A27%3Aeb%3Af6%3A1d%3A30&player=b8%3A27%3Aeb%3Af6%3A1d%3A30&autorun=on&bin=squeeze2cast-armv6hf&opts=&debugs=&log_limit=-1&configfile=castbridge.xml&autosave=on&upnp_socket=%3F&xmlparams=1&prevseldevice=.common.&seldevice=.common.&codecs=aac%2Cogg%2Cops%2Cogf%2Cflc%2Calc%2Cwav%2Caif%2Cpcm%2Cmp3&sample_rate=96000&encode_mode=thru&encode_level=&encode_bitrate=&encode_rate=&encode_size=&server=%3F&enabled=1&remove_timeout=0&volume_on_play=1&media_volume=50&send_metadata=1&send_coverart=1&enabled.79a3f5f078d67e3b25a6b3dedc624e18=1&enabled.c4f32d227235313d8c59eff43a01350c=1'`; } -function shieldRunActivity($device = null) +function shieldRunActivity($device = null, $force = false) { $device = getDevice($device); $onlySound = in_array(shieldGetCurrentApp($device), ['spotify']); if ($device['id'] === 'salon') { stopPlayersIn('salon', true, false); + denonAVROn('Media Player', $force); epson(true); - denonAVROn(); execScene('salon/cinema'); } else if ($device['id'] === 'bureau' || $device['id'] === 'bureausun') { stopPlayersIn('bureau', true, false); diff --git a/scripts/lib/tmdb.php b/scripts/lib/tmdb.php index 639c68a..894d9d8 100644 --- a/scripts/lib/tmdb.php +++ b/scripts/lib/tmdb.php @@ -103,6 +103,20 @@ function _getMovies($force = false, $forceapi = false) return $res; } +function tmdbToTvdb($tmdbid) +{ + $cacheKey = 'tmdb_to_tvdb_' . $tmdbid; + $cached = getState($cacheKey, null); + if (null === $cached) { + $client = getTmbdClient(); + $find = $client->getTvApi(); + $data = $find->getExternalIds($tmdbid); + $cached = $data['tvdb_id']; + setState($cacheKey, $cached); + } + return $cached; +} + function mb_strcasecmp($str1, $str2, $encoding = null) { if (null === $encoding) { @@ -161,8 +175,8 @@ class tvShowLibrary extends mediaLibrary $edate = explode('-', $data['last_air_date']); $mtime = gmmktime(12, 0, 0, $edate[1], $edate[2], $edate[0]); - if (file_exists($file.'.netflix')) { - $dir = 'netflix:' . file_get_contents($file.'.netflix'); + if (file_exists($file . '.netflix')) { + $dir = 'netflix:' . file_get_contents($file . '.netflix'); } else { $dir = file_exists($file) && is_file($file) ? file_get_contents($file) : $f->getPath(); } diff --git a/servers/logcat.php b/servers/logcat.php index aa60bc9..fca3814 100644 --- a/servers/logcat.php +++ b/servers/logcat.php @@ -13,7 +13,6 @@ $cases = [ 'Going to sleep due to power button' => function () use ($device) { echo 'sleep ' . $device . "\n"; off($device); - execScene('salon/on'); }, 'Waking up from sleep' => function () use ($device) { echo 'wakeup ' . $device . "\n"; @@ -25,7 +24,7 @@ $cases = [ $squeezePlayer = 'Bureau'; } if (getState($state, '0') < time() && getSqueezePlayerStatus($squeezePlayer) <= 0) { - shieldRunActivity($device); + shieldRunActivity($device,true); } }, 'WindowManager: handleComboKeys keyCode: 25, keyAction: 1' => function () use ($device) {