]> _ Git - tortuga-home.git/commitdiff
.
authorVincent <vincent@enhydra.fr>
Fri, 3 Jan 2020 08:24:04 +0000 (09:24 +0100)
committerVincent <vincent@enhydra.fr>
Fri, 3 Jan 2020 08:24:04 +0000 (09:24 +0100)
.idea/workspace.xml
js/home.js
scripts/lib/mediarasp.php
scripts/lib/raspberrycast.php
scripts/youtubedl-download.php [new file with mode: 0644]

index 9e22030eddcaa53984f6696f4002d4acbc7d743b..ba04ba3cc5ba0355816b7b1a639ea6ca75b86554 100644 (file)
@@ -2,11 +2,11 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
+      <change afterPath="$PROJECT_DIR$/scripts/youtubedl-download.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/index.php" beforeDir="false" afterPath="$PROJECT_DIR$/index.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/js/home.js" beforeDir="false" afterPath="$PROJECT_DIR$/js/home.js" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/scripts/lib/mediarasp.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/mediarasp.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/scripts/lib/weatherstation.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/weatherstation.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/raspberrycast.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/raspberrycast.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
       <workItem from="1577378088885" duration="2201000" />
       <workItem from="1577380387468" duration="866000" />
       <workItem from="1577785483253" duration="3506000" />
-      <workItem from="1577891426611" duration="1934000" />
-    </task>
-    <task id="LOCAL-00213" summary=".">
-      <created>1566603610179</created>
-      <option name="number" value="00213" />
-      <option name="presentableId" value="LOCAL-00213" />
-      <option name="project" value="LOCAL" />
-      <updated>1566603610179</updated>
+      <workItem from="1577891426611" duration="4801000" />
     </task>
     <task id="LOCAL-00214" summary=".">
       <created>1566737418166</created>
       <option name="project" value="LOCAL" />
       <updated>1577787688220</updated>
     </task>
-    <option name="localTasksCounter" value="262" />
+    <task id="LOCAL-00262" summary=".">
+      <created>1578036926863</created>
+      <option name="number" value="00262" />
+      <option name="presentableId" value="LOCAL-00262" />
+      <option name="project" value="LOCAL" />
+      <updated>1578036926863</updated>
+    </task>
+    <option name="localTasksCounter" value="263" />
     <servers />
   </component>
   <component name="TodoView">
     </state>
     <state x="720" y="247" key="#com.intellij.openapi.updateSettings.impl.PluginUpdateInfoDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1577298128269" />
     <state x="960" y="247" key="#com.intellij.openapi.updateSettings.impl.PluginUpdateInfoDialog/0.0.2560.1040@0.0.2560.1040" timestamp="1576479992407" />
-    <state x="935" y="114" key="CommitChangelistDialog2" timestamp="1577787685019">
+    <state x="935" y="114" key="CommitChangelistDialog2" timestamp="1578036915321">
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
     <state x="701" y="114" key="CommitChangelistDialog2/0.0.1920.1040@0.0.1920.1040" timestamp="1577381105204" />
     <state x="701" y="127" key="CommitChangelistDialog2/0.0.1920.1160@0.0.1920.1160" timestamp="1575647157027" />
-    <state x="935" y="114" key="CommitChangelistDialog2/0.0.2560.1040@0.0.2560.1040" timestamp="1577787685019" />
-    <state x="1114" y="443" key="NewPhpFileDialog" timestamp="1577785958789">
+    <state x="935" y="114" key="CommitChangelistDialog2/0.0.2560.1040@0.0.2560.1040" timestamp="1578036915321" />
+    <state x="1114" y="443" key="NewPhpFileDialog" timestamp="1578038647334">
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
     <state x="836" y="443" key="NewPhpFileDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1577363498855" />
-    <state x="1114" y="443" key="NewPhpFileDialog/0.0.2560.1040@0.0.2560.1040" timestamp="1577785958789" />
+    <state x="1114" y="443" key="NewPhpFileDialog/0.0.2560.1040@0.0.2560.1040" timestamp="1578038647334" />
     <state x="872" y="242" key="Vcs.Push.Dialog.v2" timestamp="1577787700897">
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
     <state x="732" y="343" key="com.intellij.ide.util.TipDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1577380394903" />
     <state x="732" y="383" key="com.intellij.ide.util.TipDialog/0.0.1920.1160@0.0.1920.1160" timestamp="1575647093028" />
     <state x="976" y="343" key="com.intellij.ide.util.TipDialog/0.0.2560.1040@0.0.2560.1040" timestamp="1577891427221" />
-    <state x="732" y="257" width="607" height="536" key="find.popup" timestamp="1577380471547">
-      <screen x="0" y="0" width="1920" height="1040" />
+    <state x="976" y="257" width="607" height="536" key="find.popup" timestamp="1578037318294">
+      <screen x="0" y="0" width="2560" height="1040" />
     </state>
     <state x="732" y="257" width="607" height="536" key="find.popup/0.0.1920.1040@0.0.1920.1040" timestamp="1577380471547" />
