]> _ Git - tortuga-home.git/commitdiff
.
authorVincent <vincent@enhydra.fr>
Fri, 3 Jan 2020 09:31:06 +0000 (10:31 +0100)
committerVincent <vincent@enhydra.fr>
Fri, 3 Jan 2020 09:31:06 +0000 (10:31 +0100)
.idea/workspace.xml
scripts/gradient.php
scripts/lib/mediarasp.php
scripts/mediacast.php [deleted file]
scripts/youtubedl-download.php

index 900e3fa9471648a8902f6d7f56f9d6abf446e505..24fe93420192a4a70c97ed157c6e9dc13b94edc5 100644 (file)
@@ -3,12 +3,10 @@
   <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$/scripts/lib/lib.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/lib.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/gradient.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/gradient.php" 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/off.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/off.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/scripts/lib/raspberrycast.php" beforeDir="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/raspberrycast.php" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/mediacast.php" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/youtubedl-download.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/youtubedl-download.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="6029000" />
-    </task>
-    <task id="LOCAL-00216" summary=".">
-      <created>1566888335894</created>
-      <option name="number" value="00216" />
-      <option name="presentableId" value="LOCAL-00216" />
-      <option name="project" value="LOCAL" />
-      <updated>1566888335894</updated>
+      <workItem from="1577891426611" duration="8164000" />
     </task>
     <task id="LOCAL-00217" summary=".">
       <created>1567019261000</created>
       <option name="project" value="LOCAL" />
       <updated>1578040654852</updated>
     </task>
-    <option name="localTasksCounter" value="265" />
+    <task id="LOCAL-00265" summary=".">
+      <created>1578040991600</created>
+      <option name="number" value="00265" />
+      <option name="presentableId" value="LOCAL-00265" />
+      <option name="project" value="LOCAL" />
+      <updated>1578040991600</updated>
+    </task>
+    <option name="localTasksCounter" value="266" />
     <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="1578040649872">
+    <state x="935" y="114" key="CommitChangelistDialog2" timestamp="1578040988584">
       <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="1578040649872" />
+    <state x="935" y="114" key="CommitChangelistDialog2/0.0.2560.1040@0.0.2560.1040" timestamp="1578040988584" />
     <state x="1114" y="443" key="NewPhpFileDialog" timestamp="1578038647334">
       <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="976" y="257" width="607" height="536" key="find.popup" timestamp="1578040823081">
+    <state x="976" y="257" width="607" height="536" key="find.popup" timestamp="1578043836670">
       <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="536" key="find.popup/0.0.2560.1040@0.0.2560.1040" timestamp="1578040823081" />
+    <state x="976" y="257" width="607" height="536" key="find.popup/0.0.2560.1040@0.0.2560.1040" timestamp="1578043836670" />
   </component>
   <component name="antWorkspaceConfiguration">
     <option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />
index ef8b55048edb00ceafb14ca8809755d3e0466153..40bdcbd18b2c398a78bb61b644ce527129222092 100644 (file)
@@ -81,7 +81,7 @@ if ($type == 'gradient' && (!is_array($res) || !count($res))) {
     $res = ['#ffffff', '#ffffff'];
 }
 if ($type == 'youtube') {
-    $res['video_path'] = downloadYoutubeDL('https://www.youtube.com/watch?v=' . $res['videoid'], false, 'webm');
+    $res['video_path'] = downloadYoutubeDL('https://www.youtube.com/watch?v=' . $res['videoid'],0, false, 'webm');
 }
 header('Content-type: application/json');
 $r = ['type' => $type, 'data' => $res];
index d3df1dc1476ae089d96ca6b461774b1f1ccdf550..9f8a277e69f5d2dabc0fcfc5334c5601826d1276 100644 (file)
@@ -347,39 +347,52 @@ function mediaRaspPlayCast($castURL, $device = null)
     }
     setPlaying('mediarasp:cast:' . $castURL);
     mediaRaspCommons($device);
-    $dest = downloadYoutubeDL($castURL);
+    $dest = downloadYoutubeDL($castURL, 1080, true, 'mkv');
     getYoutubeDLMeta($castURL);
     $res = VLCPlay($dest, $device);
