]> _ Git - tortuga-home.git/commitdiff
.
authorVincent <vincent@enhydra.fr>
Tue, 17 Nov 2020 11:49:41 +0000 (12:49 +0100)
committerVincent <vincent@enhydra.fr>
Tue, 17 Nov 2020 11:49:41 +0000 (12:49 +0100)
.idea/workspace.xml
config/remote.php
scripts/lib/harmony.php
scripts/lib/http.php
scripts/lib/remoteinfos.php
scripts/lib/scenes.php
scripts/lib/shield.php
scripts/shield.php

index 68a3f8147d1ad7b9bfbd5c84fec20aedaa41e1a6..1ce493009a274f340e7b8654df231dfc789303ae 100644 (file)
@@ -3,6 +3,13 @@
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/config/remote.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/remote.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/harmony.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/harmony.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/http.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/http.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/scenes.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/scenes.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/shield.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/shield.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/shield.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/shield.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
         <option name="Make" enabled="true" />
       </method>
     </configuration>
+    <configuration default="true" type="ArquillianJUnit" factoryName="" nameIsGenerated="true">
+      <option name="arquillianRunConfiguration">
+        <value>
+          <option name="containerStateName" value="" />
+        </value>
+      </option>
+      <option name="TEST_OBJECT" value="class" />
+      <method v="2">
+        <option name="Make" enabled="true" />
+      </method>
+    </configuration>
     <configuration default="true" type="ArquillianTestNG" factoryName="">
       <option name="arquillianRunConfiguration">
         <value>
       <workItem from="1605261347643" duration="1199000" />
       <workItem from="1605342171398" duration="4613000" />
       <workItem from="1605355486465" duration="23396000" />
-    </task>
-    <task id="LOCAL-00353" summary=".">
-      <created>1603626112636</created>
-      <option name="number" value="00353" />
-      <option name="presentableId" value="LOCAL-00353" />
-      <option name="project" value="LOCAL" />
-      <updated>1603626112636</updated>
+      <workItem from="1605531884401" duration="829000" />
+      <workItem from="1605542056704" duration="1640000" />
+      <workItem from="1605597648537" duration="6714000" />
     </task>
     <task id="LOCAL-00354" summary=".">
       <created>1603643895376</created>
       <option name="project" value="LOCAL" />
       <updated>1605517718088</updated>
     </task>
-    <option name="localTasksCounter" value="402" />
+    <task id="LOCAL-00402" summary=".">
+      <created>1605532129605</created>
+      <option name="number" value="00402" />
+      <option name="presentableId" value="LOCAL-00402" />
+      <option name="project" value="LOCAL" />
+      <updated>1605532129605</updated>
+    </task>
+    <option name="localTasksCounter" value="403" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
     </state>
     <state x="740" y="229" key="#com.jetbrains.php.refactoring.extractMethod.PhpExtractMethodDialog#function0/0.0.1707.920@0.0.1707.920" timestamp="1604146905948" />
     <state x="1110" y="259" key="#com.jetbrains.php.refactoring.extractMethod.PhpExtractMethodDialog#function0/0.0.2560.1040@0.0.2560.1040" timestamp="1605437484620" />
-    <state x="198" y="0" width="737" height="502" key="CommitChangelistDialog2" timestamp="1605517703034">
+    <state x="198" y="0" width="737" height="502" key="CommitChangelistDialog2" timestamp="1605532120874">
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
     <state x="132" y="0" width="737" height="502" key="CommitChangelistDialog2/0.0.1707.920@0.0.1707.920" timestamp="1605086955514" />
     <state x="701" y="75" key="CommitChangelistDialog2/0.0.1920.1160@0.0.1920.1160" timestamp="1605188136787" />
-    <state x="198" y="0" width="745" height="567" key="CommitChangelistDialog2/0.0.2560.1040@0.0.2560.1040" timestamp="1605517703034" />
+    <state x="198" y="0" width="745" height="567" key="CommitChangelistDialog2/0.0.2560.1040@0.0.2560.1040" timestamp="1605532120874" />
     <state x="952" y="244" key="FileChooserDialogImpl" timestamp="1605104496549">
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
     <state x="295" y="0" width="1290" height="907" key="dock-window-1/0.0.2560.1040@0.0.2560.1040" timestamp="1603274697406" />
-    <state x="977" y="257" width="607" height="536" key="find.popup" timestamp="1605437373935">
+    <state x="977" y="257" width="607" height="536" key="find.popup" timestamp="1605598576899">
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
     <state x="651" y="227" width="550" height="534" key="find.popup/0.0.1707.920@0.0.1707.920" timestamp="1604301949692" />