-    <state x="976" y="257" width="607" height="526" key="find.popup/0.0.2560.1040@0.0.2560.1040" timestamp="1576492890263" />
+    <state x="976" y="257" width="607" height="536" key="find.popup/0.0.2560.1040@0.0.2560.1040" timestamp="1578037318294" />
   </component>
   <component name="antWorkspaceConfiguration">
     <option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />
index 245c8bc4a08b2ab1121548bbbbb2e1b2f6206060..45b6f0c18a49b970a4c07b58c86c2069b2064a57 100644 (file)
@@ -187,7 +187,7 @@ $(function () {
             return false;
         }
 
-        $.get('/scripts/mediacast.php?device=' + CONFIG.DEVICE + '&url=' + encodeURIComponent(url), function () {
+        $.get('/scripts/mediarasp.php?action=play&device=' + CONFIG.DEVICE + '&cast=' + encodeURIComponent(url), function () {
             window.location = '#/section/remote'
         });
         return false;
index 57d524d205ded90ece1f9971cbe9bae5d3fa87a1..bf3b7a7631021085e2bf3dd3d0e59ec1d56538ff 100644 (file)
@@ -359,27 +359,11 @@ function mediaRaspPlayStream($url, $device = null)
     mediaRaspCommons($device);
     $res = VLCPlay($url, $device);
     mediaRaspPostPlay($device);
-    try {
-        raspberryCast('video', $device, ['control' => 'stop']);
-    } catch (Exception $e) {
-
-    }
     setPlaying('mediarasp:' . $url, $device);
     mediaRaspCommons($device);
     return $res;
 }
 
-
-function mediaRaspCastURL($url, $device = null)
-{
-    if (null === $device) {
-        $device = config('DEVICE');
-    }
-    setPlaying('raspberrycast:' . $url, $device);
-    raspberryCast('stream', $device, ['url' => $url]);
-    setPlaying('raspberrycast:' . $url, $device);
-}
-
 function mediaRaspPlayCast($castURL, $device = null)
 {
     if (null === $device) {
@@ -395,21 +379,30 @@ function mediaRaspPlayCast($castURL, $device = null)
     return $res;
 }
 
-function downloadYoutubeDL($url, $ext = 'mkv')
+function getYoutubeDLCastURL($url)
+{
+    $res = `/usr/local/bin/youtube-dl -f best --get-url $url`;
+    return trim($res);
+}
+
+function getYoutubeDLPath($url)
 {
     $hash = sha1($url);
-    $dest = "/nas/Videos/YoutubeDL/" . $hash . '.' . $ext;
-    $wip = $dest . '.wip';
-    if (!file_exists($dest) && !file_exists($wip)) {
-        set_time_limit(0);
-        ignore_user_abort(true);
-        file_put_contents($wip, '');
+    return "/nas/Videos/YoutubeDL/" . $hash . '.mkv';
+}
 
-        $format = 'bestvideo+bestaudio/best';
-        `/usr/local/bin/youtube-dl -f '$format' -o $dest --merge-output-format $ext '$url'`;
-        unlink($wip);
+function downloadYoutubeDL($url)
+{
+    $dest = getYoutubeDLPath($url);
+    $wip = $dest . '.wip';
+    if (!file_exists($dest)) {
+        if (!file_exists($wip)) {
+            httpRequest('https://' . $_SERVER['HTTP_HOST'] . '/scripts/youtubedl-download.php?url=' . rawurldecode($url), 'get', [], null, 1);
+        }
+        return getYoutubeDLCastURL($url);
+    } else {
+        return $dest;
     }
-    return $dest;
 }
 
 function getYoutubeDLMeta($url, $isHash = false)
@@ -514,6 +507,7 @@ function VLCPlay($fileorstream, $device = null, $timeout = 5)
     if (file_exists($fileorstream)) {
         $fileorstream = 'file://' . $fileorstream;
     }
+    echo $fileorstream;
     if ($device === 'bureau') {
         sshCommand('/usr/local/bin/soundtohdmi', $device, true, true);
     }
index 3bc29885381f945b41bb35bf7ec42cce6ad50069..66ba6430ffa7233379ae2ad7d47f3257424850fd 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-function  raspberryCast($command, $device = null, $data = [])
+function raspberryCast($command, $device = null, $data = [])
 {
        global $devices;
        if (null === $device) {
diff --git a/scripts/youtubedl-download.php b/scripts/youtubedl-download.php
new file mode 100644 (file)
index 0000000..f4fd135
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+require_once "import.php";
+$url = $_GET['url'];
+
+$dest = getYoutubeDLPath($url);
+$wip = $dest . '.wip';
+if (!file_exists($dest) && !file_exists($wip)) {
+    set_time_limit(0);
+    ignore_user_abort(true);
+    file_put_contents($wip, '');
+
+    $format = 'bestvideo+bestaudio/best';
+    `/usr/local/bin/youtube-dl -f '$format' -o $dest --merge-output-format mkv '$url'`;
+    unlink($wip);
+}
\ No newline at end of file