diff options
Diffstat (limited to 'yt.php')
-rw-r--r-- | yt.php | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -0,0 +1,27 @@ +<?php
+
+ini_set('max_execution_time', 300);
+ini_set('request_terminate_timeout', 300);
+require_once $_SERVER['DOCUMENT_ROOT'] . "/private/session.php";
+
+if (!isset($_GET['i'])) {
+ die();
+}
+
+if (strpos($_GET['i'], ".") !== false || strpos($_GET['i'], "/") !== false) {
+ die();
+}
+
+$film = $_GET['i'];
+$id = bin2hex(random_bytes(96));
+
+exec("bash -c \"rm -Rfvd /tmp/ytphp-*\"");
+mkdir("/tmp/ytphp-" . $id);
+exec("bash -c \"cd /tmp/ytphp-" . $id . " && yt-dlp -f 'bestaudio[ext=m4a]' -x -o 'audio.m4a' --audio-format m4a \\\"" . $film . "\\\"\"", $out);
+
+$fp = fopen("/tmp/ytphp-" . $id . "/audio.m4a", 'rb');
+header("Content-Type: " . mime_content_type("/tmp/ytphp-" . $id . "/audio.m4a"));
+header("Content-Length: " . filesize("/tmp/ytphp-" . $id . "/audio.m4a"));
+fpassthru($fp);
+exec("bash -c \"rm -Rfvd /tmp/ytphp-*\"");
+exit;
|