+    print_r($res);
     mediaRaspPostPlay($device);
     setPlaying('mediarasp:cast:' . $castURL);
     return $res;
 }
 
-function getYoutubeDLCastURL($url)
+function getYoutubeDLCastURL($url, $height = 1080)
 {
-    $res = `/usr/local/bin/youtube-dl -f best --get-url $url`;
+    $h = '';
+    if ($height != 0) {
+        $h = '[height<=' . $height . ']';
+    }
+    $res = `/usr/local/bin/youtube-dl -f best$h --get-url $url`;
     return trim($res);
 }
 
-function getYoutubeDLPath($url, $ext = 'mkv')
+function getYoutubeDLPath($url, $h = 0, $ext = 'mkv')
 {
-    $hash = sha1($url);
+    $hash = $url;
+    if ($h != 0) {
+        $hash .= '--' . $h . '++';
+    }
+    echo $hash;
+    $hash = sha1($hash);
+    echo $hash;
     return "/nas/Videos/YoutubeDL/" . $hash . '.' . $ext;
 }
 
-function downloadYoutubeDL($url, $cast = true, $ext = 'mkv')
+function downloadYoutubeDL($url, $height = 1080, $cast = true, $ext = 'mkv')
 {
-    $dest = getYoutubeDLPath($url, $ext);
+    $dest = getYoutubeDLPath($url, $height, $ext);
     $wip = $dest . '.wip';
     if (!file_exists($dest)) {
         if (!file_exists($wip)) {
-            httpRequest('https://' . $_SERVER['HTTP_HOST'] . '/scripts/youtubedl-download.php?url=' . rawurldecode($url) . '&ext=' . $ext, 'get', [], null, $cast ? 1 : 0);
+            $convert = 'https://' . $_SERVER['HTTP_HOST'] . '/scripts/youtubedl-download.php?url=' . rawurldecode($url) . '&h=' . $height . '&ext=' . $ext;
+            echo $convert;
+            httpRequest($convert, 'get', [], null, $cast ? 1 : 0);
             if (!$cast) {
                 return $dest;
             }
         }
         if ($cast) {
-            return getYoutubeDLCastURL($url);
+            return getYoutubeDLCastURL($url, $height);
         }
     } else {
         return $dest;
diff --git a/scripts/mediacast.php b/scripts/mediacast.php
deleted file mode 100644 (file)
index 9c3b794..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-require_once 'import.php';
-
-if (!isset($_GET['device'])) {
-       $_GET['device'] = config('DEVICE');
-}
-
-mediaRaspCastURL($_GET['url'], $_GET['device']);
\ No newline at end of file
index a91363a1cec16e961248e69b1fcbe454be3897e2..4dd7a4b6fb132d463d50fc98b63877d5c64cc5cd 100644 (file)
@@ -1,16 +1,23 @@
 <?php
 require_once "import.php";
 $url = $_GET['url'];
-$ext=$_GET['ext'];
+$ext = $_GET['ext'];
+$h = isset($_GET["h"]) ? $_GET['h'] : 0;
 
-$dest = getYoutubeDLPath($url,$ext);
+$dest = getYoutubeDLPath($url, $h, $ext);
 $wip = $dest . '.wip';
 if (!file_exists($dest) && !file_exists($wip)) {
     set_time_limit(0);
     ignore_user_abort(true);
     file_put_contents($wip, '');
+    $height = '';
+    if ($h != 0) {
+        $height = '[height<=' . $h . ']';
+    }
 
-    $format = 'bestvideo+bestaudio/best';
-    `/usr/local/bin/youtube-dl -f '$format' -o $dest --merge-output-format mkv '$url'`;
+    $format = 'bestvideo' . $height . '+bestaudio/best' . $height;
+    $cmd="/usr/local/bin/youtube-dl -f '$format' -o $dest --merge-output-format mkv '$url'";
+    echo $cmd;
+    `$cmd`;
     unlink($wip);
 }
\ No newline at end of file