summaryrefslogtreecommitdiff
path: root/modules/ytdl/ytdl.html
blob: e054b974009788592c60d9832a2dae26a98ef1fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>YTDL</title>
<script>
function retrieve_link(){
	var link=document.getElementById("inputlink").value;
	var xhr=new XMLHttpRequest();
	xhr.addEventListener("readystatechange",function(){
		if(xhr.readyState<4){
			show_output(["(waiting to send)","(request opened)","(headers received)","(loading)"][xhr.readyState]);
		}
		if(xhr.readyState!=4)return;
		var response;
		if(xhr.responseText==null)response="(null)";
		else response=xhr.responseText;
		show_output(response,/^https?:\/\//.test(response));
	});
	xhr.open("GET","/ytdl/"+encodeURIComponent(link));
	xhr.send();
}

function show_output(text,link){
	var output=document.getElementById("output");
	if(output.firstChild)output.removeChild(output.firstChild);
	var e;
	if(link){
		e=document.createElement("a");
		e.href=text;
		e.appendChild(document.createTextNode(text));
	} else e=document.createTextNode(text);
	output.appendChild(e);
}
</script>
</head>
<body>
<h1>YTDL</h1>
<p>This page uses the <code>youtube-dl</code> utility to provide a download link for a given youtube video. It just selects whatever format <code>youtube-dl</code> considers "best"; this is normally video+audio, in the highest quality provided by YouTube.
Enter a link or a video id below:</p>
<input type="text" id="inputlink" size="100"><br>
<input type="button" value="Retrieve link" onclick="retrieve_link()"><br>
<pre id="output" style="width:100%;word-wrap:break-word;"></pre>
</body>
</html>