From: Vincent Date: Sun, 1 Nov 2020 09:54:21 +0000 (+0100) Subject: . X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=dfd45f897457f686529a03a8927c5243d60bdd8e;p=tortuga-home.git . --- diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e1541d3..c89f585 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,8 +3,10 @@ - + + + @@ -1287,9 +1279,14 @@ - - + + + + + + + @@ -1300,6 +1297,10 @@ + + + + @@ -1312,6 +1313,10 @@ + + + + diff --git a/config/remote.php b/config/remote.php index f9feb36..4d7d039 100644 --- a/config/remote.php +++ b/config/remote.php @@ -21,6 +21,27 @@ $bricksFreebox = ['type' => 'freebox', 'width' => 6, 'height' => 4, 'bricks' => ['type' => 'remote-channels', 'width' => 1, 'height' => 3, 'top' => 0, 'left' => 5], ]]; +$bricksShield = ['type' => '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], +]]; + $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], @@ -74,4 +95,5 @@ $shortcuts['remote-squeezebox'] = [['type' => 'bricks', 'bricks' => $bricksSquee $shortcuts['remote-raspberrycast'] = [['type' => 'bricks', 'bricks' => $bricksRaspberryCast]]; $shortcuts['remote-mediarasp'] = [['type' => 'bricks', 'bricks' => $bricksMediarasp]]; $shortcuts['remote-freebox'] = [['type' => 'bricks', 'bricks' => $bricksFreebox]]; -$shortcuts['remote-omxtv'] = [['type' => 'bricks', 'bricks' => $bricksOMXRaspTV]]; \ No newline at end of file +$shortcuts['remote-omxtv'] = [['type' => 'bricks', 'bricks' => $bricksOMXRaspTV]]; +$shortcuts['remote-shield'] = [['type' => 'bricks', 'bricks' => $bricksShield]]; \ No newline at end of file diff --git a/config/tv.php b/config/tv.php index 1a8d7aa..0a61ab6 100644 --- a/config/tv.php +++ b/config/tv.php @@ -18,44 +18,43 @@ if (!$mapdvb) { } $tv = array( - 'Replay' => array('freebox' => 'replay'), - 'Netflix' => array('freebox' => 'netflix'), + 'Replay' => array('freebox' => 'replay', 'shield' => 'tv:replay'), + 'Netflix' => array('freebox' => 'netflix', 'shield' => 'netflix'), 'Infos', - 'France Info' => array('stream' => 'tvheadend:franceinfo:', 'channel' => 27), - 'Cnews' => array('stream' => 'tvheadend:CNEWS', 'channel' => 16), - 'BFM TV' => array('stream' => 'tvheadend:BFM TV', 'channel' => 15), - 'BFM Business' => array('stream' => 'tvheadend:BFM Paris', 'channel' => 347), - 'LCI' => array('stream' => 'tvheadend:LCI', 'channel' => 26), - 'Euronews' => array('stream' => 'fbx:205:sd', 'channel' => 345), + 'France Info' => array('stream' => 'tvheadend:franceinfo:', 'channel' => 27,'shield'=>'tv:live:franceinfo'), + 'Cnews' => array('stream' => 'tvheadend:CNEWS', 'channel' => 16,'shield'=>'tv:live:cnews'), + 'BFM TV' => array('stream' => 'tvheadend:BFM TV', 'channel' => 15,'shield'=>'tv:live:bfmtv'), + 'BFM Business' => array('stream' => 'tvheadend:BFM Paris', 'channel' => 347,'shield'=>'tv:live:paris'), + 'LCI' => array('stream' => 'tvheadend:LCI', 'channel' => 26,'shield'=>'tv:live:lci'), + 'Euronews' => array('stream' => 'fbx:205:sd', 'channel' => 345,'shield'=>'tv:live:euronews'), 'Généralistes', - 'TF1' => array('stream' => 'tvheadend:TF1', 'channel' => 1), - 'France 2' => array('stream' => 'tvheadend:France 2', 'channel' => 2), - 'France 3' => array('stream' => 'tvheadend:F3 Paris Ile-de-France', 'channel' => 3), - 'France 5' => array('stream' => 'tvheadend:France 5', 'channel' => 5), - 'M6' => array('stream' => 'tvheadend:M6', 'channel' => 6), - 'Canal +' => array('stream' => 'tvheadend:CANAL+', 'channel' => 4), - 'Arte' => array('stream' => 'tvheadend:Arte', 'channel' => 7), - 'C8' => array('stream' => 'tvheadend:C8', 'channel' => 8), - 'W9' => array('stream' => 'tvheadend:W9', 'channel' => 9), - 'TMC' => array('stream' => 'tvheadend:TMC', 'channel' => 10), - 'TFX' => array('stream' => 'tvheadend:TFX', 'channel' => 11), - 'NRJ12' => array('stream' => 'tvheadend:NRJ12', 'channel' => 12), - 'LCP' => array('stream' => 'tvheadend:LCP', 'channel' => 13), - 'France 4' => array('stream' => 'tvheadend:France 4', 'channel' => 14), - 'CStar' => array('stream' => 'tvheadend:CSTAR', 'channel' => 17), - 'Gulli' => array('stream' => 'tvheadend:Gulli', 'channel' => 18), - 'France Ô' => array('stream' => 'tvheadend:France Ô', 'channel' => 19), - 'RMC Story' => array('stream' => 'tvheadend:RMC STORY', 'channel' => 23), - 'RMC Découverte' => array('stream' => 'tvheadend:RMC Découverte', 'channel' => 24), - 'Chérie 25' => array('stream' => 'tvheadend:Chérie 25', 'channel' => 25), - 'Paris première' => array('stream' => 'fbx:213:ld', 'channel' => 28), - 'RTL9' => array('stream' => 'fbx:210:ld', 'channel' => 29), - '6ter' => array('stream' => 'tvheadend:6ter', 'channel' => 22), - 'TF1 Séries Films' => array('stream' => 'tvheadend:TF1 Séries Films', 'channel' => 20), + 'TF1' => array('stream' => 'tvheadend:TF1', 'channel' => 1,'shield'=>'tv:live:tf1'), + 'France 2' => array('stream' => 'tvheadend:France 2', 'channel' => 2,'shield'=>'tv:live:france2'), + 'France 3' => array('stream' => 'tvheadend:F3 Paris Ile-de-France', 'channel' => 3,'shield'=>'tv:live:france3'), + 'France 5' => array('stream' => 'tvheadend:France 5', 'channel' => 5,'shield'=>'tv:live:france5'), + 'M6' => array('stream' => 'tvheadend:M6', 'channel' => 6,'shield'=>'tv:live:m6'), + 'Canal +' => array('stream' => 'tvheadend:CANAL+', 'channel' => 4,'shield'=>'tv:live:canalplus'), + 'Arte' => array('stream' => 'tvheadend:Arte', 'channel' => 7,'shield'=>'tv:live:arte'), + 'C8' => array('stream' => 'tvheadend:C8', 'channel' => 8,'shield'=>'tv:live:c8'), + 'W9' => array('stream' => 'tvheadend:W9', 'channel' => 9,'shield'=>'tv:live:w9'), + 'TMC' => array('stream' => 'tvheadend:TMC', 'channel' => 10,'shield'=>'tv:live:tmc'), + 'TFX' => array('stream' => 'tvheadend:TFX', 'channel' => 11,'shield'=>'tv:live:tfx'), + 'NRJ12' => array('stream' => 'tvheadend:NRJ12', 'channel' => 12,'shield'=>'tv:live:nrj12'), + 'LCP' => array('stream' => 'tvheadend:LCP', 'channel' => 13,'shield'=>'tv:live:lcp'), + 'France 4' => array('stream' => 'tvheadend:France 4', 'channel' => 14,'shield'=>'tv:live:france4'), + 'CStar' => array('stream' => 'tvheadend:CSTAR', 'channel' => 17,'shield'=>'tv:live:cstar'), + 'Gulli' => array('stream' => 'tvheadend:Gulli', 'channel' => 18,'shield'=>'tv:live:gulli'), + 'RMC Story' => array('stream' => 'tvheadend:RMC STORY', 'channel' => 23,'shield'=>'tv:live:rmcstory'), + 'RMC Découverte' => array('stream' => 'tvheadend:RMC Découverte', 'channel' => 24,'shield'=>'tv:live:rmcdecouverte'), + 'Chérie 25' => array('stream' => 'tvheadend:Chérie 25', 'channel' => 25,'shield'=>'tv:live:cherie25'), + 'Paris première' => array('stream' => 'fbx:213:ld', 'channel' => 28,'shield'=>'tv:live:parispremiere'), + 'RTL9' => array('stream' => 'fbx:210:ld', 'channel' => 29,'shield'=>'tv:live:rtl9'), + '6ter' => array('stream' => 'tvheadend:6ter', 'channel' => 22,'shield'=>'tv:live:6ter'), + 'TF1 Séries Films' => array('stream' => 'tvheadend:TF1 Séries Films', 'channel' => 20,'shield'=>'tv:live:tf1seriesfilms'), 'Monde', - 'TV5 Monde' => array('stream' => 'fbx:206:sd', 'channel' => 1), - 'France 24' => array('stream' => 'tvheadend:France 24', 'channel' => 340), - 'TVE I' => array('stream' => 'fbx:306:sd', 'channel' => 537)); + 'TV5 Monde' => array('stream' => 'fbx:206:sd', 'channel' => 1,'shield'=>'tv:live:tv5monde'), + 'France 24' => array('stream' => 'tvheadend:France 24', 'channel' => 340,'shield'=>'tv:live:france24'), + 'TVE I' => array('stream' => 'fbx:306:sd', 'channel' => 537,'shield'=>'tv:live:tvei')); $shortcuts['sub-tv'] = array(); $tvplayer = config('TVPLAYER'); diff --git a/scripts/lib/shield.php b/scripts/lib/shield.php index a3f9f8a..ca9275f 100644 --- a/scripts/lib/shield.php +++ b/scripts/lib/shield.php @@ -6,9 +6,8 @@ function shieldConnect() { global $shieldConnect; if (!$shieldConnect) { - //_adb('kill-server'); - //_adb('start-server'); - //_adb('connect', SHIELD_HOST); + $shieldConnect = true; + _adb('connect', SHIELD_HOST); } } @@ -23,7 +22,7 @@ function shieldText($text) shieldCommand('shell', 'input text ' . $text); } -function shieldKey($key) +function shieldKey($keys) { $map = ['right' => 'KEYCODE_DPAD_RIGHT', 'up' => 'KEYCODE_DPAD_UP', @@ -38,11 +37,20 @@ function shieldKey($key) 'play' => 'KEYCODE_MEDIA_PLAY', 'pause' => 'KEYCODE_MEDIA_PAUSE', 'stop' => 'KEYCODE_MEDIA_STOP', + 'space' => 'KEYCODE_SPACE', ]; - if (isset($map[$key])) { - $key = $map[$key]; + if (!is_array($keys)) { + $keys = [$keys]; } - shieldCommand('shell', 'input keyevent ' . $key); + + $cmds = []; + foreach ($keys as $key) { + if (isset($map[$key])) { + $key = $map[$key]; + }; + $cmds[] = 'input keyevent ' . $key; + } + shieldCommand('shell', '"' . implode(' && ', $cmds) . '"'); } function shieldNetflix($id = null) @@ -56,20 +64,156 @@ function shieldNetflix($id = null) _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'); } -function shieldTVChannel() + +function shieldTVCommand($cmd) +{ + $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'); +} + +function shieldFranceTv() +{ + return shieldLaunchApp('fr.francetv.pluzz/fr.francetv.androidtv.main.MainActivity'); +} + +function shieldLaunchApp($activity) { + shieldHome(); + _adb('shell am start', '-n ' . $activity); +} + +function shieldTv($channel = false, $type = 'live') +{ + if ($type === 'replay') { + if ($channel === 'arte') { + return shieldArte(); + } else if ($channel === 'francetv') { + return shieldFranceTv(); + } + } + + shieldHome(); + $url = 'mycanaltvlauncher://startapp'; + _adb('shell am start', '-a android.intent.action.VIEW -f 0x10808000 -d ' . $url . ' com.canal.android.canal/com.canal.ui.tv.TvMainActivity'); + sleep(1); + $keys = ['left', 'left', 'left', 'left', 'left', 'left', 'up', 'up', 'up', 'up', 'up', 'up', 'down']; + if ($type === 'live') { + $keys = array_merge($keys, ['down', 'right', 'down']); + if ($channel) { + $keys = array_merge($keys, shieldGetKeysToTvChannel($channel)); + + } + } else if ($type === 'replay') { + $keys = array_merge($keys, ['down', 'down', 'right', 'down', 'down']); + if ($channel) { + $keys = array_merge($keys, shieldGetKeysToReplayChannel($channel)); + } + } + + shieldKey($keys); +} + + +function shieldGetKeysToTvChannel($channel) +{ + + $canalchannels = ['tf1', 'france2', 'france3', 'canalplus', + 'france5', 'm6', 'arte', 'polarplus', + 'warnertv', 'serieclub', 'tvbreizh', 'rtl9', + 'ab1', 'novelas', 'tf1seriesfilms', 'infosportplus', + 'eurosport1', 'eurosport2', 'automoto', 'equidia', + 'lequipetv', 'comedieplus', 'olympiatv', 'nonstoppeople', + 'parispremiere', 'teva', 'bet', 'c8', + 'w9', 'tmc', 'tfx', 'nrj12', + 'cstar', '6ter', 'rmcstory', 'cherie25', + 'tv5monde', 'planeteplus', 'planetepluscrime', 'planeteplusae', + 'voyage', 'museumtv', 'nationalgeographic', 'nationalgeographicwild', + '', '', '', '', + 'rmcdecouverte', '', '', '', + '', '', '', '', + '', '', '', '', + '', 'france4', 'gulli', '', + '', '', '', '', + '', '', '', '', + '', 'lachainemeteo', 'cnews', 'bfmtv', + 'lci', 'franceinfo', 'lcp', 'france24', + 'euronews', 'cnn', 'bbcworldnews', 'bfmbusiness', + ]; + return shieldGetKeysToChannel($canalchannels, $channel, 4, ['ok']); +} + +function shieldGetKeysToReplayChannel($channel) +{ + + $replaychannels = ['tf1', 'france2', 'france3', 'france5', 'm6', + 'arte', 'polarplus', 'warnertv', 'serieclub', 'hello', + 'tvbreizh', 'rtl9', 'ab1', 'novelas', 'eurosport', + 'automoto', 'equidia', 'comedieplus', 'olympiatv', 'nonstoppeople', + 'parispremiere', 'teva', 'bet', 'c8', 'w9', + 'cstar', '6ter', 'planeteplus', 'voyage', 'museumtv', + 'nationalgeographic', 'nationalgeographicwild', '', '', '', + 'rmcdecouverte', '', '', '', '', + '', '', '', '', '', + '', '', '', 'france4', 'gulli', + + ]; + return shieldGetKeysToChannel($replaychannels, $channel, 5, ['ok']); +} + +function shieldGetKeysToChannel($list, $channel, $perline = 4, $sendAfter = []) +{ + $res = []; + $index = array_search($channel, $list); + if ($index === false) { + return $res; + } + + $col = $index % $perline; + $lines = ($index - $col) / $perline; + + for ($i = 0; $i < $lines; $i++) { + $res[] = 'down'; + } + for ($i = 0; $i < $col; $i++) { + $res[] = 'right'; + } + $res[] = array_merge($res, $sendAfter); + return $res; +} + +function shieldVLC($file) +{ + shieldHome(); + $url = 'smb://Share:dcfyjbcyckwydtgufjx@192.168.13.4/Share/' . $file; + _adb('shell am start', '-a android.intent.action.VIEW -d \'"' . $url . '"\' -n org.xbmc.kodi/.Splash'); } function shieldListApps() { + shieldConnect(); _adb('shell pm list', 'packages -f'); } function shieldFindIntents($app) { - $apps = ['netflix' => 'com.netflix.ninja', 'mycanal' => 'com.canal.android.canal']; + shieldConnect(); + $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']; $app = $apps[$app]; + _adb('shell pm dump', $app); _adb('shell pm dump', $app . ' | grep -A 1 "MAIN" | grep ' . $app . ' | awk \'{print $2}\' | grep ' . $app); } @@ -82,7 +226,8 @@ function shieldHome() function shieldKill() { - $tokill = ['com.netflix.ninja']; + shieldConnect(); + $tokill = ['com.canal.android.canal']; foreach ($tokill as $item) { _adb('shell am', 'force-stop ' . $item); } diff --git a/scripts/lib/tmdb.php b/scripts/lib/tmdb.php index 13ec694..d5e85df 100644 --- a/scripts/lib/tmdb.php +++ b/scripts/lib/tmdb.php @@ -131,12 +131,14 @@ class tvShowLibrary extends mediaLibrary @rename($f->getPathname(), str_replace('.tmbd.id', '.tmdb.id', $f->getPathname())); continue; } - if ($f->isDir() || ($f->getFilename() != '.tmdb.id')) { + if ($f->isDir() || strpos($f->getFilename(), '.tmdb.id') === false) { continue; } + $file = str_replace('.tmdb.id', '', $f->getPathname()); + $dir = file_exists($file) && is_file($file) ? file_get_contents($file) : $f->getPath(); $id = file_get_contents($f->getPathname()); - $this->tvShows[] = ['type' => 'tvshow', 'dir' => $f->getPath(), 'data' => $this->getTVShowByID($id), 'id' => $id, 'mtime' => $this->dirfilemtime($f->getPath(), true)]; + $this->tvShows[] = ['type' => 'tvshow', 'dir' => $dir, 'data' => $this->getTVShowByID($id), 'id' => $id, 'mtime' => $this->dirfilemtime($f->getPath(), true)]; } } @@ -195,6 +197,14 @@ class tvShowLibrary extends mediaLibrary public function shortcut($tvShow, $prefix, &$res) { global $videoExt; + + + $e = explode(':', $tvShow['dir']); + if ($e[0] === 'netflix') { + $res['shortcuts'][] = ['label' => $tvShow['data']['name'], 'type' => 'media', 'path' => $tvShow['dir'], 'poster' => $this->_poster($tvShow['data']['poster_path'])]; + return; + } + $subname = $prefix . 'tvshow-' . $tvShow['id']; $res['shortcuts'][] = ['label' => $tvShow['data']['name'], 'type' => 'sub', 'sub' => $subname, 'poster' => $this->_poster($tvShow['data']['poster_path'])]; diff --git a/scripts/shield.php b/scripts/shield.php index 65d331b..d92ec3a 100644 --- a/scripts/shield.php +++ b/scripts/shield.php @@ -13,5 +13,13 @@ if (isset($_GET['key'])) { if ($_GET['action'] == 'apps') { shieldListApps(); } +} else if (isset($_GET['intents'])) { + shieldFindIntents($_GET['intents']); +} elseif (isset($_GET['tv'])) { + shieldTv($_GET['tv']); +} else if (isset($_GET['replay'])) { + shieldTv($_GET['replay'], 'replay'); +} else if (isset($_GET['vlc'])) { + shieldVLC($_GET['vlc']); } echo ''; \ No newline at end of file