From: Vincent Date: Fri, 23 Aug 2019 07:39:39 +0000 (+0200) Subject: . X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=04b503b7c6ec2407868b536c7fc9d8d0ed3d7da3;p=tortuga-home.git . --- diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 4d3191c..48690fb 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,12 @@ + + - + + diff --git a/scripts/lib/lib.php b/scripts/lib/lib.php index e58cc6a..8aeacf9 100644 --- a/scripts/lib/lib.php +++ b/scripts/lib/lib.php @@ -198,6 +198,8 @@ function shortcut($s, $hash) return; } + $swcorner = ''; + if ($s['type'] == 'task') { $attrs['class'] = 'ajax'; $attrs['href'] = 'scripts/tortugatask.php?task=' . $s['command']; @@ -301,6 +303,13 @@ function shortcut($s, $hash) if (isset($s['seen']) && $s['seen']) { $attrs['data-seen'] = '1'; } +// if (isset($s['srt']) && count($s['srt'])) { +// $langtoemoji = ['fr' => '🇫🇷', 'en' => '🇺🇸']; +// foreach ($s['srt'] as $item) { +// $swcorner .= '' . $langtoemoji[$item] . ''; +// } +// } + if (isset($s['poster'])) { if (!isset($attrs['class'])) { @@ -336,7 +345,7 @@ function shortcut($s, $hash) if (!isset($s['label'])) { $s['label'] = ''; } - $res .= '>' . $s['label'] . ''; + $res .= '>' . $s['label'] . '
' . $swcorner . '
'; } return $res; } diff --git a/scripts/lib/medialibrary.php b/scripts/lib/medialibrary.php index 6ae23fe..ab2193e 100644 --- a/scripts/lib/medialibrary.php +++ b/scripts/lib/medialibrary.php @@ -26,7 +26,7 @@ function getMediaContents($dir, $context, $seen = null) } $normPath = normPath($path); $x264path = getX264Version($normPath); - $results[] = array('path' => $x264path, 'seen' => isset($seen[$x264path]), 'dir' => false, 'name' => mediaName(implode(' ', $e), $context, false, $path)); + $results[] = array('path' => $x264path, 'srt' => hasSRT($normPath), 'seen' => isset($seen[$x264path]), 'dir' => false, 'name' => mediaName(implode(' ', $e), $context, false, $path)); } } else if ($value != "." && $value != ".." && $value != '@eaDir') { $files = getMediaContents($path, $context, $seen); @@ -50,6 +50,23 @@ function getMediaContents($dir, $context, $seen = null) return $results; } +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) { $e = explode('.', $path); diff --git a/scripts/lib/remoteinfos.php b/scripts/lib/remoteinfos.php index a63dd9e..7bf02a8 100644 --- a/scripts/lib/remoteinfos.php +++ b/scripts/lib/remoteinfos.php @@ -119,7 +119,7 @@ function mediaraspRemoteInfos() function squeezeboxRemoteInfos() { - $status = squeezeRequest('status - 0 tags:galdcK')['result']; + $status = _squeezeRequest('status - 0 tags:galdcK')['result']; $remoteMeta = $status['remoteMeta']; $res['type'] = 'squeezebox'; $res['time'] = $status['time']; diff --git a/scripts/lib/squeezebox.php b/scripts/lib/squeezebox.php index b20b94e..ede5f50 100644 --- a/scripts/lib/squeezebox.php +++ b/scripts/lib/squeezebox.php @@ -10,7 +10,6 @@ function stopSqueezeboxPlayer($player, $stopIfSync = true) squeezeRequest('sync -', $player); squeezeRequest('stop', $player); squeezeRequest('power 0', $player); - } function stopAllSqueezebox() @@ -30,7 +29,22 @@ function stopSqueezebox($player) } } -function squeezeRequest($params, $player = '') +function squeezeRequest($params, $player) +{ + $redis = connectRedis(); + $queue_name = 'squeezebox_queue'; + + $queue = $redis->get($queue_name); + if (!is_array($queue)) { + $queue = []; + } + array_push($queue, [$params, $player]); + + $redis->igbset($queue_name, $queue); + $redis->publish('squeezebox_event', 'handle_queue'); +} + +function _squeezeRequest($params, $player = '') { global $rpcid; if (!isAlive('cuisine')) { @@ -145,7 +159,7 @@ function getSqueezeFavorites($root = 0, $app = 'favorites', $level = 0) $params[] = 'item_id:' . $root; } - $r = squeezeRequest($params, $squeezeboxPlayers['Salon']); + $r = _squeezeRequest($params, $squeezeboxPlayers['Salon']); if (isset($r['result']) && isset($r['result']['loop_loop'])) { $loop = $r['result']['loop_loop']; @@ -208,8 +222,6 @@ function checkSpottyLogin() $accounts = [ SQUEEZEBOX_SPOTIFY_USERNAME => SQUEEZEBOX_SPOTIFY_PASSWORD, - 'jrme75009' => 'tortuga5009', - 'v12l' => 'Lr8ka&7cs@fc%lW7' ]; foreach ($accounts as $user => $password) { diff --git a/servers/squeezebox.php b/servers/squeezebox.php new file mode 100644 index 0000000..b314280 --- /dev/null +++ b/servers/squeezebox.php @@ -0,0 +1,36 @@ +#!/usr/bin/php + +igbget($q); + if (!is_array($queue)) { + $queue = []; + $redis->igbset($q, $queue); + } + if (!count($queue)) { + echo 'End processing queue' . "\n"; + break; + } + + $command = array_shift($queue); + $redis->igbset($q, $queue); + echo 'Run command ' . json_encode($command) . "\n"; + _squeezeRequest($command[0], $command[1]); + } +} \ No newline at end of file