]> _ Git - tortuga-home.git/commitdiff
.
authorVincent <vincent@enhydra.fr>
Fri, 23 Aug 2019 07:39:39 +0000 (09:39 +0200)
committerVincent <vincent@enhydra.fr>
Fri, 23 Aug 2019 07:39:39 +0000 (09:39 +0200)
.idea/workspace.xml
scripts/lib/lib.php
scripts/lib/medialibrary.php
scripts/lib/remoteinfos.php
scripts/lib/squeezebox.php
servers/squeezebox.php [new file with mode: 0644]

index 4d3191c083a27220bb8c869e9fb2feb32259c9d4..48690fb1abf21c742bfc73e59c51e72bd5b696b8 100644 (file)
@@ -2,9 +2,12 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
+      <change afterPath="$PROJECT_DIR$/servers/squeezebox.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/lib.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/lib.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/scripts/lib/medialibrary.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/medialibrary.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/servers/domoticz.php" beforeDir="false" afterPath="$PROJECT_DIR$/servers/domoticz.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/remoteinfos.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/remoteinfos.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/squeezebox.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/squeezebox.php" afterDir="false" />
     </list>
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
     <option name="SHOW_DIALOG" value="false" />
       <workItem from="1566371220982" duration="598000" />
       <workItem from="1566376145799" duration="4963000" />
       <workItem from="1566402117063" duration="1534000" />
-      <workItem from="1566458804773" duration="1632000" />
-    </task>
-    <task id="LOCAL-00159" summary=".">
-      <created>1551017579585</created>
-      <option name="number" value="00159" />
-      <option name="presentableId" value="LOCAL-00159" />
-      <option name="project" value="LOCAL" />
-      <updated>1551017579586</updated>
+      <workItem from="1566458804773" duration="5114000" />
     </task>
     <task id="LOCAL-00160" summary=".">
       <created>1551079784438</created>
       <option name="project" value="LOCAL" />
       <updated>1566458823293</updated>
     </task>
-    <option name="localTasksCounter" value="208" />
+    <task id="LOCAL-00208" summary=".">
+      <created>1566499257720</created>
+      <option name="number" value="00208" />
+      <option name="presentableId" value="LOCAL-00208" />
+      <option name="project" value="LOCAL" />
+      <updated>1566499257720</updated>
+    </task>
+    <option name="localTasksCounter" value="209" />
     <servers />
   </component>
   <component name="TodoView">
index e58cc6ac12f72187487aa558d18cde77aa1306d8..8aeacf9d6c03f3ed533fb60a83f9967e731714e6 100644 (file)
@@ -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 .= '<span>' . $langtoemoji[$item] . '</span>';
+//        }
+//    }
+
 
     if (isset($s['poster'])) {
         if (!isset($attrs['class'])) {
@@ -336,7 +345,7 @@ function shortcut($s, $hash)
         if (!isset($s['label'])) {
             $s['label'] = '';
         }
-        $res .= '><span>' . $s['label'] . '</span></' . $markup . '>';
+        $res .= '><span>' . $s['label'] . '</span><div class="sw-corner">' . $swcorner . '</div></' . $markup . '>';
     }
     return $res;
 }
index 6ae23fe2aa11959ccb0dbda297ec0137590fb470..ab2193eeb95701f616dbc727e8f18e281af2c5bb 100644 (file)
@@ -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);
index a63dd9e89b169bd6af30c8bd6dc3db27835702bb..7bf02a88be493f02339eb2824d2cd7f7ec818a4d 100644 (file)
@@ -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'];
index b20b94e285335fb7c92b1a9d21a9bc61d6c77b3b..ede5f50fcc3b12d64200880ae3c5c2753bb877b6 100644 (file)
@@ -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 (file)
index 0000000..b314280
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/php
+
+<?php
+require_once __DIR__ . "/../scripts/import.php";
+
+// Set time limit to indefinite execution
+set_time_limit(0);
+ignore_user_abort(true);
+
+echo 'Run home server squeezebox' . "\n";
+
+$redis = connectRedis();
+redisEventListener('squeezebox_event', 'handleSqueezeboxQueue');
+
+function handleSqueezeboxQueue()
+{
+    global $redis;
+
+    while (true) {
+        $q = 'squeezebox_queue';
+        $queue = $redis->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