-
Notifications
You must be signed in to change notification settings - Fork 48
/
index.html
158 lines (119 loc) · 4.13 KB
/
index.html
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<!DOCTYPE html>
<html>
<head>
<title>Youtube-mp3</title>
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<link rel="stylesheet" href="style/style.css">
<script>window.$ = window.jQuery = require('jquery');</script>
<script src="js/getApiKey.js">
</script>
<script>
function ajax_get_json(id) {
var yt = id;
var results = document.getElementById("results");
var k = document.getElementById('key').value;
$.getJSON('http://www.yt-mp3.com/fetch?v=' + id + '&apikey=' + k, function (yt_data) {
if (yt_data.status == 'error') {
results.innerHTML = "<p style='top: 40vh;' id='Down' >" + yt_data.message + "</p>";
return false;
}
// if(yt_data.status!=='ok'){ajax_get_json(id);}
if (yt_data.status == 'timeout') {
results.innerHTML = "<p style='top: 40vh;' id='Down' >Video is in a queue, please wait <img style='line-hight:20px;' src='img/loader.gif' width='13px' height='13px' /></p>";
setTimeout(function () {
ajax_get_json(id);
}, 5000);
} else {
// results.innerHTML = "";
try {
if (yt_data.url !== undefined) {
results.innerHTML = "<div id='loader'></div><p id='Down'>" + yt_data.title + "<br><br> <a href=http:" + yt_data.url + "> Download </a> <br> </p>";
$("#results").css("background-image", "url(" + yt_data.thumbnail + ")");
dReady();
} else {
$("#results").css("background-image", "url(" + yt_data.thumbnail + ")");
results.innerHTML = "<p style='top: 40vh;' id='Down' >Video is in a queue, please wait <img style='line-hight:20px;' src='img/loader.gif' width='13px' height='13px' /></p>";
setTimeout(function () {
ajax_get_json(id);
}, 5000);
}
} catch (e) {
alert("Error, Please restart the application");
}
}
});
// results.innerHTML = "";
}
</script>
</head>
<body>
<div class="titlebar">
<audio id="myAudio">
<source src="audio/s.mp3" type="audio/mpeg">
</audio>
<div class="buttons">
<div title="close" class="close" id='close-btn'>
<a class="closebutton" href="#"><span><strong></strong></span></a>
<!-- close button link -->
</div>
<div title="minimize" class="minimize" id="min-btn">
<a class="minimizebutton" href="#"><span><strong></strong></span></a>
<!-- minimize button link -->
</div>
<div title="This app was mad by MEDZED" class="zoom">
<a class="zoombutton" href="#"><span><strong></strong></span></a>
<!-- zoom button link -->
</div>
</div>
<input type="text" class="textfield" name="url" onpaste="var e=this; setTimeout(function(){return runScript_paste(e.value);}, 4);" value="https://youtu.be/hlNIHMyF3-I" id="url" onkeypress="return runScript(event)">
<input id='key' type="text" style='display: none;' value='no key'>
</div>
<div id="results">
<div id="help">
Past a valid youtube link..
</div>
</div>
<script>
var url = document.getElementById("url").value;
function runScript(e) {
if (e.keyCode == 13) {
url = document.getElementById("url").value;
validateUrl(url);
}
}
function runScript_paste(url) {
validateUrl(url);
}
function validateUrl(url) {
var videoid = url.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/);
if (videoid != null) {
ajax_get_json(videoid[1]);
} else {
$("input").css('background-color', 'rgba(200,20,0,0.3)');
}
}
</script>
<script src="./js/noDragAndDrop.js"></script>
<script src="js/buttons.js"></script>
<script src="js/menu.js"></script>
<script src="js/downloadReady.js"></script>
<script>
$(document).ready(function () {
var key = document.getElementById('key').value;
testKey();
if ($('#results:empty').length) { alert("Error"); }
$('#url').focus();
var url = document.getElementById("url").value;
validateUrl(url);
});
function playAudio() {
var x = document.getElementById("myAudio");
x.play();
}
function testKey() {
getapikey();
setTimeout(function () { var apikey = document.getElementById('key').value; console.log(apikey); }, 2000);
}
</script>
</body>
</html>