Outils pour utilisateurs

Outils du site


php:youtubedlproxy

Youtube-dl Proxy

Minimal (very dirty) script executing youtube-dl and displaying video in the web browser. Place in folder with the “youtube-dl” binary (non included), and open in web browser like this:

http(s)://domain.tld/watch?v=aqz-KE-bpKQ

(note: video is actually downloaded server-side, so make sure to have enough disk space and PHP script execution time while youtube-dl processes the video)

.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
index.php
<?php 
if(!isset($_GET['v']))
	die;
exec('rm *.webm');  //purge previous videos
 
// prepare URL and download WebM file format (highest→lowest quality)
$id = $_GET['v'];
$url='https://www.youtube.com/watch?v='.$id;
exec('./youtube-dl -o "'.$id.'" -f 303+251/248+251/302+251/247+251/244+251/243+251/242+251/278+251/248+249/247+249/244+249/243+249/242+249  "'.$url.'" ');
?>
 
<!DOCTYPE html><!-- <!DOCTYPE HTML PUBLIC> -->
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta http-equiv="Cache-Control" content="no-store">
<style type="text/css">
body {	font-family:sans-serif;}
video { max-width:70%; }
</style>
<body>
<video src="<?php echo $id; ?>.webm" controls autoplay></video>
<br><a href="<?php echo $url; ?>">video URL</a>
</body>
</html>
php/youtubedlproxy.txt · Dernière modification : 2020-11-12 17:09 de mitsu