From f686eba35a2be599610b134fa7d462d03ebfb93e Mon Sep 17 00:00:00 2001 From: Vincent Date: Sat, 6 Jun 2020 18:42:16 +0200 Subject: [PATCH] . --- .idea/workspace.xml | 32 +++++++++++++++------------- scripts/cron/cron.php | 42 +++++++++++++++++++++++++++---------- scripts/lib/remoteinfos.php | 8 +++---- scripts/lib/tmdb.php | 14 +++++++++++-- tools/pop/pop.py | 2 +- 5 files changed, 66 insertions(+), 32 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 3dde7a4..ce7c9bd 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,8 +3,10 @@ + + + - @@ -1224,10 +1228,10 @@ - + - + @@ -1248,10 +1252,10 @@ - + - + diff --git a/scripts/cron/cron.php b/scripts/cron/cron.php index e3d4420..d916b4a 100644 --- a/scripts/cron/cron.php +++ b/scripts/cron/cron.php @@ -5,6 +5,9 @@ require_once __DIR__ . "/../import.php"; function cronOneLoop($cronmin) { set_time_limit(0); + + echo '------------------------------------' . "\n"; + _logSection('One Loop // ' . $cronmin); cronRooms($cronmin); cronInsteon($cronmin); cronWeather($cronmin); @@ -12,7 +15,6 @@ function cronOneLoop($cronmin) if ($cronmin % 5 == 0) { cronTraffic($cronmin, false); cronVelib($cronmin); - //cronBackyard($cronmin); cronGuest($cronmin); } if ($cronmin % 10 == 0) { @@ -30,8 +32,8 @@ function cronOneLoop($cronmin) cronInterface($cronmin); if ($cronmin % 15 == 0) { cronXPlanet($cronmin); - cronPodcasts($cronmin); cronFlowerPower($cronmin); + cronPodcasts($cronmin); } if ($cronmin == 0) { cronEcoMode($cronmin); @@ -40,10 +42,12 @@ function cronOneLoop($cronmin) cronTranscode($cronmin); } cronHeartbeat($cronmin); + _logSection('End Loop'); } function cronXPlanet($cronmin) { + _logSection('XPlanet'); $path = ROOT . '/tools/xplanet/'; $suncurve = $path . 'xplanet-suncurve'; $earth = $path . 'xplanet-earth'; @@ -53,16 +57,20 @@ function cronXPlanet($cronmin) function cronGuest($cronmin) { + + _logSection('Guest'); setState('guest', hasGuest() ? '1' : '0'); } function cronInsteon($cronmin) { + _logSection('Insteon'); insteonCommand('knock'); } function cronEcoMode($cronmin) { + _logSection('Ecomode'); $ecomode = (int)getEcoMode(); $scenes = [0 => 'off', 1 => 'on', 2 => 'super']; execScene('ecomode/' . $scenes[$ecomode]); @@ -70,11 +78,18 @@ function cronEcoMode($cronmin) function cronTranscode($cronmin) { + _logSection('Transcode'); httpRequest('https://salon.home.tortuga.enhydra.fr/scripts/transcode.php', 'get', [], null, 10, true); } +function _logSection($t) +{ + echo '------' . $t . ' :: ' . date('Y-m-d H:i:s') . "\n"; +} + function cronRooms($cronmin) { + _logSection('Rooms'); if ($cronmin % 5 == 0 && getState('bureauAutoMode') == '1') { updateBureauAuto(); } @@ -84,19 +99,16 @@ function cronRooms($cronmin) checkPlanetarium(); } -function cronBackyard($cronmin) -{ - domoticzSwitch(679, isDay()); // Projecteurs cour -} - function cronFlowerPower($cronmin) { + _logSection('Flower Power'); updateFlowerPower(); } function cronMediaLibrary($cronmin) { global $directories; + _logSection('Media Library'); $media = array(); $shareroot = '/volume1/Share'; @@ -120,6 +132,7 @@ function cronMediaLibrary($cronmin) function cronTmdb($cronmin) { + _logSection('TMDB'); _getTVShows(true, false); _getMovies(true, false); _getMediaRecentAdded(true); @@ -128,9 +141,10 @@ function cronTmdb($cronmin) function cronPing($cronmin) { + _logSection('Pings'); global $devices; - setState('vincenthere', ping('192.168.13.31') ? '1' : '0'); - setState('hasnetwork', ping('1.1.1.1', 443) ? '1' : '0'); + setState('vincenthere', ping('192.168.13.31', 5) ? '1' : '0'); + setState('hasnetwork', ping('1.1.1.1', 3, 443) ? '1' : '0'); foreach ($devices as $name => $device) { $result = ping($device['host'], 3, 22) ? '1' : '0'; setState('device_' . $name . '_awake', $result); @@ -145,6 +159,7 @@ function cronPing($cronmin) function cronSqueezeFavorites($cronmin) { + _logSection('Squeeze Favorites'); $favorites = getSqueezeFavorites(); if ($favorites !== false && count($favorites) > 0) { connectRedis()->igbset('squeezebox_favorites', $favorites); @@ -153,6 +168,7 @@ function cronSqueezeFavorites($cronmin) function cronWeather($cronmin) { + _logSection('Weather'); $place = 2608449; $apikey = 'fM7z3yrWwnUuXuAPPYIM5EqTl2iBAGB6'; @@ -245,7 +261,7 @@ function cronWeather($cronmin) function cronVelib($cronmin) { - + _logSection('Velib'); $cache = ROOT . '/cache/velib.json'; $hour = date('G'); @@ -270,7 +286,7 @@ function cronVelib($cronmin) function cronTraffic($cronmin, $force = false) { - + _logSection('Traffic'); $cache = ROOT . '/cache/traffic.json'; $hour = date('G'); @@ -296,6 +312,7 @@ function cronTraffic($cronmin, $force = false) function cronPodcasts($cronmin) { + _logSection('Podcasts'); checkSpottyLogin(); $podcasts = getSqueezeFavorites(0, 'podcasts'); if ($podcasts !== false && count($podcasts) > 0) { @@ -305,6 +322,7 @@ function cronPodcasts($cronmin) function cronInterface($cronmin) { + _logSection('Interface'); if ((getState('ecomode') == '0' && $cronmin % 3 == 0) || $cronmin % 10 == 0) { $devices = ['salon', 'bureau', 'entree', 'cuisine', 'litvincent', 'litjerome', 'sdb', 'chambre', 'bureausun', 'wc']; foreach ($devices as $device) { @@ -315,6 +333,7 @@ function cronInterface($cronmin) function cronHarmony($cronmin) { + _logSection('Harmony'); $currentActivity = getCurrentHarmonyActivity(); if ($currentActivity == 'tv') { @@ -343,6 +362,7 @@ function cronHarmony($cronmin) function cronHeartbeat($cronmin) { + _logSection('Heartbeat'); if ($cronmin % 5 != 0) { return; } diff --git a/scripts/lib/remoteinfos.php b/scripts/lib/remoteinfos.php index 70b67fb..d1bf942 100644 --- a/scripts/lib/remoteinfos.php +++ b/scripts/lib/remoteinfos.php @@ -47,7 +47,7 @@ function mediaraspRemoteInfos() $res['time'] = ''; $res['title'] = ''; $res['artwork'] = ''; - $res['status']=''; + $res['status'] = ''; $d = getDevice(); $playlist = simplexml_load_string(VLCCmd(['query' => 'requests/playlist.xml'], $d)); @@ -81,7 +81,7 @@ function mediaraspRemoteInfos() $library = new moviesLibrary($directories); $movie = $library->getMovieByID($id); $res['title'] = $movie['title']; - $res['artwork'] = 'https://image.tmdb.org/t/p/w500' . $movie['backdrop_path']; + $res['artwork'] = cacheMedia('https://image.tmdb.org/t/p/w500' . $movie['backdrop_path']); } } else { $f = new SplFileInfo($file); @@ -97,7 +97,7 @@ function mediaraspRemoteInfos() if (count($matches) > 0) { $res['title'] .= '
S' . $matches[1] . ' E' . $matches[2]; } - $res['artwork'] = 'https://image.tmdb.org/t/p/w500' . $tvshow['backdrop_path']; + $res['artwork'] = cacheMedia('https://image.tmdb.org/t/p/w500' . $tvshow['backdrop_path']); } } } @@ -117,7 +117,7 @@ function squeezeboxRemoteInfos() } $res['can_seek'] = isset($status['can_seek']); $res['title'] = $remoteMeta['title']; - $res['artwork'] = str_replace('http://', 'https://', $remoteMeta['artwork_url']); + $res['artwork'] = cacheMedia($remoteMeta['artwork_url']); return $res; } diff --git a/scripts/lib/tmdb.php b/scripts/lib/tmdb.php index 471eff0..13ec694 100644 --- a/scripts/lib/tmdb.php +++ b/scripts/lib/tmdb.php @@ -196,7 +196,7 @@ class tvShowLibrary extends mediaLibrary { global $videoExt; $subname = $prefix . 'tvshow-' . $tvShow['id']; - $res['shortcuts'][] = ['label' => $tvShow['data']['name'], 'type' => 'sub', 'sub' => $subname, 'poster' => cacheMedia('https://image.tmdb.org/t/p/w500' . $tvShow['data']['poster_path'])]; + $res['shortcuts'][] = ['label' => $tvShow['data']['name'], 'type' => 'sub', 'sub' => $subname, 'poster' => $this->_poster($tvShow['data']['poster_path'])]; $res['subs']['sub-' . $subname] = ['size' => 'poster']; $res['subs']['sub-' . $subname][] = ['label' => $tvShow['data']['name'], 'type' => 'back']; @@ -325,6 +325,15 @@ class mediaLibrary } return $lastModified; } + + public function _poster($path) + { + if ($path === '') { + return ''; + } else { + return cacheMedia('https://image.tmdb.org/t/p/w500' . $path); + } + } } class moviesLibrary extends mediaLibrary @@ -445,9 +454,10 @@ class moviesLibrary extends mediaLibrary public function shortcut($movie, $prefix, &$res) { $path = $this->_path($movie['path']); - $res[] = ['label' => $movie['data']['title'], 'type' => 'media', 'seen' => $this->_seen($path), 'srt' => hasSRT($path), 'path' => $path, 'poster' => cacheMedia('https://image.tmdb.org/t/p/w500' . $movie['data']['poster_path'])]; + $res[] = ['label' => $movie['data']['title'], 'type' => 'media', 'seen' => $this->_seen($path), 'srt' => hasSRT($path), 'path' => $path, 'poster' => $this->_poster($movie['data']['poster_path'])]; } + public function _orderMovies($a, $b) { return mb_strcasecmp($a['data']['title'], $b['data']['title']); diff --git a/tools/pop/pop.py b/tools/pop/pop.py index 81f927a..24fc99e 100644 --- a/tools/pop/pop.py +++ b/tools/pop/pop.py @@ -49,7 +49,7 @@ while True: while True: try: - if p.waitForNotifications(30.0): + if p.waitForNotifications(0.2): # handleNotification() was called continue -- 2.39.5