From: Vincent Vanwaelscappel Date: Wed, 25 Mar 2026 13:18:04 +0000 (+0100) Subject: . X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=9f6ab38fa5b04d7212dae961e6e3296041a2f115;p=tortuga-home.git . --- diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 46fdc82..ed15818 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,8 +5,32 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/bureau.php b/config/bureau.php index af6c292..e113fac 100644 --- a/config/bureau.php +++ b/config/bureau.php @@ -28,9 +28,8 @@ if (DISPLAYINTERFACE) { $favoriteslights = $c['favorites']; } - include_once "remote.php"; include "default.php"; include ROOT . "/config/media.php"; - $nav = ['home', 'lights', 'music', 'media', 'remote', 'switch', 'fan', 'settings', 'alert', 'off']; + $nav = ['home', 'lights', 'music', 'media', 'switch', 'settings', 'alert', 'off']; } diff --git a/config/chambre.php b/config/chambre.php index 3e1ddf0..ae8aa33 100644 --- a/config/chambre.php +++ b/config/chambre.php @@ -21,5 +21,5 @@ if (DISPLAYINTERFACE) { $favoriteslights = array_merge([['type' => 'light', 'scene' => 'chambre/reading/fireplace', 'label' => 'Au coin du feu'],], $c['favorites']); include "default.php"; - $nav = ['home', 'lights', 'music', 'remote', 'coffee', 'switch', 'fan', 'settings', 'alert', 'off']; + $nav = ['home', 'lights', 'music', 'switch','settings', 'alert', 'off']; } \ No newline at end of file diff --git a/config/cuisine.php b/config/cuisine.php index f683040..592ef29 100644 --- a/config/cuisine.php +++ b/config/cuisine.php @@ -22,5 +22,5 @@ if (DISPLAYINTERFACE) { include "default.php"; - $nav=['home','lights','water','music','remote','coffee','switch','settings','alert','off']; + $nav=['home','lights','water','music','switch','settings','alert','off']; } \ No newline at end of file diff --git a/config/default.php b/config/default.php index 7554972..967c9ff 100644 --- a/config/default.php +++ b/config/default.php @@ -36,7 +36,6 @@ if (hasConfig('SQUEEZEBOX_PLAYER')) { config('SQUEEZEBOX_AMBIANCE_PLAYER', config('SQUEEZEBOX_PLAYER')); } include_once ROOT . '/config/music.php'; - include_once ROOT . "/config/remote.php"; } if (!isset($nav)) { diff --git a/config/lit.php b/config/lit.php index 533ec84..138dbc7 100644 --- a/config/lit.php +++ b/config/lit.php @@ -13,7 +13,7 @@ if (DISPLAYINTERFACE) { $shortcuts['lights'] = $c['all']; $favoriteslights = $c['favorites']; - $nav = ['home', 'lights', 'music', /*'media', */'coffee', 'switch'/*, 'fan'*/, 'settings', 'alert', 'off']; + $nav = ['home', 'lights', 'music', 'switch', 'settings', 'alert', 'off']; // include "media.php"; include "default.php"; diff --git a/config/media.php b/config/media.php index 095f869..5e560e1 100644 --- a/config/media.php +++ b/config/media.php @@ -1,86 +1,8 @@ igbget('medialibrary'); $device = config('DEVICE'); $shortcuts['media'] = [['label' => 'TV', 'type' => 'sub', 'sub' => 'tv']/*, ['label' => 'Ajoutés récemment', 'type' => 'sub', 'sub' => 'mediarecent']*/]; -//$shortcuts['media'][] = ['label' => 'Séries TV', 'type' => 'sub', 'sub' => 'seriestv']; -//$shortcuts['media'][] = ['label' => 'Films', 'type' => 'sub', 'sub' => 'movies']; if ($device == 'salon' || $device == 'bureau' || $device == 'bureausun') { $shortcuts['media'][] = array('type' => 'netflix', 'url' => 'scripts/netflix.php?id=home', 'label' => ''); $shortcuts['media'][] = array('type' => 'amazonprime', 'url' => 'scripts/shield.php?amazonprime=home', 'label' => ''); - //$shortcuts['media'][] = array('type' => 'nintendoswitch', 'url' => 'scripts/switch.php', 'label' => ''); - //$shortcuts['media'][] = ['label' => 'Vidéo web', 'type' => 'raspberrycast']; } - - -//$tvshows = getTVShows(); -//if (is_array($tvshows)) { -// $shortcuts['sub-seriestv'] = $tvshows['shortcuts']; -// $shortcuts = array_merge($shortcuts, $tvshows['subs']); -// profile('Got TV Shows', __FILE__, __LINE__); -//} -// -//$movies = getMovies(); -//if (is_array($movies)) { -// $shortcuts['sub-movies'] = $movies['shortcuts']; -// $shortcuts = array_merge($shortcuts, $movies['subs']); -// profile('Got movies', __FILE__, __LINE__); -//} -// -//$recent = getMediaRecentAdded(); -//if (is_array($recent)) { -// $shortcuts['sub-mediarecent'] = $recent['shortcuts']; -// $shortcuts = array_merge($shortcuts, $recent['subs']); -// profile('Got recents', __FILE__, __LINE__); -//} - -//if (is_array($media)) { -// foreach ($media as $id => $mediagroup) { -// if ($id == 'x' && (!isset($_GET['x']) || $_GET['x'] != 'x')) { -// continue; -// } -// $parentId = 'media-' . $id; -// $shortcuts['media'][] = array('label' => $mediagroup['name'], 'type' => 'sub', 'sub' => $parentId); -// $shortcuts = array_merge($shortcuts, getMediaFolderShortcuts($mediagroup, $parentId)); -// } -//} - -//$shortcuts['media'][] = ['label' => 'Recharger', 'type' => 'url', 'href' => '/scripts/tmdb.php']; - -function getMediaFolderShortcuts($mediagroup, $parentId) -{ - - - $res['sub-' . $parentId] = array(); - if (!isset($mediagroup['items'])) { - return $res; - } - - foreach ($mediagroup['items'] as $item) { - if ($item['dir']) { - $pid = 'media-' . $item['id']; - $res['sub-' . $parentId][] = array('label' => $item['name'], 'type' => 'sub', 'sub' => $pid); - $res = array_merge($res, getMediaFolderShortcuts($item, $pid)); - } else { - $unsupportedExt = []; - $unsupportedCodec = ['av1', 'hevc']; - if (config('VIDEOPLAYER') === 'shield') { - $unsupportedCodec = ['xvid']; - $unsupportedExt = ['avi']; - } - $e = explode('.', $item['path']); - $path = $item['path']; - if (in_array($e, $unsupportedExt) || in_array(getVideoCodec($item['path']), $unsupportedCodec)) { - $path = $item['x264path']; - } - $res['sub-' . $parentId][] = array('label' => $item['name'], 'type' => 'media', 'path' => $path); - } - } - - if (count($res['sub-' . $parentId]) > 0) { - array_unshift($res['sub-' . $parentId], array('label' => $mediagroup['name'], 'type' => 'back')); - } - return $res; -} \ No newline at end of file diff --git a/config/remote.php b/config/remote.php deleted file mode 100644 index 0c127a8..0000000 --- a/config/remote.php +++ /dev/null @@ -1,69 +0,0 @@ - 'freebox', 'width' => 6, 'height' => 4, 'bricks' => [ - ['type' => 'remote-volume', 'width' => 1, 'height' => 3, 'top' => 1, 'left' => 0], - ['type' => 'remote-rew', 'width' => 1, 'height' => 1, 'top' => 0, 'left' => 0], - ['type' => 'remote-playpause', 'width' => 2, 'height' => 1, 'top' => 0, 'left' => 1], - ['type' => 'remote-rec', 'width' => 1, 'height' => 1, 'top' => 0, 'left' => 4], - ['type' => 'remote-light-up', 'width' => 1, 'height' => 1, 'top' => 1, 'left' => 4], - ['type' => 'remote-light-down', 'width' => 1, 'height' => 1, 'top' => 2, 'left' => 4], - ['type' => 'remote-fwd', 'width' => 1, 'height' => 1, 'top' => 0, 'left' => 3], - ['type' => 'remote-free', 'width' => 2, 'height' => 1, 'top' => 3, 'left' => 4], - ['type' => 'remote-up', 'width' => 1, 'height' => 1, 'top' => 1, 'left' => 2], - ['type' => 'remote-left', 'width' => 1, 'height' => 1, 'top' => 2, 'left' => 1], - ['type' => 'remote-down', 'width' => 1, 'height' => 1, 'top' => 3, 'left' => 2], - ['type' => 'remote-right', 'width' => 1, 'height' => 1, 'top' => 2, 'left' => 3], - ['type' => 'remote-red', 'width' => 1, 'height' => 1, 'top' => 1, 'left' => 1], - ['type' => 'remote-blue', 'width' => 1, 'height' => 1, 'top' => 1, 'left' => 1 + 2], - ['type' => 'remote-green', 'width' => 1, 'height' => 1, 'top' => 1 + 2, 'left' => 1], - ['type' => 'remote-yellow', 'width' => 1, 'height' => 1, 'top' => 1 + 2, 'left' => 1 + 2], - ['type' => 'remote-ok', 'width' => 1, 'height' => 1, 'top' => 2, 'left' => 2], - ['type' => 'remote-channels', 'width' => 1, 'height' => 3, 'top' => 0, 'left' => 5], -]]; - -$bricksShield = ['type' => 'shield', 'width' => 4, 'height' => 4, 'bricks' => [ - ['type' => 'remote-volume', 'width' => 1, 'height' => 3, 'top' => 1, 'left' => 0], - ['type' => 'remote-rew', 'width' => 1, 'height' => 1, 'top' => 0, 'left' => 0], - ['type' => 'remote-playpause', 'width' => 2, 'height' => 1, 'top' => 0, 'left' => 1], - ['type' => 'remote-light-down', 'width' => 1, 'height' => 1, 'top' => 1, 'left' => 3], - ['type' => 'remote-fwd', 'width' => 1, 'height' => 1, 'top' => 0, 'left' => 3], - ['type' => 'remote-up', 'width' => 1, 'height' => 1, 'top' => 1, 'left' => 2], - ['type' => 'remote-left', 'width' => 1, 'height' => 1, 'top' => 2, 'left' => 1], - ['type' => 'remote-down', 'width' => 1, 'height' => 1, 'top' => 3, 'left' => 2], - ['type' => 'remote-right', 'width' => 1, 'height' => 1, 'top' => 2, 'left' => 3], - ['type' => 'remote-shield-back', 'width' => 1, 'height' => 1, 'top' => 1, 'left' => 1], - ['type' => 'remote-shield-menu', 'width' => 1, 'height' => 1, 'top' => 1 + 2, 'left' => 1], - ['type' => 'remote-shield-home', 'width' => 1, 'height' => 1, 'top' => 1 + 2, 'left' => 1 + 2], - ['type' => 'remote-shield-ok', 'width' => 1, 'height' => 1, 'top' => 2, 'left' => 2], -]]; - -$bricksShieldMedia = ['type' => 'shieldmedia', 'width' => 5, 'height' => 5, 'bricks' => [ - ['type' => 'remote-volume', 'width' => 1, 'height' => 3, 'top' => 1, 'left' => 0], - ['type' => 'remote-rew', 'width' => 1, 'height' => 1, 'top' => 0, 'left' => 0], - ['type' => 'remote-playpause', 'width' => 2, 'height' => 1, 'top' => 0, 'left' => 1], - ['type' => 'remote-light-down', 'width' => 1, 'height' => 1, 'top' => 4, 'left' => 4], - ['type' => 'remote-fwd', 'width' => 1, 'height' => 1, 'top' => 0, 'left' => 3], - ['type' => 'remote-stop', 'width' => 1, 'height' => 1, 'top' => 0, 'left' => 4], - ['type' => 'remote-infos', 'width' => 3, 'height' => 3, 'top' => 1, 'left' => 1], - ['type' => 'remote-subtitles', 'width' => 1, 'height' => 3, 'top' => 1, 'left' => 4], - ['type' => 'remote-timeline', 'width' => 4, 'height' => 1, 'top' => 4, 'left' => 0], -]]; - - -$bricksSqueezebox = ['type' => 'squeezebox', 'width' => 6, 'height' => 4, 'bricks' => [ - ['type' => 'remote-volume', 'width' => 1, 'height' => 3, 'top' => 0, 'left' => 0], - ['type' => 'remote-rew', 'width' => 1, 'height' => 1, 'top' => 0, 'left' => 1], - ['type' => 'remote-playpause', 'width' => 2, 'height' => 1, 'top' => 0, 'left' => 2], - ['type' => 'remote-fwd', 'width' => 1, 'height' => 1, 'top' => 0, 'left' => 4], - ['type' => 'remote-stop', 'width' => 1, 'height' => 1, 'top' => 0, 'left' => 5], - ['type' => 'remote-infos', 'width' => 4, 'height' => 2, 'top' => 1, 'left' => 1], - ['type' => 'remote-timeline', 'width' => 6, 'height' => 1, 'top' => 3, 'left' => 0], - ['type' => 'remote-light-up', 'width' => 1, 'height' => 1, 'top' => 1, 'left' => 5], - ['type' => 'remote-light-down', 'width' => 1, 'height' => 1, 'top' => 2, 'left' => 5], -]]; - - -$shortcuts['remote-squeezebox'] = [['type' => 'bricks', 'bricks' => $bricksSqueezebox]]; -$shortcuts['remote-freebox'] = [['type' => 'bricks', 'bricks' => $bricksFreebox]]; -$shortcuts['remote-shield'] = [['type' => 'bricks', 'bricks' => $bricksShield]]; -$shortcuts['remote-shieldmedia'] = [['type' => 'bricks', 'bricks' => $bricksShieldMedia]]; \ No newline at end of file diff --git a/config/salon.php b/config/salon.php index 65974b9..4a243ed 100644 --- a/config/salon.php +++ b/config/salon.php @@ -27,9 +27,8 @@ if (DISPLAYINTERFACE) { $favoriteslights = $c['favorites']; } - include_once "remote.php"; include "default.php"; include ROOT . "/config/media.php"; - $nav = ['home', 'lights', 'music', 'media', 'remote', 'switch', 'fan', 'settings', 'alert', 'off']; + $nav = ['home', 'lights', 'music', 'media', 'switch', 'settings', 'alert', 'off']; } diff --git a/config/sdb.php b/config/sdb.php index fe32823..e432bd9 100644 --- a/config/sdb.php +++ b/config/sdb.php @@ -15,7 +15,7 @@ config('THEME', '#92475c'); if (DISPLAYINTERFACE) { $c = sdb(); $shortcuts['lights'] = $c['all']; - $nav = ['home', 'lights', 'water', 'music', 'media', 'remote', 'switch', 'settings', 'alert', 'off']; + $nav = ['home', 'lights', 'water', 'music', 'media', 'switch', 'settings', 'alert', 'off']; include_once ROOT . '/config/music.php'; diff --git a/config/tv.php b/config/tv.php deleted file mode 100644 index 2659870..0000000 --- a/config/tv.php +++ /dev/null @@ -1,152 +0,0 @@ -igbget('dvbchannels'); -if (!$mapdvb) { - $mapdvb = array(); -// $m3u = getUrlContent('http://tvheadend.home.tortuga.enhydra.fr:9981/playlist/channels', 30); -// $lines = explode("\n", $m3u); -// $name = ''; -// foreach ($lines as $line) { -// $line = trim($line); -// if (strpos($line, '#EXTINF:') === 0) { -// $e = explode(',', $line); -// $name = array_pop($e); -// } else if (strpos($line, 'http') === 0) { -// $mapdvb[$name] = $line; -// } -// } - connectRedis()->igbsetex('dvbchannels', 3600, $mapdvb); -} - -$replays = [ - 'FranceTV' => ['shield' => 'mycanal:replay:francetv', 'logo' => 'https://www.france.tv/images/francetv-black.svg'], - 'Arte' => ['shield' => 'mycanal:replay:arte', 'logo' => '80204926'], - 'MyTF1' => ['shield' => 'mycanal:replay:mytf1', 'logo' => '3932761'], - 'Toutes les chaînes' => ['shield' => 'mycanal:replay:home'], -]; -$shortcuts['sub-tv-replay'] = array(); -foreach ($replays as $name => $replay) { - if (isset($replay['logo']) && $replay['logo']) { - $url = $replay['logo']; - $style = 'width:80%;margin-top:42%;'; - $ext = null; - if (strpos($url, 'http') !== 0) { - $url = 'http://thumb.canalplus.pro/bddpe/unsafe/' . $replay['logo']; - $style = 'margin-top:12%;'; - $ext = 'webp'; - } - $name = ''; - } - if (isset($replay['shield'])) { - $e = explode(':', $replay['shield'], 2); - if ($name === 'netflix') { - $name = ''; - } - $shortcuts['sub-tv-replay'][] = array('type' => 'shield', 'url' => 'scripts/shield.php?' . $e[0] . '=' . $e[1], 'label' => $name); - } -} - -$tv = array( - //'Connexion MyCanal' => array('freebox' => 'replay', 'shield' => 'mycanal:connect:home'), - 'Replay' => array('freebox' => 'replay', 'shield' => 'mycanal:replay:home'), - 'Netflix' => array('freebox' => 'netflix', 'shield' => 'netflix:home'), - 'Amazon Prime' => array('shield' => 'amazonprime:home'), - 'Généralistes', - 'TF1' => array('stream' => 'tvheadend:TF1', 'channel' => 1, 'shield' => 'mycanal:live:312', 'logo' => '66746746'), - 'France 2' => array('stream' => 'tvheadend:France 2', 'channel' => 2, 'shield' => 'mycanal:live:26', 'logo' => '67032119'), - 'France 3' => array('stream' => 'tvheadend:France 3', 'channel' => 3, 'shield' => 'mycanal:live:543', 'logo' => '67033022'), - 'France 5' => array('stream' => 'tvheadend:France 5', 'channel' => 5, 'shield' => 'mycanal:live:545', 'logo' => '67033026'), - 'M6' => array('stream' => 'tvheadend:M6', 'channel' => 6, 'shield' => 'mycanal:live:313', 'logo' => '96947147'), - 'Canal +' => array('stream' => 'tvheadend:CANAL+', 'channel' => 4, 'shield' => 'mycanal:live:601', 'logo' => '59320209'), - 'Arte' => array('stream' => 'tvheadend:Arte', 'channel' => 7, 'shield' => 'mycanal:live:154', 'logo' => '3932761'), - 'C8' => array('stream' => 'tvheadend:C8', 'channel' => 8, 'shield' => 'mycanal:live:450', 'logo' => '64698815'), - 'W9' => array('stream' => 'tvheadend:W9', 'channel' => 9, 'shield' => 'mycanal:live:296', 'logo' => '2953125'), - 'TMC' => array('stream' => 'tvheadend:TMC', 'channel' => 10, 'shield' => 'mycanal:live:584', 'logo' => '66747568'), - 'TFX' => array('stream' => 'tvheadend:TFX', 'channel' => 11, 'shield' => 'mycanal:live:570', 'logo' => '66747551'), - 'NRJ12' => array('stream' => 'tvheadend:NRJ12', 'channel' => 12, 'shield' => 'mycanal:live:568', 'logo' => '21549709'), - 'LCP' => array('stream' => 'tvheadend:LCP', 'channel' => 13, 'shield' => 'mycanal:live:554', 'logo' => '94033640'), - 'France 4' => array('stream' => 'tvheadend:France 4', 'channel' => 14, 'shield' => 'mycanal:live:544', 'logo' => '67033024'), - 'CStar' => array('stream' => 'tvheadend:CSTAR', 'channel' => 17, 'shield' => 'mycanal:live:513', 'logo' => '64699011'), - 'Gulli' => array('stream' => 'tvheadend:Gulli', 'channel' => 18, 'shield' => 'mycanal:live:549', 'logo' => '61929315'), - 'RMC Story' => array('stream' => 'tvheadend:RMC STORY', 'channel' => 23, 'shield' => 'mycanal:live:571', 'logo' => '76992469'), - 'RMC Découverte' => array('stream' => 'tvheadend:RMC Découverte', 'channel' => 24, 'shield' => 'mycanal:live:595', 'logo' => '64959411'), - 'Chérie 25' => array('stream' => 'tvheadend:Chérie 25', 'channel' => 25, 'shield' => 'mycanal:live:440', 'logo' => '2953383'), - 'Paris première' => array('stream' => 'fbx:213:ld', 'channel' => 28, 'shield' => 'mycanal:live:294', 'logo' => '2953121'), - 'RTL9' => array('stream' => 'fbx:210:ld', 'channel' => 29, 'shield' => 'mycanal:live:505', 'logo' => '24419688'), - 'TV Breizh' => array('shield' => 'mycanal:live:586', 'logo' => '93561480'), - '6ter' => array('stream' => 'tvheadend:6ter', 'channel' => 22, 'shield' => 'mycanal:live:521', 'logo' => '16598429'), - 'TF1 Séries Films' => array('stream' => 'tvheadend:TF1 Séries Films', 'channel' => 20, 'shield' => 'mycanal:live:526', 'logo' => '66747478'), - 'Infos', - 'France Info' => array('stream' => 'tvheadend:franceinfo:', 'channel' => 27, 'shield' => 'mycanal:live:670', 'logo' => '41072782'), - 'Cnews' => array('stream' => 'tvheadend:CNEWS', 'channel' => 16, 'shield' => 'mycanal:live:480', 'logo' => '64698936'), - 'BFM TV' => array('stream' => 'tvheadend:BFM TV', 'channel' => 15, 'shield' => 'mycanal:live:633', 'logo' => '34766177'), - 'BFM Business' => array('stream' => 'tvheadend:BFM Paris', 'channel' => 347, 'shield' => 'mycanal:live:645', 'logo' => '54239635'), - 'LCI' => array('stream' => 'tvheadend:LCI', 'channel' => 26, 'shield' => 'mycanal:live:553', 'logo' => '66747521'), - 'Euronews' => array('stream' => 'fbx:205:sd', 'channel' => 345, 'shield' => 'mycanal:live:324', 'logo' => '36581437'), - 'Monde', - 'TV5 Monde' => array('stream' => 'fbx:206:sd', 'channel' => 1, 'shield' => 'mycanal:live:520', 'logo' => '14279265'), - 'France 24' => array('stream' => 'tvheadend:France 24', 'channel' => 340, 'shield' => 'mycanal:live:310', 'logo' => '18810794'), - 'BBC World News' => array('shield' => 'mycanal:live:589', 'logo' => '27443835'), - 'CNN' => array('shield' => 'mycanal:live:30', 'logo' => '13455768'), -); -$shortcuts['sub-tv'] = array(); -$tvplayer = config('TVPLAYER'); -foreach ($tv as $name => $service) { - if ($name === 'Replay' && $tvplayer === 'shield') { - $shortcuts['sub-tv'][] = ['label' => $name, 'type' => 'sub', 'sub' => 'tv-replay']; - continue; - } - - if (isset($service['logo']) && $service['logo']) { - $name = ''; - } elseif ($name === 'Netflix') { - $name = ''; - } else if ($name === 'Amazon Prime') { - $name = ''; - } - - if (is_numeric($name)) { - $shortcuts['sub-tv'][] = array('type' => 'separator', 'label' => $service); - } else { - if ($tvplayer === 'shield') { - if (isset($service['channel'])) { - $shortcuts['sub-tv'][] = array('type' => 'shield', 'url' => 'scripts/shield.php?oqee=' . $service['channel'], 'label' => $name); - } else if (isset($service['shield'])) { - $e = explode(':', $service['shield'], 2); - if ($name === 'netflix') { - $name = ''; - } else if ($name === 'amazonprime') { - $name = ''; - } - $shortcuts['sub-tv'][] = array('type' => 'shield', 'url' => 'scripts/shield.php?' . $e[0] . '=' . $e[1], 'label' => $name); - } - } else if ($tvplayer == 'freebox') { - if (isset($service['channel'])) { - $shortcuts['sub-tv'][] = array('type' => 'freebox', 'url' => 'scripts/freeboxchannel.php?channel=' . $service['channel'], 'label' => $name); - } else { - $shortcuts['sub-tv'][] = array('type' => 'freebox', 'url' => 'scripts/freeboxchannel.php?channel=' . $service['freebox'], 'label' => $name); - } - } else if (isset($service['stream'])) { - $e = explode(':', $service['stream'], 3); - $protocol = $e[0]; - $id = $e[1]; - $definition = ''; - if (isset($e[2])) { - if ($protocol == 'fbx') { - $definition = '&flavour=' . $e[2]; - } else { - $id .= ':'; - } - } - - if ($protocol == 'fbx') { - $shortcuts['sub-tv'][] = array('type' => 'media', 'url' => 'rtsp://mafreebox.freebox.fr/fbxtv_pub/stream?namespace=1&service=' . $id . $definition, 'label' => $name); - } else { - if (isset($mapdvb[$id])) { - $shortcuts['sub-tv'][] = array('type' => 'media', 'url' => $mapdvb[$id], 'label' => $name); - } - } - } - } -} - -profile('Got DVB and TV Channels', __FILE__, __LINE__); \ No newline at end of file diff --git a/config/wc.php b/config/wc.php index 12340a0..1e227e5 100644 --- a/config/wc.php +++ b/config/wc.php @@ -10,7 +10,7 @@ config('HIDEMASK_TIMEOUT', 250); if (DISPLAYINTERFACE) { $c = wc(); $shortcuts['lights'] = $c['all']; - $nav = ['home', 'lights', 'music', 'remote', 'switch', 'settings', 'alert', 'off']; + $nav = ['home', 'lights', 'music', 'switch', 'settings', 'alert', 'off']; include_once ROOT . '/config/music.php'; diff --git a/js/home.js b/js/home.js index 4495737..116b881 100644 --- a/js/home.js +++ b/js/home.js @@ -198,11 +198,7 @@ $(function () { $(document).on(clickevent, 'a.ajax', function () { displayLoader($(this)); - var goremote = $(this).attr('data-remote') === '1'; $.get($(this).attr('href'), {}, function () { - if (goremote) { - window.location = '#/section/remote'; - } hideLoader(); }).fail(function () { hideLoader(); @@ -284,32 +280,6 @@ $(function () { [Hammer.Press, {time: 551}],] }); - mc.on('press', function (e) { - var target; - if ($(e.target).is('[data-remote-command-long]')) { - target = $(e.target); - } else if ($(e.target).find('[data-remote-command-long]').length > 0) { - target = $(e.target).find('[data-remote-command-long]'); - } else if ($(e.target).closest('[data-remote-command-long]').length > 0) { - target = $(e.target).closest('[data-remote-command-long]'); - } else { - return true; - } - - maskRemoteShort = true; - setTimeout(function () { - maskRemoteShort = false; - }, 10000); - - var cmd = $(target).data('remote-command-long'); - if ($(target).data('repeat') != null) { - cmd += "&repeat=" + $(target).data('repeat'); - } - remoteCmd(cmd); - return false; - - }); - mc.on('press', function (e) { var target; if ($(e.target).is('.time.info')) { @@ -333,19 +303,6 @@ $(function () { return true; }); - $(document).on('click', '[data-remote-command]', function () { - if (maskRemoteShort && $(this).is('[data-remote-command-long]')) { - maskRemoteShort = false; - return false; - } - var cmd = $(this).data('remote-command'); - if ($(this).data('repeat') != null) { - cmd += "&repeat=" + $(this).data('repeat'); - } - remoteCmd(cmd); - return false; - }); - console.log('init functions'); changeAddress(); initScreenSaver(); @@ -374,11 +331,6 @@ function volumeUp() { $.get('scripts/volume.php?action=up'); } - -function remoteCmd(cmd) { - $.get('scripts/remotecmd.php?cmd=' + cmd); -} - function checkEcoMode(init) { $.get('/scripts/ecomode.php?j=' + Date.now() + '&heartbeat=1', function (data) { var formerEcoMode = ecomode; @@ -590,9 +542,6 @@ function updateScreenSaver(force) { } function showScreenSaver() { - if ($('main section:visible').data('section') === 'remote') { - return; - } if (androidApp && !window.power) { return; } @@ -762,16 +711,6 @@ function refreshSections(callback) { function _showSection(section) { $('main').find('section').remove(); - if (section === 'remote') { - $.get('scripts/remoteinfos.php', function (data) { - REMOTE_FIRST_DATA = data; - if (data.type !== '') { - _showSection('remote-' + data.type); - } - }); - return; - } - displayLoader(); if ($('main').find('section[data-section="' + section + '"]').length === 0) { $('main').append(SECTIONS[section]); @@ -904,119 +843,4 @@ function resizeText(a, paddingSide) { }); } return span; -} - -function initBricks() { - console.log('init bricks'); - var b = $(".bricks[data-init='0']"); - b.hide(); - b.attr('data-init', '1'); - - $(b).on('click', '.timeline-progressbar', function (e) { - if (!$(e.target).is('.timeline-progressbar')) { - return true; - } - var progress = Math.max(0, Math.min(1, (e.originalEvent.clientX - $(this).get(0).getBoundingClientRect().left) / $(this).outerWidth())); - console.log(progress); - $.get('/scripts/remoteprogress.php?progress=' + progress, function (data) { - _updateRemote(data); - }); - }); - - _updateRemote(REMOTE_FIRST_DATA); - b.show(); - - setTimeout(updateRemote, 500); - resizeBricks(); -} - -function updateRemote() { - $.get('/scripts/remoteinfos.php', function (data) { - if ($('main section:visible').data('section').search('remote-') > -1) { - setTimeout(updateRemote, getRemoteUpdateTime(data)); - } - if (data == null) { - return; - } - _updateRemote(data); - }).fail(function () { - setTimeout(function () { - updateRemote(); - }, 500); - }) -} - -function getRemoteUpdateTime(data) { - if (!data) { - return 1000; - } else if (data.type === 'squeezebox') { - return 2000; - } - return 5000; -} - -function _updateRemote(data) { - if (data.type !== REMOTE_FIRST_DATA.type) { - _showSection('remote', true); - return; - } - - var r = $(".remote-infos .h") - var css = {backgroundImage: "url(" + data.artwork + ")"}; - r.find('.title').html(data.title); - r.css(css); - - var t = $(".remote-timeline"); - $(t).find('.timeline-duration').text(data.duration ? secondsToTime(data.duration) : '--:--'); - $(t).find('.timeline-time').text(data.time ? secondsToTime(data.time) : '--:--'); - if (data.can_seek) { - $(t).find('.timeline-progressbar').css('opacity', 1); - $(t).find('.timeline-cursor').css('left', (Math.max(0, Math.min(data.time / data.duration)) * 100) + '%'); - } else { - $(t).find('.timeline-progressbar').css('opacity', .3); - $(t).find('.timeline-cursor').css('left', 0); - } -} - -function secondsToTime(t) { - t = Math.round(t); - var min = Math.floor(t / 60); - var sec = t % 60; - if (min < 10) { - min = '0' + min; - } - if (sec < 10) { - sec = '0' + sec; - } - - return min + ':' + sec; -} - -function resizeBricks() { - $(".bricks").each(function () { - var cw = $(this).outerWidth(); - var totalMargin = cw * 0.1; - var margin = totalMargin / $(this).data('width'); - - cw -= margin; - var ch = $(this).outerHeight() - margin; - // Brick base dimension - var bw = cw / $(this).data('width'); - var bh = ch / $(this).data('height'); - - $(this).find('.brick').each(function () { - // Util dimensions (excluding padding) - var css = {}; - css.width = bw * $(this).data('width'); - css.height = bh * $(this).data('height'); - css.left = bw * $(this).data('left'); - css.top = bh * $(this).data('top'); - css.fontSize = bh * 0.5; - css.lineHeight = (bh - margin) + 'px'; - css.paddingTop = css.paddingLeft = margin; - $(this).find('.fas,.far').css('lineHeight', css.lineHeight); - $(this).find('.line:not(:eq(0))').css('marginTop', margin); - $(this).css(css); - }); - }); } \ No newline at end of file diff --git a/lib/caldav-client-v2.php b/lib/caldav-client-v2.php deleted file mode 100644 index d280eb0..0000000 --- a/lib/caldav-client-v2.php +++ /dev/null @@ -1,1018 +0,0 @@ - -* @copyright Andrew McMillan -* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU LGPL version 3 or later -*/ - -require_once('XMLDocument.php'); - -/** - * A class for holding basic calendar information - * @package awl - */ -class CalendarInfo { - public $url; - public $displayname; - public $getctag; - - function __construct( $url, $displayname = null, $getctag = null ) { - $this->url = $url; - $this->displayname = $displayname; - $this->getctag = $getctag; - } - - function __toString() { - return( '(URL: '.$this->url.' Ctag: '.$this->getctag.' Displayname: '.$this->displayname .')'. "\n" ); - } -} - -if(!defined("_FSOCK_TIMEOUT")){ - define("_FSOCK_TIMEOUT", 10); -} - -/** -* A class for accessing DAViCal via CalDAV, as a client -* -* @package awl -*/ -class CalDAVClient { - /** - * Server, username, password, calendar - * - * @var string - */ - protected $base_url, $user, $pass, $entry, $protocol, $server, $port; - - /** - * The principal-URL we're using - */ - protected $principal_url; - - /** - * The calendar-URL we're using - */ - protected $calendar_url; - - /** - * The calendar-home-set we're using - */ - protected $calendar_home_set; - - /** - * The calendar_urls we have discovered - */ - protected $calendar_urls; - - /** - * The useragent which is send to the caldav server - * - * @var string - */ - public $user_agent = 'DAViCalClient'; - - protected $headers = array(); - protected $body = ""; - protected $requestMethod = "GET"; - protected $httpRequest = ""; // for debugging http headers sent - protected $xmlRequest = ""; // for debugging xml sent - protected $xmlResponse = ""; // xml received - protected $httpResponseCode = 0; // http response code - protected $httpResponseHeaders = ""; - protected $httpParsedHeaders; - protected $httpResponseBody = ""; - - protected $parser; // our XML parser object - - private $debug = false; // Whether we are debugging - - /** - * Constructor, initialises the class - * - * @param string $base_url The URL for the calendar server - * @param string $user The name of the user logging in - * @param string $pass The password for that user - */ - function __construct( $base_url, $user, $pass ) { - $this->user = $user; - $this->pass = $pass; - $this->headers = array(); - - if ( preg_match( '#^(https?)://([a-z0-9.-]+)(:([0-9]+))?(/.*)$#', $base_url, $matches ) ) { - $this->server = $matches[2]; - $this->base_url = $matches[5]; - if ( $matches[1] == 'https' ) { - $this->protocol = 'ssl'; - $this->port = 443; - } - else { - $this->protocol = 'tcp'; - $this->port = 80; - } - if ( $matches[4] != '' ) { - $this->port = intval($matches[4]); - } - } - else { - trigger_error("Invalid URL: '".$base_url."'", E_USER_ERROR); - } - } - - - /** - * Call this to enable / disable debugging. It will return the prior value of the debugging flag. - * @param boolean $new_value The new value for debugging. - * @return boolean The previous value, in case you want to restore it later. - */ - function SetDebug( $new_value ) { - $old_value = $this->debug; - if ( $new_value ) - $this->debug = true; - else - $this->debug = false; - return $old_value; - } - - - - /** - * Adds an If-Match or If-None-Match header - * - * @param bool $match to Match or Not to Match, that is the question! - * @param string $etag The etag to match / not match against. - */ - function SetMatch( $match, $etag = '*' ) { - $this->headers['match'] = sprintf( "%s-Match: \"%s\"", ($match ? "If" : "If-None"), trim($etag,'"')); - } - - /** - * Add a Depth: header. Valid values are 0, 1 or infinity - * - * @param int $depth The depth, default to infinity - */ - function SetDepth( $depth = '0' ) { - $this->headers['depth'] = 'Depth: '. ($depth == '1' ? "1" : ($depth == 'infinity' ? $depth : "0") ); - } - - /** - * Add a Depth: header. Valid values are 1 or infinity - * - * @param int $depth The depth, default to infinity - */ - function SetUserAgent( $user_agent = null ) { - if ( !isset($user_agent) ) $user_agent = $this->user_agent; - $this->user_agent = $user_agent; - } - - /** - * Add a Content-type: header. - * - * @param string $type The content type - */ - function SetContentType( $type ) { - $this->headers['content-type'] = "Content-type: $type"; - } - - /** - * Set the calendar_url we will be using for a while. - * - * @param string $url The calendar_url - */ - function SetCalendar( $url ) { - $this->calendar_url = $url; - } - - /** - * Split response into httpResponse and xmlResponse - * - * @param string Response from server - */ - function ParseResponse( $response ) { - $pos = strpos($response, 'xmlResponse = trim(substr($response, $pos)); - $this->xmlResponse = preg_replace('{>[^>]*$}s', '>',$this->xmlResponse ); - $parser = xml_parser_create_ns('UTF-8'); - xml_parser_set_option ( $parser, XML_OPTION_SKIP_WHITE, 1 ); - xml_parser_set_option ( $parser, XML_OPTION_CASE_FOLDING, 0 ); - - if ( xml_parse_into_struct( $parser, $this->xmlResponse, $this->xmlnodes, $this->xmltags ) === 0 ) { - printf( "XML parsing error: %s - %s\n", xml_get_error_code($parser), xml_error_string(xml_get_error_code($parser)) ); -// debug_print_backtrace(); -// echo "\nNodes array............................................................\n"; print_r( $this->xmlnodes ); -// echo "\nTags array............................................................\n"; print_r( $this->xmltags ); - printf( "\nXML Reponse:\n%s\n", $this->xmlResponse ); - } - - xml_parser_free($parser); - } - } - - /** - * Split httpResponseHeaders into an array of headers - * - * @return array of arrays of header lines - */ - function ParseResponseHeaders() { - if ( empty($this->httpResponseHeaders) ) return array(); - if ( !isset($this->httpParsedHeaders) ) { - $this->httpParsedHeaders = array(); - $headers = str_replace("\r\n", "\n", $this->httpResponseHeaders); - $ar_headers = explode("\n", $headers); - $last_header = ''; - foreach ($ar_headers as $cur_headers) { - if( preg_match( '{^\s*\S}', $cur_headers) ) $header_name = $last_header; - else if ( preg_match( '{^(\S*):', $cur_headers, $matches) ) { - $header_name = $matches[1]; - $last_header = $header_name; - if ( empty($this->httpParsedHeaders[$header_name]) ) $this->httpParsedHeaders[$header_name] = array(); - } - $this->httpParsedHeaders[$header_name][] = $cur_headers; - } - } - return $this->httpParsedHeaders; - } - - /** - * Output http request headers - * - * @return HTTP headers - */ - function GetHttpRequest() { - return $this->httpRequest; - } - /** - * Output http response headers - * - * @return HTTP headers - */ - function GetResponseHeaders() { - return $this->httpResponseHeaders; - } - /** - * Output http response body - * - * @return HTTP body - */ - function GetResponseBody() { - return $this->httpResponseBody; - } - /** - * Output xml request - * - * @return raw xml - */ - function GetXmlRequest() { - return $this->xmlRequest; - } - /** - * Output xml response - * - * @return raw xml - */ - function GetXmlResponse() { - return $this->xmlResponse; - } - - /** - * Send a request to the server - * - * @param string $url The URL to make the request to - * - * @return string The content of the response from the server - */ - function DoRequest( $url = null ) { - $headers = array(); - - if ( !isset($url) ) $url = $this->base_url; - $this->request_url = $url; - $url = preg_replace('{^https?://[^/]+}', '', $url); - // URLencode if it isn't already - if ( preg_match( '{[^%?&=+,.-_/a-z0-9]}', $url ) ) { - $url = str_replace(rawurlencode('/'),'/',rawurlencode($url)); - $url = str_replace(rawurlencode('?'),'?',$url); - $url = str_replace(rawurlencode('&'),'&',$url); - $url = str_replace(rawurlencode('='),'=',$url); - $url = str_replace(rawurlencode('+'),'+',$url); - $url = str_replace(rawurlencode(','),',',$url); - } - $headers[] = $this->requestMethod." ". $url . " HTTP/1.1"; - $headers[] = "Authorization: Basic ".base64_encode($this->user .":". $this->pass ); - $headers[] = "Host: ".$this->server .":".$this->port; - - if ( !isset($this->headers['content-type']) ) $this->headers['content-type'] = "Content-type: text/plain"; - foreach( $this->headers as $ii => $head ) { - $headers[] = $head; - } - $headers[] = "Content-Length: " . strlen($this->body); - $headers[] = "User-Agent: " . $this->user_agent; - $headers[] = 'Connection: close'; - $this->httpRequest = join("\r\n",$headers); - $this->xmlRequest = $this->body; - - $this->xmlResponse = ''; - - $fip = fsockopen( $this->protocol . '://' . $this->server, $this->port, $errno, $errstr, _FSOCK_TIMEOUT); //error handling? - if ( !(get_resource_type($fip) == 'stream') ) return false; - if ( !fwrite($fip, $this->httpRequest."\r\n\r\n".$this->body) ) { fclose($fip); return false; } - $response = ""; - while( !feof($fip) ) { $response .= fgets($fip,8192); } - fclose($fip); - - list( $this->httpResponseHeaders, $this->httpResponseBody ) = preg_split( '{\r?\n\r?\n}s', $response, 2 ); - if ( preg_match( '{Transfer-Encoding: chunked}i', $this->httpResponseHeaders ) ) $this->Unchunk(); - if ( preg_match('/HTTP\/\d\.\d (\d{3})/', $this->httpResponseHeaders, $status) ) - $this->httpResponseCode = intval($status[1]); - else - $this->httpResponseCode = 0; - - $this->headers = array(); // reset the headers array for our next request - $this->ParseResponse($this->httpResponseBody); - return $response; - } - - - /** - * Unchunk a chunked response - */ - function Unchunk() { - $content = ''; - $chunks = $this->httpResponseBody; - // printf( "\n================================\n%s\n================================\n", $chunks ); - do { - $bytes = 0; - if ( preg_match('{^((\r\n)?\s*([ 0-9a-fA-F]+)(;[^\n]*)?\r?\n)}', $chunks, $matches ) ) { - $octets = $matches[3]; - $bytes = hexdec($octets); - $pos = strlen($matches[1]); - // printf( "Chunk size 0x%s (%d)\n", $octets, $bytes ); - if ( $bytes > 0 ) { - // printf( "---------------------------------\n%s\n---------------------------------\n", substr($chunks,$pos,$bytes) ); - $content .= substr($chunks,$pos,$bytes); - $chunks = substr($chunks,$pos + $bytes + 2); - // printf( "+++++++++++++++++++++++++++++++++\n%s\n+++++++++++++++++++++++++++++++++\n", $chunks ); - } - } - else { - $content .= $chunks; - } - } - while( $bytes > 0 ); - $this->httpResponseBody = $content; - // printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n%s\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n", $content ); - } - - - /** - * Send an OPTIONS request to the server - * - * @param string $url The URL to make the request to - * - * @return array The allowed options - */ - function DoOptionsRequest( $url = null ) { - $this->requestMethod = "OPTIONS"; - $this->body = ""; - $this->DoRequest($url); - $this->ParseResponseHeaders(); - $allowed = ''; - foreach( $this->httpParsedHeaders['Allow'] as $allow_header ) { - $allowed .= preg_replace( '/^(Allow:)?\s+([a-z, ]+)\r?\n.*/is', '$1,', $allow_header ); - } - $options = array_flip( preg_split( '/[, ]+/', trim($allowed, ', ') )); - return $options; - } - - - - /** - * Send an XML request to the server (e.g. PROPFIND, REPORT, MKCALENDAR) - * - * @param string $method The method (PROPFIND, REPORT, etc) to use with the request - * @param string $xml The XML to send along with the request - * @param string $url The URL to make the request to - * - * @return array An array of the allowed methods - */ - function DoXMLRequest( $request_method, $xml, $url = null ) { - $this->body = $xml; - $this->requestMethod = $request_method; - $this->SetContentType("text/xml"); - return $this->DoRequest($url); - } - - - - /** - * Get a single item from the server. - * - * @param string $url The URL to GET - */ - function DoGETRequest( $url ) { - $this->body = ""; - $this->requestMethod = "GET"; - return $this->DoRequest( $url ); - } - - - /** - * Get the HEAD of a single item from the server. - * - * @param string $url The URL to HEAD - */ - function DoHEADRequest( $url ) { - $this->body = ""; - $this->requestMethod = "HEAD"; - return $this->DoRequest( $url ); - } - - - /** - * PUT a text/icalendar resource, returning the etag - * - * @param string $url The URL to make the request to - * @param string $icalendar The iCalendar resource to send to the server - * @param string $etag The etag of an existing resource to be overwritten, or '*' for a new resource. - * - * @return string The content of the response from the server - */ - function DoPUTRequest( $url, $icalendar, $etag = null ) { - $this->body = $icalendar; - - $this->requestMethod = "PUT"; - if ( $etag != null ) { - $this->SetMatch( ($etag != '*'), $etag ); - } - $this->SetContentType('text/calendar; charset="utf-8"'); - $this->DoRequest($url); - - $etag = null; - if ( preg_match( '{^ETag:\s+"([^"]*)"\s*$}im', $this->httpResponseHeaders, $matches ) ) $etag = $matches[1]; - if ( !isset($etag) || $etag == '' ) { - if ( $this->debug ) printf( "No etag in:\n%s\n", $this->httpResponseHeaders ); - $save_request = $this->httpRequest; - $save_response_headers = $this->httpResponseHeaders; - $this->DoHEADRequest( $url ); - if ( preg_match( '{^Etag:\s+"([^"]*)"\s*$}im', $this->httpResponseHeaders, $matches ) ) $etag = $matches[1]; - if ( !isset($etag) || $etag == '' ) { - if ( $this->debug ) printf( "Still No etag in:\n%s\n", $this->httpResponseHeaders ); - } - $this->httpRequest = $save_request; - $this->httpResponseHeaders = $save_response_headers; - } - return $etag; - } - - - /** - * DELETE a text/icalendar resource - * - * @param string $url The URL to make the request to - * @param string $etag The etag of an existing resource to be deleted, or '*' for any resource at that URL. - * - * @return int The HTTP Result Code for the DELETE - */ - function DoDELETERequest( $url, $etag = null ) { - $this->body = ""; - - $this->requestMethod = "DELETE"; - if ( $etag != null ) { - $this->SetMatch( true, $etag ); - } - $this->DoRequest($url); - return $this->httpResponseCode; - } - - - /** - * Get a single item from the server. - * - * @param string $url The URL to PROPFIND on - */ - function DoPROPFINDRequest( $url, $props, $depth = 0 ) { - $this->SetDepth($depth); - $xml = new XMLDocument( array( 'DAV:' => '', 'urn:ietf:params:xml:ns:caldav' => 'C' ) ); - $prop = new XMLElement('prop'); - foreach( $props AS $v ) { - $xml->NSElement($prop,$v); - } - - $this->body = $xml->Render('propfind',$prop ); - - $this->requestMethod = "PROPFIND"; - $this->SetContentType("text/xml"); - $this->DoRequest($url); - return $this->GetXmlResponse(); - } - - - /** - * Get/Set the Principal URL - * - * @param $url string The Principal URL to set - */ - function PrincipalURL( $url = null ) { - if ( isset($url) ) { - $this->principal_url = $url; - } - return $this->principal_url; - } - - - /** - * Get/Set the calendar-home-set URL - * - * @param $url array of string The calendar-home-set URLs to set - */ - function CalendarHomeSet( $urls = null ) { - if ( isset($urls) ) { - if ( ! is_array($urls) ) $urls = array($urls); - $this->calendar_home_set = $urls; - } - return $this->calendar_home_set; - } - - - /** - * Get/Set the calendar-home-set URL - * - * @param $urls array of string The calendar URLs to set - */ - function CalendarUrls( $urls = null ) { - if ( isset($urls) ) { - if ( ! is_array($urls) ) $urls = array($urls); - $this->calendar_urls = $urls; - } - return $this->calendar_urls; - } - - - /** - * Return the first occurrence of an href inside the named tag. - * - * @param string $tagname The tag name to find the href inside of - */ - function HrefValueInside( $tagname ) { - foreach( $this->xmltags[$tagname] AS $k => $v ) { - $j = $v + 1; - if ( $this->xmlnodes[$j]['tag'] == 'DAV::href' ) { - return rawurldecode($this->xmlnodes[$j]['value']); - } - } - return null; - } - - - /** - * Return the href containing this property. Except only if it's inside a status != 200 - * - * @param string $tagname The tag name of the property to find the href for - * @param integer $which Which instance of the tag should we use - */ - function HrefForProp( $tagname, $i = 0 ) { - if ( isset($this->xmltags[$tagname]) && isset($this->xmltags[$tagname][$i]) ) { - $j = $this->xmltags[$tagname][$i]; - while( $j-- > 0 && $this->xmlnodes[$j]['tag'] != 'DAV::href' ) { -// printf( "Node[$j]: %s\n", $this->xmlnodes[$j]['tag']); - if ( $this->xmlnodes[$j]['tag'] == 'DAV::status' && $this->xmlnodes[$j]['value'] != 'HTTP/1.1 200 OK' ) return null; - } -// printf( "Node[$j]: %s\n", $this->xmlnodes[$j]['tag']); - if ( $j > 0 && isset($this->xmlnodes[$j]['value']) ) { -// printf( "Value[$j]: %s\n", $this->xmlnodes[$j]['value']); - return rawurldecode($this->xmlnodes[$j]['value']); - } - } - else { - if ( $this->debug ) printf( "xmltags[$tagname] or xmltags[$tagname][$i] is not set\n"); - } - return null; - } - - - /** - * Return the href which has a resourcetype of the specified type - * - * @param string $tagname The tag name of the resourcetype to find the href for - * @param integer $which Which instance of the tag should we use - */ - function HrefForResourcetype( $tagname, $i = 0 ) { - if ( isset($this->xmltags[$tagname]) && isset($this->xmltags[$tagname][$i]) ) { - $j = $this->xmltags[$tagname][$i]; - while( $j-- > 0 && $this->xmlnodes[$j]['tag'] != 'DAV::resourcetype' ); - if ( $j > 0 ) { - while( $j-- > 0 && $this->xmlnodes[$j]['tag'] != 'DAV::href' ); - if ( $j > 0 && isset($this->xmlnodes[$j]['value']) ) { - return rawurldecode($this->xmlnodes[$j]['value']); - } - } - } - return null; - } - - - /** - * Return the ... of a propstat where the status is OK - * - * @param string $nodenum The node number in the xmlnodes which is the href - */ - function GetOKProps( $nodenum ) { - $props = null; - $level = $this->xmlnodes[$nodenum]['level']; - $status = ''; - while ( $this->xmlnodes[++$nodenum]['level'] >= $level ) { - if ( $this->xmlnodes[$nodenum]['tag'] == 'DAV::propstat' ) { - if ( $this->xmlnodes[$nodenum]['type'] == 'open' ) { - $props = array(); - $status = ''; - } - else { - if ( $status == 'HTTP/1.1 200 OK' ) break; - } - } - elseif ( !isset($this->xmlnodes[$nodenum]) || !is_array($this->xmlnodes[$nodenum]) ) { - break; - } - elseif ( $this->xmlnodes[$nodenum]['tag'] == 'DAV::status' ) { - $status = $this->xmlnodes[$nodenum]['value']; - } - else { - $props[] = $this->xmlnodes[$nodenum]; - } - } - return $props; - } - - - /** - * Attack the given URL in an attempt to find a principal URL - * - * @param string $url The URL to find the principal-URL from - */ - function FindPrincipal( $url=null ) { - $xml = $this->DoPROPFINDRequest( $url, array('resourcetype', 'current-user-principal', 'owner', 'principal-URL', - 'urn:ietf:params:xml:ns:caldav:calendar-home-set'), 1); - - $principal_url = $this->HrefForProp('DAV::principal'); - - if ( !isset($principal_url) ) { - foreach( array('DAV::current-user-principal', 'DAV::principal-URL', 'DAV::owner') AS $href ) { - if ( !isset($principal_url) ) { - $principal_url = $this->HrefValueInside($href); - } - } - } - - return $this->PrincipalURL($principal_url); - } - - - /** - * Attack the given URL in an attempt to find a principal URL - * - * @param string $url The URL to find the calendar-home-set from - */ - function FindCalendarHome( $recursed=false ) { - if ( !isset($this->principal_url) ) { - $this->FindPrincipal(); - } - if ( $recursed ) { - $this->DoPROPFINDRequest( $this->principal_url, array('urn:ietf:params:xml:ns:caldav:calendar-home-set'), 0); - } - - $calendar_home = array(); - foreach( $this->xmltags['urn:ietf:params:xml:ns:caldav:calendar-home-set'] AS $k => $v ) { - if ( $this->xmlnodes[$v]['type'] != 'open' ) continue; - while( $this->xmlnodes[++$v]['type'] != 'close' && $this->xmlnodes[$v]['tag'] != 'urn:ietf:params:xml:ns:caldav:calendar-home-set' ) { -// printf( "Tag: '%s' = '%s'\n", $this->xmlnodes[$v]['tag'], $this->xmlnodes[$v]['value']); - if ( $this->xmlnodes[$v]['tag'] == 'DAV::href' && isset($this->xmlnodes[$v]['value']) ) - $calendar_home[] = rawurldecode($this->xmlnodes[$v]['value']); - } - } - - if ( !$recursed && count($calendar_home) < 1 ) { - $calendar_home = $this->FindCalendarHome(true); - } - - return $this->CalendarHomeSet($calendar_home); - } - - - /** - * Find the calendars, from the calendar_home_set - */ - function FindCalendars( $recursed=false ) { - if ( !isset($this->calendar_home_set[0]) ) { - $this->FindCalendarHome(); - } - $this->DoPROPFINDRequest( $this->calendar_home_set[0], array('resourcetype','displayname','http://calendarserver.org/ns/:getctag'), 1); - - $calendars = array(); - if ( isset($this->xmltags['urn:ietf:params:xml:ns:caldav:calendar']) ) { - $calendar_urls = array(); - foreach( $this->xmltags['urn:ietf:params:xml:ns:caldav:calendar'] AS $k => $v ) { - $calendar_urls[$this->HrefForProp('urn:ietf:params:xml:ns:caldav:calendar', $k)] = 1; - } - - foreach( $this->xmltags['DAV::href'] AS $i => $hnode ) { - $href = rawurldecode($this->xmlnodes[$hnode]['value']); - - if ( !isset($calendar_urls[$href]) ) continue; - -// printf("Seems '%s' is a calendar.\n", $href ); - - $calendar = new CalendarInfo($href); - $ok_props = $this->GetOKProps($hnode); - foreach( $ok_props AS $v ) { -// printf("Looking at: %s[%s]\n", $href, $v['tag'] ); - switch( $v['tag'] ) { - case 'http://calendarserver.org/ns/:getctag': - $calendar->getctag = $v['value']; - break; - case 'DAV::displayname': - $calendar->displayname = $v['value']; - break; - } - } - $calendars[] = $calendar; - } - } - - return $this->CalendarUrls($calendars); - } - - - /** - * Find the calendars, from the calendar_home_set - */ - function GetCalendarDetails( $url = null ) { - if ( isset($url) ) $this->SetCalendar($url); - - $calendar_properties = array( 'resourcetype', 'displayname', 'http://calendarserver.org/ns/:getctag', 'urn:ietf:params:xml:ns:caldav:calendar-timezone', 'supported-report-set' ); - $this->DoPROPFINDRequest( $this->calendar_url, $calendar_properties, 0); - - $hnode = $this->xmltags['DAV::href'][0]; - $href = rawurldecode($this->xmlnodes[$hnode]['value']); - - $calendar = new CalendarInfo($href); - $ok_props = $this->GetOKProps($hnode); - foreach( $ok_props AS $k => $v ) { - $name = preg_replace( '{^.*:}', '', $v['tag'] ); - if ( isset($v['value'] ) ) { - $calendar->{$name} = $v['value']; - } -/* else { - printf( "Calendar property '%s' has no text content\n", $v['tag'] ); - }*/ - } - - return $calendar; - } - - - /** - * Get all etags for a calendar - */ - function GetCollectionETags( $url = null ) { - if ( isset($url) ) $this->SetCalendar($url); - - $this->DoPROPFINDRequest( $this->calendar_url, array('getetag'), 1); - - $etags = array(); - if ( isset($this->xmltags['DAV::getetag']) ) { - foreach( $this->xmltags['DAV::getetag'] AS $k => $v ) { - $href = $this->HrefForProp('DAV::getetag', $k); - if ( isset($href) && isset($this->xmlnodes[$v]['value']) ) $etags[$href] = $this->xmlnodes[$v]['value']; - } - } - - return $etags; - } - - - /** - * Get a bunch of events for a calendar with a calendar-multiget report - */ - function CalendarMultiget( $event_hrefs, $url = null ) { - - if ( isset($url) ) $this->SetCalendar($url); - - $hrefs = ''; - foreach( $event_hrefs AS $k => $href ) { - $href = str_replace( rawurlencode('/'),'/',rawurlencode($href)); - $hrefs .= ''.$href.''; - } - $this->body = << - - -$hrefs - -EOXML; - - $this->requestMethod = "REPORT"; - $this->SetContentType("text/xml"); - $this->DoRequest( $this->calendar_url ); - - $events = array(); - if ( isset($this->xmltags['urn:ietf:params:xml:ns:caldav:calendar-data']) ) { - foreach( $this->xmltags['urn:ietf:params:xml:ns:caldav:calendar-data'] AS $k => $v ) { - $href = $this->HrefForProp('urn:ietf:params:xml:ns:caldav:calendar-data', $k); -// echo "Calendar-data:\n"; print_r($this->xmlnodes[$v]); - $events[$href] = $this->xmlnodes[$v]['value']; - } - } - else { - foreach( $event_hrefs AS $k => $href ) { - $this->DoGETRequest($href); - $events[$href] = $this->httpResponseBody; - } - } - - return $events; - } - - - /** - * Given XML for a calendar query, return an array of the events (/todos) in the - * response. Each event in the array will have a 'href', 'etag' and '$response_type' - * part, where the 'href' is relative to the calendar and the '$response_type' contains the - * definition of the calendar data in iCalendar format. - * - * @param string $filter XML fragment which is the element of a calendar-query - * @param string $url The URL of the calendar, or empty/null to use the 'current' calendar_url - * - * @return array An array of the relative URLs, etags, and events from the server. Each element of the array will - * be an array with 'href', 'etag' and 'data' elements, corresponding to the URL, the server-supplied - * etag (which only varies when the data changes) and the calendar data in iCalendar format. - */ - function DoCalendarQuery( $filter, $url = '' ) { - - if ( !empty($url) ) $this->SetCalendar($url); - - $this->body = << - - - - - $filter - -EOXML; - - $this->requestMethod = "REPORT"; - $this->SetContentType("text/xml"); - $this->DoRequest( $this->calendar_url ); - - $report = array(); - foreach( $this->xmlnodes as $k => $v ) { - switch( $v['tag'] ) { - case 'DAV::response': - if ( $v['type'] == 'open' ) { - $response = array(); - } - elseif ( $v['type'] == 'close' ) { - $report[] = $response; - } - break; - case 'DAV::href': - $response['href'] = basename( rawurldecode($v['value']) ); - break; - case 'DAV::getetag': - $response['etag'] = preg_replace('/^"?([^"]+)"?/', '$1', $v['value']); - break; - case 'urn:ietf:params:xml:ns:caldav:calendar-data': - $response['data'] = $v['value']; - break; - } - } - return $report; - } - - - /** - * Get the events in a range from $start to $finish. The dates should be in the - * format yyyymmddThhmmssZ and should be in GMT. The events are returned as an - * array of event arrays. Each event array will have a 'href', 'etag' and 'event' - * part, where the 'href' is relative to the calendar and the event contains the - * definition of the event in iCalendar format. - * - * @param timestamp $start The start time for the period - * @param timestamp $finish The finish time for the period - * @param string $relative_url The URL relative to the base_url specified when the calendar was opened. Default ''. - * - * @return array An array of the relative URLs, etags, and events, returned from DoCalendarQuery() @see DoCalendarQuery() - */ - function GetEvents( $start = null, $finish = null, $relative_url = '' ) { - $filter = ""; - if ( isset($start) && isset($finish) ) - $range = ""; - else - $range = ''; - - $filter = << - - - $range - - - -EOFILTER; - - return $this->DoCalendarQuery($filter, $relative_url); - } - - - /** - * Get the todo's in a range from $start to $finish. The dates should be in the - * format yyyymmddThhmmssZ and should be in GMT. The events are returned as an - * array of event arrays. Each event array will have a 'href', 'etag' and 'event' - * part, where the 'href' is relative to the calendar and the event contains the - * definition of the event in iCalendar format. - * - * @param timestamp $start The start time for the period - * @param timestamp $finish The finish time for the period - * @param boolean $completed Whether to include completed tasks - * @param boolean $cancelled Whether to include cancelled tasks - * @param string $relative_url The URL relative to the base_url specified when the calendar was opened. Default ''. - * - * @return array An array of the relative URLs, etags, and events, returned from DoCalendarQuery() @see DoCalendarQuery() - */ - function GetTodos( $start, $finish, $completed = false, $cancelled = false, $relative_url = "" ) { - - if ( $start && $finish ) { -$time_range = << -EOTIME; - } - - // Warning! May contain traces of double negatives... - $neg_cancelled = ( $cancelled === true ? "no" : "yes" ); - $neg_completed = ( $cancelled === true ? "no" : "yes" ); - - $filter = << - - - - COMPLETED - - - CANCELLED - $time_range - - - -EOFILTER; - - return $this->DoCalendarQuery($filter, $relative_url); - } - - - /** - * Get the calendar entry by UID - * - * @param uid - * @param string $relative_url The URL relative to the base_url specified when the calendar was opened. Default ''. - * @param string $component_type The component type inside the VCALENDAR. Default 'VEVENT'. - * - * @return array An array of the relative URL, etag, and calendar data returned from DoCalendarQuery() @see DoCalendarQuery() - */ - function GetEntryByUid( $uid, $relative_url = '', $component_type = 'VEVENT' ) { - $filter = ""; - if ( $uid ) { - $filter = << - - - - $uid - - - - -EOFILTER; - } - - return $this->DoCalendarQuery($filter, $relative_url); - } - - - /** - * Get the calendar entry by HREF - * - * @param string $href The href from a call to GetEvents or GetTodos etc. - * - * @return string The iCalendar of the calendar entry - */ - function GetEntryByHref( $href ) { - $href = str_replace( rawurlencode('/'),'/',rawurlencode($href)); - return $this->DoGETRequest( $href ); - } - -} diff --git a/scripts/homeassistant_device_event.php b/scripts/homeassistant_device_event.php index de1c035..ce2446f 100644 --- a/scripts/homeassistant_device_event.php +++ b/scripts/homeassistant_device_event.php @@ -28,10 +28,6 @@ switch ($_GET['id']) { $forceConfig = 'bureau'; $action = 'cubeBureau'; break; - case HA_SWITCH_BUREAU: - $forceConfig = 'bureau'; - $action = 'switchBureau'; - break; case HA_SWITCH_BEDROOM: $forceConfig = 'chambre'; $action = 'chambreToggle'; @@ -100,30 +96,6 @@ function wcSwitch() } } -function switchBureau() -{ - switch ($_GET['state']) { - case '1_double': - stopMusiqueBureau(); - break; - case '2_double': - musiqueBureau(); - break; - case '1_hold': - case '2_hold': - execScene('bureau/rideaux/toggle', true); - break; - case '1_single': - haAction('script.klarstein_fan_toggle'); - break; - case '2_single': - haAction(HA_OFFICE_MAIN_SCREEN); - execScene('bureau/auto', true); - break; - default: - break; - } -} function cubeBureau() { @@ -149,24 +121,12 @@ function cubeBureau() off('bureau'); break; case 'slide': -// if ($face == 5) { -// haAction('script.klarstein_fan_toggle'); -// break; -// } stopMusiqueBureau(); break; case 'rotate_right': -// if ($face == 5) { -// haAction('script.klarstein_fan_speed_up'); -// break; -// } volume(config('VOLUME_STEP'), '+'); break; case 'rotate_left': -// if ($face == 5) { -// haAction('script.klarstein_fan_speed_down'); -// break; -// } volume(config('VOLUME_STEP'), '-'); break; case 'tap': diff --git a/scripts/lib/bricks.php b/scripts/lib/bricks.php deleted file mode 100644 index fda68b9..0000000 --- a/scripts/lib/bricks.php +++ /dev/null @@ -1,220 +0,0 @@ -'; - foreach ($bricks['bricks'] as $brick) { - - $c = ''; - $f = preg_replace_callback('/-(.?)/', function ($e) { - return strtoupper($e[1]); - }, 'get-' . $brick['type'] . '-brick'); - if (function_exists($f)) { - $c = $f($brick); - } - - $class = ''; - if (is_array($c)) { - $class = $c['class']; - $c = $c['content']; - } - - $res .= '
' . - '
' . $c . '
'; - } - $res .= ''; - return $res; -} - -function getRemoteVolumeBrick($brick) -{ - $res = '
'; - $res .= '
'; - $res .= '
'; - return $res; -} - -function getRemoteSubtitlesBrick($brick) -{ - $res = '
'; - $res .= '
'; - $res .= '
'; - return $res; -} - -function getRemoteChannelsBrick($brick) -{ - $res = '
'; - $res .= '
'; - $res .= '
'; - return $res; -} - - -function getRemotePlaypauseBrick($brick) -{ - $res = '
'; - return $res; -} - -function getRemoteStopBrick($brick) -{ - return _fullBrickButton('stop', 'stop'); -} - -function getRemoteBlueBrick($brick) -{ - return _fullBrickButton('search', 'blue', 'background-color:#0F49A8;color:#fff;'); -} - -function getRemoteShieldHomeBrick($brick) -{ - return _fullBrickButton('home', 'home', 'background-color:#0F49A8;color:#fff;'); -} - -function getRemoteYellowBrick($brick) -{ - return _fullBrickButton('info-circle', 'yellow', 'background-color:#fc0;color:#fff;'); -} - -function getRemoteGreenBrick($brick) -{ - return _fullBrickButton('bars', 'green', 'background-color:#00B233;color:#fff;'); -} - -function getRemoteShieldMenuBrick($brick) -{ - return _fullBrickButton('bars', 'menu', 'background-color:#00B233;color:#fff;'); -} - -function getRemoteShieldBackBrick($brick) -{ - return _fullBrickButton('backspace', 'back', 'background-color:#c00;color:#fff;'); -} - -function getRemoteRedBrick($brick) -{ - return _fullBrickButton('backspace', 'red', 'background-color:#c00;color:#fff;'); -} - -function getRemoteUpBrick($brick) -{ - return _fullArrowBrickButton('caret-up', 'direction-up', 'font-size:1.75em;top:-0.05em;'); -} - -function getRemoteLeftBrick($brick) -{ - return _fullArrowBrickButton('caret-left', 'direction-left', 'font-size:1.75em;left:-0.05em;'); -} - -function getRemoteRightBrick($brick) -{ - return _fullArrowBrickButton('caret-right', 'direction-right', 'font-size:1.75em;left:0.05em;'); -} - -function getRemoteDownBrick($brick) -{ - return _fullArrowBrickButton('caret-down', 'direction-down', 'font-size:1.75em;top:0.05em;'); -} - -function getRemoteOkBrick($brick) -{ - return _fullCustomBrickButton('OK', 'select', '', 'arrow'); -} - -function getRemoteShieldOkBrick($brick) -{ - return _fullBrickButton('circle', 'ok', '','fas','arrow'); -} - -function getRemoteTimelineBrick($brick) -{ - $res = '
00:00
00:00
'; - return $res; -} - -function getRemoteInfosBrick($brick) -{ - $res = '
'; - return $res; -} - -function getRemoteTouchBrick($brick) -{ - return '
'; -} - -function getRemoteRewBrick($brick) -{ - return _fullBrickButton('backward', ['command' => 'rewind', 'long' => 'fast-rewind']); -} - -function getRemoteLightUpBrick($brick) -{ - return _fullBrickButton('lightbulb', 'light-up', '', 'far'); -} - -function getRemoteLightDownBrick($brick) -{ - return _fullBrickButton('lightbulb', 'light-down'); -} - - -function getRemoteFwdBrick($brick) -{ - return _fullBrickButton('forward', ['command' => 'forward', 'long' => 'fast-forward']); -} - -function getRemoteNextBrick($brick) -{ - return _fullBrickButton('fast-forward', ['command' => 'next', 'long' => 'prev']); -} - -function getRemoteRecBrick($brick) -{ - return _fullBrickButton('circle', 'record', 'color:#c00;'); -} - -function getRemoteFreeBrick($free) -{ - return _fullCustomBrickButton('', 'menu'); -} - -function _fullCustomBrickButton($content, $command, $style = "", $class = '') -{ - if (!is_array($command)) { - $command = ['command' => $command]; - } - $long = ''; - if (isset($command['long'])) { - $long = ' data-remote-command-long="' . $command['long'] . '"'; - } - return ['class' => $class, 'content' => '' . $content . '']; -} - -function _fullBrickButton($icon, $command, $style = "", $iconstyle = 'fas',$class='') -{ - if (!is_array($command)) { - $command = ['command' => $command]; - } - $long = ''; - if (isset($command['long'])) { - $long = ' data-remote-command-long="' . $command['long'] . '"'; - } - return ['class'=>$class,'content'=>'']; -} - -function _fullArrowBrickButton($icon, $command, $style = "") -{ - if (!is_array($command)) { - $command = ['command' => $command]; - } - $long = ''; - if (isset($command['long'])) { - $long = ' data-remote-command-long="' . $command['long'] . '"'; - } - return ['class' => 'arrow', 'content' => '']; -} - diff --git a/scripts/lib/lib.php b/scripts/lib/lib.php index 3cc12cc..0220519 100644 --- a/scripts/lib/lib.php +++ b/scripts/lib/lib.php @@ -23,11 +23,8 @@ require_once ROOT . '/scripts/lib/ecomode.php'; require_once ROOT . '/scripts/lib/off.php'; require_once ROOT . '/scripts/lib/ir.php'; require_once ROOT . '/scripts/lib/playing.php'; -require_once ROOT . '/scripts/lib/bricks.php'; require_once ROOT . '/scripts/lib/youtubedl.php'; -require_once ROOT . '/scripts/lib/remoteinfos.php'; require_once ROOT . '/scripts/lib/weatherstation.php'; -require_once ROOT . '/scripts/lib/medialibrary.php'; require_once ROOT . '/scripts/lib/heartbeats.php'; require_once ROOT . '/scripts/lib/ssh.php'; require_once ROOT . '/scripts/lib/cachemedia.php'; @@ -310,7 +307,6 @@ function shortcut($s, $hash) } elseif ($s['type'] == 'freebox' || $s['type'] === 'shield' || $s['type'] === 'netflix' || $s['type'] === 'amazonprime' || $s['type'] === 'nintendoswitch') { $attrs['href'] = $s['url']; $attrs['class'] = 'ajax play ' . $s['type']; - $attrs['data-remote'] = "1"; } else if ($s['type'] == 'map') { $rand = rand(1, 1000000); $html = '' . $s['map'] . ''; @@ -582,11 +578,7 @@ function makeNav($nav) 'lights' => '
Lumières
', 'music' => '
Musique & Radio
', 'media' => '
Medias & TV
', - 'coffee' => '
Cuisine / Café
', - 'fan' => 'Ventilateur', - 'remote' => '
Télécommande
', 'switch' => '
Changer de pièce
', - 'clock' => '
Réveil
', 'settings' => '
Paramètres
', 'alert' => '
Alerte
', 'off' => '
Éteindre
', diff --git a/scripts/lib/medialibrary.php b/scripts/lib/medialibrary.php deleted file mode 100644 index 05af39b..0000000 --- a/scripts/lib/medialibrary.php +++ /dev/null @@ -1,334 +0,0 @@ - $value) { - $path = realpath($dir . DIRECTORY_SEPARATOR . $value); - if (!is_dir($path)) { - $e = explode('.', $value); - $ext = mb_strtolower(array_pop($e)); - if (in_array($ext, $videoExt)) { - if (stristr($path, '.x264.')) { - continue; - } - $normPath = normPath($path); - $results[] = array('path' => $normPath, 'ext' => $ext, 'codec' => getVideoCodec($path), 'x264path' => getX264Version($path, false), 'srt' => hasSRT($normPath), 'seen' => seen($normPath), 'dir' => false, 'name' => mediaName(implode(' ', $e), $context, false, $path)); - } - } else if ($value != "." && $value != ".." && $value != '@eaDir') { - $files = getMediaContents($path, $context, $seen); - $n = count($files); - if ($n == 0) { - continue; - } else if ($n == 1 && !$files[0]['dir']) { - $results[] = $files[0]; - } else { - $normPath = normPath($path); - $results[] = array('path' => $normPath, 'ext' => $ext, 'codec' => getVideoCodec($path), 'x264path' => getX264Version($path, false), 'seen' => seen($normPath), 'dir' => true, 'id' => hash('sha256', $path), 'name' => mediaName($value, $context, true, $path), 'items' => $files); - } - } - } - - if (count($results) == 1) { - $e = explode('/', $dir); - $results[0]['name'] = array_pop($e); - } - - return $results; -} - -function seen($path) -{ - global $seen; - if (!isset($seen) || null === $seen) { - $seen = connectRedis()->igbget('mediaseen'); - } - if (!is_array($seen)) { - $seen = []; - } - - $path = normPath($path); - if (isset($seen[$path])) { - return true; - } - $x264 = getX264Version($path, true); - if (isset($seen[$x264])) { - $seen[$path] = true; - connectRedis()->igbset('mediaseen', $seen); - return true; - } - return false; -} - -function hasSRT($path) -{ - $langs = ['fr', 'en']; - $e = explode('.', $path); - $ext = array_pop($e); - $p = implode('.', $e); - - $paths = [$p . '.srt' => 'fr', $p . '.fr.srt' => 'fr', $p . '.en.srt' => 'en']; - $res = []; - foreach ($paths as $path => $lang) { - if (file_exists($path)) { - $res[] = $lang; - } - } - return array_unique($res); -} - -function getX264Version($path, $forceReturn = false) -{ - $e = explode('.', $path); - $ext = array_pop($e); - array_push($e, 'x264'); - if ($ext === 'avi') { - $ext = 'mkv'; - } - array_push($e, $ext); - $x264path = implode('.', $e); - if ($forceReturn || file_exists($x264path)) { - return $x264path; - } - return $path; -} - -function normPath($path) -{ - global $shareroot; - return preg_replace('|^' . $shareroot . '|', '', $path); -} - -function mediaName($name, $context, $dir, $path) -{ - if ($context == 'tvshow') { - if ($dir) { - if (file_exists($path . '/.tmbd.id')) { - rename($path . '/.tmbd.id', $path . '/.tmdb.id'); - } - - if (file_exists($path . '/.tmdb.id')) { - $tv = getTVShowByID(file_get_contents($path . '/.tmdb.id')); - return $tv['name']; - } - if (preg_match('|S[0-9]{2}|i', $name, $matches)) { - return $matches[0]; - } - if (preg_match('|Temporada ([0-9]{1,2})|i', $name, $matches)) { - return 'S' . $matches[1]; - } - } else { - if (preg_match('|[ex]([0-9]{2})|i', $name, $matches)) { - return 'E' . $matches[1]; - } - if (preg_match('|^[0-9]{2}$|', $name, $matches)) { - return 'E' . $name; - } - } - } - return $name; -} - -// -//// /volume1/@appstore/ffmpeg/bin/ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 /volume1/Share/Videos/Series/Westworld/S01/E01.mkv -//// -////ffmpeg -i /volume1/Share/Videos/Séries/Westworld/S01/E01.mkv -c:v libx264 -crf 19 -preset slow -c:a aac -b:a 192k -ac 2 /volume1/Share/Videos/Séries/Westworld/S01/E01.x264.mkv -// - - -function getTranscodedPath(SplFileInfo $item) -{ - $destext = $item->getExtension(); - if ($destext === 'avi') { - $destext = 'mkv'; - } - $normalized = $item->getRealPath(); - $normalized = str_replace('/volume1/Share', '', $normalized); - $normalized = str_replace('/nas', '', $normalized); - $normalized = str_replace('/mnt/smb/share', '', $normalized); - $normalized = str_replace('/mnt/sshfs/share', '', $normalized); - $normalized = 'c' . $normalized; - return '/mnt/smb/share/Videos/Transcoded/' . sha1($normalized) . '.' . $destext; - -} - -function transcodeOneVideo() -{ - return; - if (getState('night') == '1' || getState('device_avion_awake') == '0') { - return; - } - - $list = getVideosList(true); - - foreach ($list as $item) { - - $destext = $item->getExtension(); - if ($destext === 'avi') { - $destext = 'mkv'; - } - - - /** @var SplFileInfo $item */ - $path = $item->getRealPath(); - $to = getTranscodedPath($item); - $oldto = preg_replace('/\.' . $item->getExtension() . '$/', '.x264.' . $destext, $path); - - if (file_exists($oldto)) { - if (!file_exists($to) || filesize($oldto) > filesize($to)) { - rename($oldto, $to); - } - continue; - } - - if (file_exists($to) && filesize($to) != 0 && videosHaveSameDuration($path, $to)) { - continue; - } else { - echo $to . '/exists :' . file_exists($to) . '/size:' . filesize($to) . "\n\n"; - } - - set_time_limit(120); - ignore_user_abort(true); - - if (!getNightMode()) { - wakeupPC('avion'); - sleep(15); - } - - $resize = getVideoHeight($path) > 1080 ? ' 1' : ' 0'; - $cmd = 'C:\Scripts\convertvideo.bat "' . nasToAvion($item) . '" "' . nasToAvion($to) . '" ' . $destext . ' ' . getVideoCodec($path) . $resize; - return; - } - echo 'no file to transcode'; -} - -function videosHaveSameDuration($v1, $v2, $tolerance = 10) -{ - $d1 = getVideoDuration($v1); - $d2 = getVideoDuration($v2); - $diff = abs($d1 - $d2); - $res = $diff < $tolerance; - echo $v1 . '/' . $v2 . '/' . $d1 . '/' . $d2 . '/' . $diff . '/' . $res . "\n"; - return $res; -} - -function nasToAvion($path) -{ - $path = str_replace('/volume1/Share/', 'Z:/', $path); - $path = str_replace('/nas/', 'Z:/', $path); - $path = str_replace('/mnt/sshfs/tortuga/Share/', 'Z:/', $path); - $path = str_replace('/mnt/nfs/share/', 'Z:/', $path); - $path = str_replace('/mnt/smb/share/', 'Z:/', $path); - $path = str_replace('/', '\\', $path); - return $path; -} - -class DirFilter extends RecursiveFilterIterator -{ - protected $exclude; - - public function __construct($iterator, array $exclude) - { - parent::__construct($iterator); - $this->exclude = $exclude; - } - - public function accept() - { - return !($this->isDir() && in_array($this->getFilename(), $this->exclude)); - } - - public function getChildren() - { - return new DirFilter($this->getInnerIterator()->getChildren(), $this->exclude); - } -} - -function getVideosList($shuffle = false) -{ - global $videoExt; - $res = array(); - $dirit = new RecursiveDirectoryIterator('/nas/Videos'); - $filtered = new DirFilter($dirit, ['@eaDir']); - $iterator = new RecursiveIteratorIterator($filtered, RecursiveIteratorIterator::CHILD_FIRST); - - $toTranscode = ['hevc', 'vc1', 'xvid']; - $extToTranscode = ['avi']; - - foreach ($iterator as $f) { - /** @var $f SplFileInfo */ - if (!$f->isFile()) { - continue; - } - if (stristr($f->getPath(), 'Transcoded')) { - continue; - } - if (!in_array($f->getExtension(), $videoExt)) { - continue; - } - $path = $f->getRealPath(); - - $codec = getVideoCodec($path); - - if (!in_array($codec, $toTranscode) && !in_array($f->getExtension(), $extToTranscode)) { - continue; - } - if (preg_match('/[\&\[\]\|]/', $f->getFilename(), $matches)) { - continue; - } - $res[] = $f; - } - if ($shuffle) { - shuffle($res); - } - return $res; -} - -function getVideoCodec($path) -{ - $cacheKey = 'codec_3_' . md5($path . '-' . filemtime($path) . '-' . filesize($path)); - $res = getState($cacheKey, null); - if (null === $res) { - $codecfile = $path . '.vc'; - if (file_exists($codecfile) && filesize($codecfile) > 0) { - $res = file_get_contents($codecfile); - unlink($codecfile); - } else if (stristr($path, '.x264.')) { - $res = 'h264'; - } else { - $res = `ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$path"`; - $res = trim($res); - } - echo $path . '::' . $res . "\n"; - setState($cacheKey, $res); - } - return $res; -} - -function getVideoDuration($path) -{ - $cacheKey = 'duration_4_' . md5($path . '-' . filemtime($path) . '-' . filesize($path)); - $res = getState($cacheKey, null); - if (null === $res) { - $res = `ffprobe -i "$path" -show_entries format=duration -v quiet -of csv="p=0"`; - setState($cacheKey, $res); - } - return (float)$res; -} - -function getVideoHeight($path) -{ - $cacheKey = 'height_2_' . md5($path . '-' . filemtime($path)); - $res = getState($cacheKey, null); - if (null === $res) { - $res = `ffprobe -v error -select_streams v:0 -show_entries stream=height -of default=nw=1:nk=1 $path`; - $res = trim($res); - setState($cacheKey, $res); - } - return (int)$res; -} \ No newline at end of file diff --git a/scripts/lib/netgearwifiext.php b/scripts/lib/netgearwifiext.php deleted file mode 100644 index 85e685a..0000000 --- a/scripts/lib/netgearwifiext.php +++ /dev/null @@ -1,34 +0,0 @@ -post('http://192.168.13.84/ajax/weblogin', ['form_params' => [ - 'email_auth' => 'vincent@enhydra.fr', - 'passwd_auth' => 'HXXzYlphGy!xLe3k', - 'remember_func' => 'Remember+Me', - 'login_ng' => 'ng-hide', - 'next_file' => 'index.htm', - 'support_cookie' => '0', - 'ajax' => '0' - ]]); - } - return $netgearWifiExtHttpClient; -} - -function netgearWifiExtReboot() -{ - - $client = getNetgearWifiExtHttpClient(); - $resp = $client->request('get', 'http://192.168.13.84/BAK_restart.htm'); - preg_match('|backup\.cgi\?id=\d+|', $resp->getBody(), $matches); - $url = '/' . $matches[0]; - - $client->post($url, ['form_params' => [ - 'ROMRestart' => 'Oui', - ]]); - - $client->get('http://192.168.13.84/logout.htm'); -} \ No newline at end of file diff --git a/scripts/lib/remoteinfos.php b/scripts/lib/remoteinfos.php deleted file mode 100644 index c4041b7..0000000 --- a/scripts/lib/remoteinfos.php +++ /dev/null @@ -1,135 +0,0 @@ - 'shield', 'can_seek' => false]; - } else { - if (($p === 'netflix' || $p === 'tv' || $p === 'amazonprime') && config('TVPLAYER') === 'shield') { - $res = ['type' => 'shield', 'can_seek' => false]; - } else { - if ($p === 'shieldmedia') { - $res = ['type' => 'shieldmedia', 'can_seek' => false]; - - } else { - $res = ['type' => $p, 'can_seek' => false]; - } - } - } - } - $res['playing'] = $playing; - $res['device'] = config('DEVICE'); - if ($res['type'] === 'mycanal') { - $res['type'] = 'shield'; - } - $json = json_encode($res); - - $cacheName = 'remote_infos_' . config('DEVICE'); - - if (null !== $res) { - setState($cacheName, $json); - return $json; - } - - return getState($cacheName); -} - -function remoteProgress($progress) -{ - if (config('TVPLAYER') === 'shield') { - return; - } - - $playing = getPlaying(); - $e = explode(':', $playing); - $p = $e[0]; - if ($p == 'squeezebox') { - return squeezeboxRemoteProgress($progress); - } -} - -function getTitleAndArtwork($source) -{ - global $directories; - $cachekey = 'title_artwork_' . sha1($source); - $cache = getState($cachekey, null); - if (null !== $cache) { - return json_decode($cache, true); - } - - $res = ['title' => '', 'artwork' => '']; - $file = str_replace(NAS_ROOT, '/volume1/Share/', $source); - $file = str_replace(NAS_PWD_ROOT, '/volume1/Share/', $file); - $file = str_replace('/nas/', '/volume1/Share/', $file); - $res['title'] = $file; - - if (file_exists($file . '.tmdb.id')) { - $id = file_get_contents($file . '.tmdb.id'); - if (intval($id) > 0) { - $library = new moviesLibrary($directories); - $movie = $library->getMovieByID($id); - $res['title'] = $movie['title']; - $res['artwork'] = cacheMedia('https://image.tmdb.org/t/p/w500' . $movie['backdrop_path']); - } - } else { - $f = new SplFileInfo($file); - preg_match('|S(\d{2})/S\d{2}E(\d{2})|', $f, $matches); - $tvid = $f->getPath() . '/../.tmdb.id'; - - if (file_exists($tvid)) { - $id = file_get_contents($tvid); - if (intval($id)) { - $library = new tvShowLibrary($directories); - $tvshow = $library->getTVShowById($id); - $res['title'] = $tvshow['name']; - if (count($matches) > 0) { - $res['title'] .= '
S' . $matches[1] . ' E' . $matches[2]; - } - $res['artwork'] = cacheMedia('https://image.tmdb.org/t/p/w500' . $tvshow['backdrop_path']); - } - } - } - setState($cachekey, json_encode($res)); - return $res; - -} - -function squeezeboxRemoteInfos() -{ - $status = _squeezeRequest('status - 0 tags:galdcK')['result']; - $remoteMeta = $status['remoteMeta']; - $res['type'] = 'squeezebox'; - $res['time'] = $status['time']; - if (isset($status['duration'])) { - $res['duration'] = $status['duration']; - } - $res['can_seek'] = isset($status['can_seek']); - $res['title'] = $remoteMeta['title']; - $res['artwork'] = cacheMedia($remoteMeta['artwork_url']); - return $res; -} - -function squeezeboxRemoteProgress($progress) -{ - $infos = squeezeboxRemoteInfos(); - if ($infos['can_seek']) { - $infos['time'] = $infos['duration'] * $progress; - squeezeRequest('time ' . round($infos['time'])); - } - return $infos; -} diff --git a/scripts/lib/scenes.php b/scripts/lib/scenes.php index 117b8c5..5654805 100644 --- a/scripts/lib/scenes.php +++ b/scripts/lib/scenes.php @@ -37,19 +37,6 @@ $scenes = [ ['type' => 'scene', 'scene' => 'chambre/auto', 'delay' => 35], ['type' => 'scene', 'scene' => 'cuisine/coffee/on'], ], - 'chambre/deshumidificateur/on' => [ - ], - 'chambre/deshumidificateur/off' => [ - - ], - 'chambre/fan/on' => [ - - ], - 'chambre/fan/off' => [ - - ], - 'chambre/fan/toggle' => [ - ], 'chambre/auto' => [ ['type' => 'nightmode', 'mode' => '0'], ['type' => 'function', 'function' => 'chambreAuto', 'args' => [true]], @@ -210,7 +197,6 @@ $scenes = [ 'chambre/off' => [ ['type' => 'scene', 'scene' => 'chambre/off/exceptcheminee'], ['type' => 'scene', 'scene' => 'chambre/cheminee/off'], - ['type' => 'scene', 'scene' => 'chambre/fan/off'], ], 'chambre/off/exceptcheminee' => [ ['type' => 'state', 'key' => 'chambre', 'value' => 0], @@ -331,7 +317,6 @@ $scenes = [ //['type' => 'insteon', 'command' => '0?133=I=0=0'], ['type' => 'function', 'function' => 'chemineeOff', 'args' => ['salon']], ['type' => 'hue', 'group' => $salon, 'scene' => array('on' => false)], - ['type' => 'scene', 'scene' => 'salon/fan/off'], ['type' => 'scene', 'scene' => 'salon/bar/off'], ], 'salon/cinemabase' => [ @@ -417,15 +402,6 @@ $scenes = [ 'bureau/screens/on' => [ ['type' => 'function', 'function' => 'pcScreensProfile', 'args' => ['Tortuga', 'avion']] ], - 'bureau/fan/on' => [ - - ], - 'bureau/fan/off' => [ - - ], - 'bureau/fan/toggle' => [ - ['type' => 'ha', 'device' => 'script.klarstein_fan_toggle'], - ], 'bureau/auto' => [ ['type' => 'function', 'function' => 'bureauAuto', 'args' => [true]], ], diff --git a/scripts/netgearwifiext.php b/scripts/netgearwifiext.php deleted file mode 100644 index 7d70f63..0000000 --- a/scripts/netgearwifiext.php +++ /dev/null @@ -1,3 +0,0 @@ -del($key); require_once "cron/cron.php"; - cronMediaLibrary(0); file_get_contents('https://' . getCurrentConfig() . '.home.tortuga.enhydra.fr'); } echo connectRedis()->igbget($key); \ No newline at end of file diff --git a/scripts/share.php b/scripts/share.php deleted file mode 100644 index ca29e8c..0000000 --- a/scripts/share.php +++ /dev/null @@ -1,39 +0,0 @@ - .info.lock .icon { margin-bottom: 20px; text-align: center; } -.bricks { - height: 100%; - width: 100%; - position: absolute; - top: 0; - left: 0; -} -.bricks .brick { - overflow: hidden; - position: absolute; -} -.bricks .brick .c { - background-color: rgba(255, 255, 255, 0.35); - text-align: center; - border-radius: 5px; - width: 100%; - height: 100%; -} -.bricks .brick .c a { - color: #000; - text-decoration: none; -} -.bricks .brick .c a.fullbrickbutton { - display: block; - width: 100%; - height: 100%; - border-radius: 5px; - position: relative; -} -.bricks .brick .c.arrow { - background-color: rgba(0, 0, 0, 0.35); -} -.bricks .brick .c.arrow .fullbrickbutton { - color: #fff; -} -.bricks .brick .c .hspacer { - display: inline-block; -} -.bricks .brick .c .remote-touch { - width: 100%; - height: 100%; - font-family: Font Awesome\ 5 Pro; - font-size: 3em; - opacity: 0.2; - padding-top: 0.1em; -} -.bricks .brick .c .remote-infos { - width: 100%; - height: 100%; - overflow: hidden; -} -.bricks .brick .c .remote-infos .h { - width: 100%; - height: 100%; - background-position: 50% 50%; - background-size: cover; - background-repeat: no-repeat; - position: relative; -} -.bricks .brick .c .remote-infos .h .title { - position: absolute; - bottom: 10%; - width: 100%; - text-align: center; - font-size: 0.5em; - line-height: 1; - color: #000; - z-index: 1; - text-shadow: #fff 0px 1px 2px, #fff 1px 0px 2px, #fff -1px 0px 2px, #fff 0px -1px 2px; -} -.bricks .brick .c .remote-timeline .timeline-time { - display: inline-block; - font-size: 0.5em; - vertical-align: middle; - width: 16%; - text-align: center; -} -.bricks .brick .c .remote-timeline .timeline-duration { - display: inline-block; - font-size: 0.5em; - vertical-align: middle; - width: 16%; - text-align: center; -} -.bricks .brick .c .remote-timeline .timeline-progressbar { - display: inline-block; - vertical-align: middle; - width: 68%; - background-color: #000; - height: 0.25em; - border-radius: 0.1em; - position: relative; -} -.bricks .brick .c .remote-timeline .timeline-cursor { - position: absolute; - top: -50%; - background: #222; - width: 0.5em; - height: 0.5em; - border-radius: 50%; - margin-left: -0.25em; - pointer-events: none; -} diff --git a/style/style.less b/style/style.less index c49b5fe..50c0184 100644 --- a/style/style.less +++ b/style/style.less @@ -450,6 +450,4 @@ section .col > .info.lock { } } -@import "menu"; - -@import "remote"; \ No newline at end of file +@import "menu"; \ No newline at end of file