<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/media.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/media.php" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/config/tv.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/tv.php" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/scripts/lib/cachemedia.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/cachemedia.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/config/global.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/global.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/scripts/cron/cron.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/cron/cron.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/medialibrary.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/medialibrary.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/scripts/lib/off.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/off.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/lib/tmdb.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/tmdb.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/scripts/transcode.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/transcode.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="1604042543878" duration="11137000" />
<workItem from="1604152329376" duration="42646000" />
<workItem from="1604347943058" duration="16133000" />
+ <workItem from="1604497757709" duration="6812000" />
</task>
<task id="LOCAL-00323" summary=".">
<created>1591440466804</created>
<screen x="0" y="0" width="1707" height="920" />
</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="198" y="0" width="737" height="502" key="CommitChangelistDialog2" timestamp="1604477469385">
+ <state x="198" y="0" width="737" height="502" key="CommitChangelistDialog2" timestamp="1604521334703">
<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="1604307637401" />
<state x="701" y="75" key="CommitChangelistDialog2/0.0.1920.1160@0.0.1920.1160" timestamp="1602171117745" />
- <state x="198" y="0" width="745" height="567" key="CommitChangelistDialog2/0.0.2560.1040@0.0.2560.1040" timestamp="1604477469385" />
+ <state x="198" y="0" width="745" height="567" key="CommitChangelistDialog2/0.0.2560.1040@0.0.2560.1040" timestamp="1604521334703" />
<state x="635" y="216" key="FileChooserDialogImpl" timestamp="1604227698339">
<screen x="0" y="0" width="1707" height="920" />
</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="1604396363414">
+ <state x="977" y="257" width="607" height="536" key="find.popup" timestamp="1604520524183">
<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="1604396363414" />
+ <state x="977" y="257" width="607" height="536" key="find.popup/0.0.2560.1040@0.0.2560.1040" timestamp="1604520524183" />
+ <state x="1056" y="292" key="refactoring.ChangeSignatureDialog" timestamp="1604518096294">
+ <screen x="0" y="0" width="2560" height="1040" />
+ </state>
+ <state x="1056" y="292" key="refactoring.ChangeSignatureDialog/0.0.2560.1040@0.0.2560.1040" timestamp="1604518096294" />
<state x="512" y="211" key="run.anything.popup" timestamp="1604146410464">
<screen x="0" y="0" width="1707" height="920" />
</state>
'entree' => ['id' => 'entree', 'host' => '192.168.13.64', 'user' => 'pi', 'password' => 'atacama'],
'jarvis' => ['id' => 'jarvis', 'host' => '192.168.13.60', 'user' => 'jarvis', 'password' => 'atacama'],
'chambre' => ['id' => 'chambre', 'host' => '192.168.13.65', 'user' => 'pi', 'password' => 'atacama'],
- 'salon' => ['id' => 'salon', 'host' => '192.168.13.66', 'user' => 'pi', 'password' => 'atacama'],
+ 'salon' => ['id' => 'salon', 'host' => '192.168.13.66', 'shield' => '192.168.13.40', 'user' => 'pi', 'password' => 'atacama'],
'bureau' => ['id' => 'bureau', 'host' => '192.168.13.67', 'user' => 'pi', 'password' => 'atacama'],
'cuisine' => ['id' => 'cuisine', 'host' => '192.168.13.68', 'user' => 'pi', 'password' => 'atacama'],
'bureausun' => ['id' => 'bureausun', 'host' => '192.168.13.70', 'user' => 'pi', 'password' => 'atacama'],
function cronShield($cronmin)
{
- shieldConnect(true);
+ global $devices;
+ foreach ($devices as $device) {
+ if (isset($device['shield'])) {
+ shieldConnect(true, $device['id']);
+ }
+ }
+ `curl 'http://192.168.13.60:9000/plugins/Extensions/settings/plugins/CastBridge/settings/basic.html?playerid=b8%3A27%3Aeb%3Af6%3A1d%3A30' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Accept-Language: fr-FR,en;q=0.5' --compressed -H 'Content-Type: application/x-www-form-urlencoded' -H 'Origin: http://192.168.13.60:9000' -H 'Connection: keep-alive' -H 'Referer: http://192.168.13.60:9000/plugins/Extensions/settings/plugins/CastBridge/settings/basic.html?playerid=b8%3A27%3Aeb%3Af6%3A1d%3A30' -H 'Cookie: Squeezebox-player=b8%3A27%3Aeb%3Af6%3A1d%3A30; Squeezebox-enableHiDPI=1; Squeezebox-expandPlayerControl=true; Squeezebox-expanded-MY_MUSIC=0; Squeezebox-expanded-RADIO=1; Squeezebox-expanded-PLUGIN_MY_APPS_MODULE_NAME=1; Squeezebox-expanded-FAVORITES=1; Squeezebox-expanded-PLUGINS=0; Squeezebox-playersettings=null; Squeezebox-advancedsettings=plugins/CastBridge/settings/basic.html%3F; Squeezebox-expanded-activePlugins=1; Squeezebox-expanded-inactivePlugins=1; Squeezebox-expanded-otherPlugins0=1' -H 'Upgrade-Insecure-Requests: 1' --data-raw 'saveSettings=1&useAJAX=0&page=PLUGIN_CASTBRIDGE&playerid=b8%3A27%3Aeb%3Af6%3A1d%3A30&player=b8%3A27%3Aeb%3Af6%3A1d%3A30&autorun=on&bin=squeeze2cast-armv6hf&opts=&debugs=&log_limit=-1&configfile=castbridge.xml&autosave=on&upnp_socket=%3F&xmlparams=1&prevseldevice=.common.&seldevice=.common.&codecs=aac%2Cogg%2Cops%2Cogf%2Cflc%2Calc%2Cwav%2Caif%2Cpcm%2Cmp3&sample_rate=96000&encode_mode=thru&encode_level=&encode_bitrate=&encode_rate=&encode_size=&server=%3F&enabled=1&remove_timeout=0&volume_on_play=1&media_volume=50&send_metadata=1&send_coverart=1&enabled.79a3f5f078d67e3b25a6b3dedc624e18=1'`;
}
function cronGuest($cronmin)
if ($activity !== 'off' && $activity !== 'poweroff') {
ecoMode('0');
}
+ if ($activity === 'musique' || $activity === 'tv') {
+ shieldWakeup('salon');
+ }
$res = harmonyRequest('activities/' . $activity, 'POST');
if ($wait > 0) {
sleep($wait);
function getMediaContents($dir, $context, $seen = null)
{
- global $videoExt;
+ global $videoExt,$seen;
$files = scandir($dir);
$results = array();
- if (null === $seen) {
- $seen = connectRedis()->igbget('mediaseen');
-
- }
- if (!is_array($seen)) {
- $seen = [];
- }
foreach ($files as $key => $value) {
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
continue;
}
$normPath = normPath($path);
- $x264path = getX264Version($normPath);
- $results[] = array('path' => $x264path, 'srt' => hasSRT($normPath), 'seen' => isset($seen[$x264path]), 'dir' => false, 'name' => mediaName(implode(' ', $e), $context, false, $path));
+ $results[] = array('path' => $normPath, '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);
$results[] = $files[0];
} else {
$normPath = normPath($path);
- $results[] = array('path' => $normPath, 'seen' => isset($seen[$normPath]), 'dir' => true, 'id' => hash('sha256', $path), 'name' => mediaName($value, $context, true, $path), 'items' => $files);
+ $results[] = array('path' => $normPath, 'seen' => seen($normPath), 'dir' => true, 'id' => hash('sha256', $path), 'name' => mediaName($value, $context, true, $path), 'items' => $files);
}
}
}
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'];
return array_unique($res);
}
-function getX264Version($path)
+function getX264Version($path, $forceReturn = false)
{
$e = explode('.', $path);
$ext = array_pop($e);
array_push($e, 'x264');
array_push($e, $ext);
$x264path = implode('.', $e);
- if (file_exists($x264path)) {
+ if ($forceReturn || file_exists($x264path)) {
return $x264path;
}
return $path;
}
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 transcodeOneVideo()
-{
- if (getState('night') == '1') {
- return;
- }
-
- $list = getVideosList(true);
-
- foreach ($list as $item) {
-
- /** @var SplFileInfo $item */
- $path = $item->getRealPath();
- $to = preg_replace('/\.' . $item->getExtension() . '$/', '.x264.' . $item->getExtension(), $path);
-
-
- 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(0);
- 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) . '" ' . $item->getExtension() . ' ' . getVideoCodec($path) . $resize;
- print_r(sshCommand($cmd, 'avion'));
- 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;
-}
+//// /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 transcodeOneVideo()
+//{
+// if (getState('night') == '1') {
+// return;
+// }
+//
+// $list = getVideosList(true);
+//
+// foreach ($list as $item) {
+//
+// /** @var SplFileInfo $item */
+// $path = $item->getRealPath();
+// $to = preg_replace('/\.' . $item->getExtension() . '$/', '.x264.' . $item->getExtension(), $path);
+//
+//
+// 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(0);
+// 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) . '" ' . $item->getExtension() . ' ' . getVideoCodec($path) . $resize;
+// print_r(sshCommand($cmd, 'avion'));
+// 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)
{
}
}
-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'];
-
- foreach ($iterator as $f) {
- /** @var $f SplFileInfo */
- if (!$f->isFile()) {
- continue;
- }
- if (!in_array($f->getExtension(), $videoExt)) {
- continue;
- }
- $path = $f->getRealPath();
-
- $codec = getVideoCodec($path);
-
- if (!in_array($codec, $toTranscode)) {
- 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
+//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'];
+//
+// foreach ($iterator as $f) {
+// /** @var $f SplFileInfo */
+// if (!$f->isFile()) {
+// continue;
+// }
+// if (!in_array($f->getExtension(), $videoExt)) {
+// continue;
+// }
+// $path = $f->getRealPath();
+//
+// $codec = getVideoCodec($path);
+//
+// if (!in_array($codec, $toTranscode)) {
+// 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
function offSalon()
{
stopHarmony();
- execScene('salon/freebox/off');
+ shieldKillAll('salon');
+ shieldSleep('salon');
+ harmonyDeviceCommand('videoprojecteur-epson', 'power-off');
}
function offBureau()
<?php
-define('SHIELD_HOST', '192.168.13.40');
$shieldConnect = false;
-function shieldConnect($force = false)
+function shieldConnect($force = false, $device = null)
{
global $shieldConnect;
- $lastConnect = getState('shield_lastconnect', null);
+ $d = getDevice($device);
+ $stateKey = 'shield_lastconnect_' . $d['id'];
+ $lastConnect = getState($stateKey, null);
$limit = time() - 3600;
if ($force || (!$shieldConnect && ($lastConnect === null || $lastConnect < $limit))) {
$shieldConnect = true;
- _adb('connect', SHIELD_HOST);
- $lastConnect = getState('shield_lastconnect', time());
+ _adb('connect', $d['shield'], $device);
+ setState($stateKey, time());
}
}
+function shieldSleep($device = null)
+{
+ shieldKey('sleep', $device);
+}
+
+function shieldWakeup($device = null)
+{
+ shieldKey('wakeup', $device);
+}
+
function shieldRunActivity($device = null)
{
$device = getDevice($device);
}
}
-function shieldCommand($command, $params)
+function shieldCommand($command, $params, $device = null)
{
- shieldConnect();
- _adb($command, $params);
+ shieldConnect(false, $device);
+ _adb($command, $params, $device);
}
-function shieldText($text)
+function shieldText($text, $device = null)
{
- shieldCommand('shell', 'input text ' . $text);
+ shieldCommand('shell', 'input text ' . $text, $device);
}
function shieldKey($keys, $device = true)
};
$cmds[] = 'input keyevent ' . $key;
}
- shieldCommand('shell', ' "' . implode(' && ', $cmds) . '"');
+ shieldCommand('shell', ' "' . implode(' && ', $cmds) . '"', $device);
}
function shieldNetflix($id = null, $device = null)
{
shieldRunActivity($device);
- shieldHome();
+ shieldHome($device);
sleep(1);
$url = 'http://www.netflix.com/';
setPlaying('netflix', $device);
if ($id === 'home') {
- shieldKill('netflix');
+ shieldKill('netflix', $device);
}
- //_adb('shell am start', ' -c android.intent.category.LEANBACK_LAUNCHER -a android.intent.action.VIEW -f 0x10808000 -e source 30 -d ' . $url . ' com.netflix.ninja/.MainActivity');
- _adb('shell am start', ' -c android.intent.category.LEANBACK_LAUNCHER -a android.intent.action.VIEW -f 0x10808000 -e source 30 -d ' . $url . ' com.netflix.ninja/.MainActivity');
+ shieldCommand('shell am start', ' -c android.intent.category.LEANBACK_LAUNCHER -a android.intent.action.VIEW -f 0x10808000 -e source 30 -d ' . $url . ' com.netflix.ninja/.MainActivity', $device);
if ($id === 'home') {
sleep(6);
- shieldKey(['ok', 'down']);
+ shieldKey(['ok', 'down'], $device);
} else {
sleep(1);
- shieldKey(['ok']);
+ shieldKey(['ok'], $device);
}
}
return true;
}
-function shieldTVCommand($cmd)
+function shieldArte($device = null)
{
- $e = explode(':', $cmd);
- if ($e[0] === 'netflix') {
- shieldNetflix(isset($e[1]) ? $e[1] : null);
- } else if ($e[0] === 'tv') {
- if ($e[1] === 'replay') {
- shieldTV(false, 'replay');
- } else if ($e[1] === 'live') {
- shieldTV($e[2], 'live');
- }
- }
-}
-
-function shieldArte()
-{
- return shieldLaunchApp('tv.arte.plus7/.leanback.MainActivity');
+ shieldLaunchApp('tv.arte.plus7/.leanback.MainActivity', $device);
}
-function shieldFranceTv()
+function shieldFranceTv($device = null)
{
- return shieldLaunchApp('fr.francetv.pluzz/fr.francetv.androidtv.main.MainActivity');
+ shieldLaunchApp('fr.francetv.pluzz/fr.francetv.androidtv.main.MainActivity', $device);
}
-function shieldLaunchApp($activity)
+function shieldLaunchApp($activity, $device)
{
- shieldHome();
- _adb('shell am start', '-n ' . $activity);
+ shieldHome($device);
+ shieldCommand('shell am start', '-n ' . $activity, $device);
}
function shieldMyCanal($channel = false, $type = 'live', $device = null)
shieldRunActivity($device);
if ($type === 'replay') {
if ($channel === 'arte') {
- return shieldArte();
+ shieldArte($device);
+ return;
} else if ($channel === 'francetv') {
- return shieldFranceTv();
+ shieldFranceTv($device);
+ return;
}
$url = 'https://www.canalplus.com/chaines/';
if ($channel !== 'home') {
}
setPlaying('mycanal', $device);
- shieldHome();
- _adb('shell am start', '-a android.intent.action.VIEW -f 0x10808000 -d ' . $url . ' com.canal.android.canal/com.canal.app.common.legacy.DeepLinkActivity');
+ shieldHome($device);
+ shieldCommand('shell am start', '-a android.intent.action.VIEW -f 0x10808000 -d ' . $url . ' com.canal.android.canal/com.canal.app.common.legacy.DeepLinkActivity', $device);
}
function shieldKodi($file, $device = null)
{
shieldRunActivity($device);
- shieldHome();
- $device = getDevice($device);
- if ($device === 'salon') {
- harmonyActivity('tv');
- }
- _adb('shell am start', '-a android.intent.action.VIEW -d \'"' . shieldNormalizeURL($file) . '"\' -n org.xbmc.kodi/.Splash');
+ shieldKillAll($device);
+ shieldHome($device);
+ shieldCommand('shell am start', '-a android.intent.action.VIEW -d \'"' . shieldNormalizeURL($file) . '"\' -n org.xbmc.kodi/.Splash', $device);
}
function shieldNormalizeURL($input)
return $input;
}
-function shieldVLC($file)
+function shieldVLC($file, $device = null)
{
shieldRunActivity($device);
- shieldHome();
- _adb('shell am start', '-a android.intent.action.VIEW -d \'"' . shieldNormalizeURL($file) . '"\' -n org.videolan.vlc/.StartActivity');
+ shieldHome($device);
+ shieldCommand('shell am start', '-a android.intent.action.VIEW -d \'"' . shieldNormalizeURL($file) . '"\' -n org.videolan.vlc/.StartActivity', $device);
}
-function shieldListApps()
+function shieldListApps($device = null)
{
- shieldConnect();
- _adb('shell pm list', 'packages -f');
+ shieldCommand('shell pm list', 'packages -f', $device);
}
-function shieldFindIntents($app)
+function shieldFindIntents($app, $device)
{
- shieldConnect();
-
$app = shieldGetAppId($app);
- _adb('shell pm dump', $app);
- _adb('shell pm dump', $app . ' | grep -A 1 "MAIN" | grep ' . $app . ' | awk \'{print $2}\' | grep ' . $app);
+ shieldCommand('shell pm dump', $app, $device);
+ shieldCommand('shell pm dump', $app . ' | grep -A 1 "MAIN" | grep ' . $app . ' | awk \'{print $2}\' | grep ' . $app, $device);
}
function shieldGetAppId($id = null)
{
- $apps = ['kodi' => 'org.xbmc.kodi', 'vlc' => 'org.videolan.vlc', 'netflix' => 'com.netflix.ninja', 'mycanal' => 'com.canal.android.canal', 'arte' => 'tv.arte.plus7', 'francetv' => 'fr.francetv.pluzz'];
+ $apps = shieldGetApps();
if (null === $id) {
return $apps;
}
return $id;
}
-function shieldHome()
+function shieldGetApps()
+{
+ return ['kodi' => 'org.xbmc.kodi',
+ 'vlc' => 'org.videolan.vlc',
+ 'netflix' => 'com.netflix.ninja',
+ 'mycanal' => 'com.canal.android.canal',
+ 'arte' => 'tv.arte.plus7',
+ 'francetv' => 'fr.francetv.pluzz',
+ 'gamecast' => 'com.nvidia.nvgamecast',
+ 'teleloisirs' => 'fr.playsoft.teleloisirs',
+ 'allocine' => 'com.allocine.androidapp',
+ 'twitch' => 'tv.twitch.android.app',
+ 'youtube' => 'com.google.android.youtube.tv',
+ 'dailymotion' => 'com.dailymotion.dailymotion',
+ 'vimeo' => 'com.vimeo.android.videoapp',
+ 'plex' => 'com.plexapp.android',
+ ];
+}
+
+function shieldHome($device = null)
{
- $res = shieldKey('home');
+ shieldKey('home', $device);
usleep(0.5 * 1000000);
- return $res;
}
-function shieldKill($app)
+function shieldKill($app, $device = null)
+{
+ shieldCommand('shell am', 'force-stop ' . shieldGetAppId($app), $device);
+}
+
+function shieldKillAll($device = null)
{
- shieldConnect();
- _adb('shell am', 'force-stop ' . shieldGetAppId($app));
+ $apps = shieldGetApps();
+ foreach ($apps as $name => $app) {
+ shieldKill($name, $device);
+ }
}
-function _adb($command, $params = '')
+function _adb($command, $params = '', $device = null)
{
- $c = 'adb ' . $command;
+ $device = getDevice($device);
+ $c = 'adb -s ' . $device['shield'] . ':5555 ' . $command;
if ($params) {
$c .= ' ' . $params;
}
protected function _path($p)
{
- $e = explode('.', $p);
- $ext = array_pop($e);
-
- array_push($e, 'x264');
- array_push($e, $ext);
- $x264 = implode('.', $e);
- if (file_exists($x264)) {
- $p = $x264;
- }
+// $e = explode('.', $p);
+// $ext = array_pop($e);
+//
+// array_push($e, 'x264');
+// array_push($e, $ext);
+// $x264 = implode('.', $e);
+// if (file_exists($x264)) {
+// $p = $x264;
+// }
return str_replace('/volume1/Share', '', $p);
}
<?php
require_once 'import.php';
-transcodeOneVideo();
\ No newline at end of file
+//transcodeOneVideo();
\ No newline at end of file