-    <state x="977" y="257" width="607" height="536" key="find.popup/0.0.2560.1040@0.0.2560.1040" timestamp="1605437373935" />
+    <state x="977" y="257" width="607" height="536" key="find.popup/0.0.2560.1040@0.0.2560.1040" timestamp="1605598576899" />
     <state x="1056" y="292" key="refactoring.ChangeSignatureDialog" timestamp="1604518096294">
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
index 173414a36f413c5a5e9a5ce2a41b138ef8d748a3..c9a33ac3397b65f3985d6f41d147153d655c7210 100644 (file)
@@ -37,21 +37,16 @@ $bricksShield = ['type' => 'shield', 'width' => 4, 'height' => 4, 'bricks' => [
     ['type' => 'remote-shield-ok', 'width' => 1, 'height' => 1, 'top' => 2, 'left' => 2],
 ]];
 
-$bricksShieldMedia = ['type' => 'shieldmedia', 'width' => 5, 'height' => 4, 'bricks' => [
+$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' => 3, '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' => 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-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],
+    ['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],
 ]];
 
 
index 83df419907b6c3ad43cda1cfead545c50e6db8dd..6dfe74afb7b688ebceb1b17fa80f097ca9001ee6 100644 (file)
@@ -37,7 +37,7 @@ function harmonyActivity($activity)
     $current = getCurrentHarmonyActivity();
     if ($current == 'off' || $current == 'poweroff' || !$current) {
         if ($activity == 'media' || $activity == 'shield' || $activity == 'tv') {
-            $wait = 30;
+            $wait = 10;
         }
     }
     if ($activity !== 'off' && $activity !== 'poweroff') {
index adec6f4abfaf8f4b13810761cb01f0fb732d4898..cd99e87101008d112bdd397f31211514315023f1 100644 (file)
@@ -31,12 +31,14 @@ function getHttpClient($newclient = false)
 /**
  * @param $url
  * @param string $method
- * @param string $data
+ * @param array $data
  * @param null $auth
+ * @param int $timeout
+ * @param bool $allowRedirections
+ * @param array $headers
  * @return mixed|\Psr\Http\Message\ResponseInterface
- * @throws \GuzzleHttp\Exception\GuzzleException
  */
-function httpRequest($url, $method = 'get', $data = [], $auth = null, $timeout = 10, $allowRedirections = true)
+function httpRequest($url, $method = 'get', $data = [], $auth = null, $timeout = 10, $allowRedirections = true, $headers = [])
 {
     $method = mb_strtoupper($method);
     $client = getHttpClient();
@@ -47,8 +49,13 @@ function httpRequest($url, $method = 'get', $data = [], $auth = null, $timeout =
     if ($method == 'GET') {
         $options['query'] = $data;
     } else {
-        $options['form_params'] = $data;
+        if (is_string($data)) {
+            $options['body'] = $data;
+        } else {
+            $options['form_params'] = $data;
+        }
     }
+    $options['headers'] = $headers;
 
     return $client->request($method, $url, $options);
 }
\ No newline at end of file
index da2874e5dfcc91b9e745e690a9ef767f811de021..cb64b91049324cae4fb543cf794743aa8f02ff75 100644 (file)
@@ -7,17 +7,41 @@ function remoteInfos()
     if ($p == 'squeezebox') {
         $res = squeezeboxRemoteInfos();
     } else {
-        if (($p === 'netflix' || $p === 'tv') && config('TVPLAYER') === 'shield') {
-            $res = ['type' => 'shield', 'can_seek' => false];
+        if (config('TVPLAYER') === 'shield') {
+            if (shieldGetCurrentApp() === 'kodi') {
+                $res = ['type' => 'shieldmedia', 'can_seek' => true];
+                $p = json_decode(httpRequest('http://' . getDevice()['shield'] . ':8754/jsonrpc?Base=1', 'post', '[{"jsonrpc":"2.0","method":"Player.GetProperties","params":[1,["playlistid","speed","position","totaltime","time","percentage","shuffled","repeat","canrepeat","canshuffle","canseek","partymode"]],"id":1},{"jsonrpc":"2.0","method":"Player.GetItem","params":[1,["title","thumbnail","file","artist","genre","year","rating","album","track","duration","playcount","dateadded","episode","artistid","albumid","tvshowid","fanart"]],"id":2}]', ['kodi', 'atacama'], 10, true, ['X-Requested-With' => 'XMLHttpRequest', 'Content-type' => 'application/json'])->getBody(), true);
+                $res['duration'] = '';
+                $res['time'] = '';
+                $res['title'] = '';
+                $res['artwork'] = '';
+                $res['status'] = '';
+                if (isset($p[0]['result'])) {
+                    $r = $p[0]['result'];
+                    $res['can_seek'] = $r['canseek'];
+                    $res['duration'] = 3600 * $r['totaltime']['hours'] + 60 * $r['totaltime']['minutes'] + $r['totaltime']['seconds'];
+                    $res['time'] = 3600 * $r['time']['hours'] + 60 * $r['time']['minutes'] + $r['time']['seconds'];
+                }
+                if (isset($p[1]['result']['item']['file'])) {
+                    $res = array_merge($res, getTitleAndArtwork($p[1]['result']['item']['file']));
+                }
+            } else {
+                $res = ['type' => 'shield', 'can_seek' => false];
+            }
+
         } else {
-            if ($p == 'mediarasp') {
-                if (config('VIDEOPLAYER') === 'shield') {
-                    $res = ['type' => 'shieldmedia', 'can_seek' => false];
+            if (($p === 'netflix' || $p === 'tv') && config('TVPLAYER') === 'shield') {
+                $res = ['type' => 'shield', 'can_seek' => false];
+            } else {
+                if ($p == 'mediarasp' || $p === 'shieldmedia') {
+                    if (config('VIDEOPLAYER') === 'shield') {
+                        $res = ['type' => 'shieldmedia', 'can_seek' => false];
+                    } else {
+                        $res = mediaraspRemoteInfos();
+                    }
                 } else {
-                    $res = mediaraspRemoteInfos();
+                    $res = ['type' => $p, 'can_seek' => false];
                 }
-            } else {
-                $res = ['type' => $p, 'can_seek' => false];
             }
         }
     }
@@ -87,36 +111,53 @@ function mediaraspRemoteInfos()
         $res['title'] = $meta['title'];
         $res['artwork'] = $meta['thumbnail'];
     } else {
-        $file = str_replace('/nas', '/volume1/Share', $source);
-        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'] .= '<br>S' . $matches[1] . ' E' . $matches[2];
-                    }
-                    $res['artwork'] = cacheMedia('https://image.tmdb.org/t/p/w500' . $tvshow['backdrop_path']);
+        $res = array_merge($res, getTitleAndArtwork($source));
+    }
+
+    return $res;
+}
+
+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('smb://Share:dcfyjbcyckwydtgufjx@192.168.13.4/Share/', '/volume1/Share', $source);
+    $file = str_replace('/nas', '/volume1/Share', $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'] .= '<br>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()
index 2c5060c4af5e08b4db038b93f9fd44bd260d6564..e7c95e4f8f611f0a3ef70d1097c1d9709677b725 100644 (file)
@@ -498,8 +498,6 @@ $scenes = [
         ['type' => 'ir', 'room' => 'bureausun', 'device' => 'Projector', 'command' => 'PowerOn'],
     ],
     'bureau/media/stop' => [
-        /*    domoticzSwitch(1, false);
-      irsend('bureau', 'Projector', 'PowerOff');*/
         ['type' => 'scene', 'scene' => 'bureau/screen/up'],
         ['type' => 'scene', 'scene' => 'bureau/rideaux/open'],
         ['type' => 'scene', 'scene' => 'bureau/auto'],
index f8496b28506ac1a895c56d620414c68b5a2780a9..3686fdcee1ed31d64001c093b5d4f9dae1b14fe0 100644 (file)
@@ -73,7 +73,7 @@ function shieldKey($keys, $device = null)
         'back' => 'KEYCODE_BACK',
         'home' => 'KEYCODE_HOME',
         'pause' => 'KEYCODE_MEDIA_PLAY_PAUSE',
-        'stop' => 'KEYCODE_MEDIA_STOP',
+        'stop' => 'KEYCODE_HOME',
         'space' => 'KEYCODE_SPACE',
         'rewind' => 'KEYCODE_MEDIA_REWIND',
         'fast-rewind' => 'KEYCODE_MEDIA_REWIND',
@@ -285,12 +285,23 @@ function shieldIsAwake($device = null)
     return strpos($out, 'Display Power: state=ON') !== false;
 }
 
+function shieldGetCurrentApp($device = null)
+{
+    $out = shieldCommand('shell', 'dumpsys window windows | grep -E \'mCurrentFocus|mFocusedApp|mResumedActivity\'');
+    foreach (shieldGetApps() as $name => $id) {
+        if (strpos($out, $id) !== false) {
+            return $name;
+        }
+    }
+    return null;
+}
+
 
 function _adb($command, $params = '', $device = null)
 {
     $c = _adbcmd($command, $params, $device);
     $output = `$c`;
-    echo $c . ' :: ' . $output . "\n";
+    // echo $c . ' :: ' . $output . "\n";
     return $output;
 }
 
index a9b52c9f44929b716f13e0db736e5e8d99875854..c33f62488c62e1f811c555d40b863f5bcd19e6e4 100644 (file)
@@ -12,6 +12,8 @@ if (isset($_GET['key'])) {
 } else if (isset($_GET['action'])) {
     if ($_GET['action'] == 'apps') {
         shieldListApps();
+    } else if ($_GET['action'] == 'currentApp') {
+        shieldGetCurrentApp();
     }
 } else if (isset($_GET['intents'])) {
     shieldFindIntents($_GET['intents']);