-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
212 lines (194 loc) · 9.51 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<html>
<head>
<title>Twitch Highlight Reel Generator</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/css/bootstrap-material-design.min.css" integrity="sha384-wXznGJNEXNG1NFsbm0ugrLFMQPWswR3lds2VeinahP8N0zJw9VWSopbjv2x7WCvX" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/umd/popper.js" integrity="sha384-fA23ZRQ3G/J53mElWqVJEGJzU0sTs+SvzG8fXVWP+kJQ1lwFAOkcUOysnlKJC33U" crossorigin="anonymous"></script>
<script src="https://unpkg.com/[email protected]/dist/js/bootstrap-material-design.js" integrity="sha384-CauSuKpEqAFajSpkdjv3z9t8E7RlpJ1UP0lKM/+NdtSarroVKu069AlsRPKkFBz9" crossorigin="anonymous"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<script src= "https://player.twitch.tv/js/embed/v1.js"></script>
<style>
@keyframes rotation {
from {
transform: rotate(0deg);
}
to {
transform: rotate(359deg);
}
}
</style>
</head>
<body>
<main>
<div id="inpForm">
<div class="container">
<div class="row">
<div class="col-sm-1">
</div>
<div class="col-sm-10" style="text-align: center;">
<img src="HighlightReel.png" style="max-height: 300px;">
<h5 style="margin-bottom: 100px;">Programmatically generated highlights from <i class="fab fa-twitch"></i> streams.</h5>
</div>
<div class="col-sm-1">
</div>
</div>
<div class="row">
<div class="col-sm-1">
</div>
<div class="col-sm-7">
<div class="form-group">
<input type="url" placeholder="392794181" id="vodurl" class="form-control">
<small class="form-text text-muted">VOD URL</small>
</div>
</div>
<div class="col-sm-3">
<button class="btn btn-lg btn-raised btn-primary" onclick="startQuery();">Make Reel</button>
</div>
<div class="col-sm-1">
</div>
</div>
</div>
</div>
<div id="loading">
<div class="container">
<div class="row">
<div class="col-sm-1">
</div>
<div class="col-sm-10" style="text-align: center;">
<img src="reelblue.png" style="max-height: 145px; margin-top: 55px; animation: rotation 2s infinite linear;">
<h5 style="margin-top: 50px;">
Downloading and Processing Chat Log
</h5>
</div>
<div class="col-sm-1">
</div>
</div>
</div>
</div>
<div id="twitch">
<div class="container">
<div class="row">
<div class="col-sm-1">
</div>
<div class="col-sm-10" style="text-align: center;">
<a href="/">
<img src="text.png" style="margin: 50px 0;">
</a>
<div style="margin-bottom: 20px;"id="playa"></div>
<div class="alert alert-success" role="alert">
Success! The important sections of the video are given
below.
</div>
<div id="timestamps"></div>
</div>
<div class="col-sm-1">
</div>
</div>
</div>
</div>
</main>
<script>
$("#loading").hide();
// $("#inpForm").hide();
$("#twitch").hide();
var videoID = "392794181";
var timestamps = [[100, 110], [360, 362], [560, 600]];
var player;
var clicked = 0;
// onCallBack(videoID, timestamps);
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie !== '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
function startQuery() {
var csrftoken = getCookie('csrftoken');
$.ajax({
url: "/video/"+$("#vodurl").val()+'/',
type: "POST",
data: {
csrftoken: csrftoken
},
dataType: "json",
success: function(data) { onCallBack($("#vodurl").val(),data)}
});
$("#inpForm").hide();
$("#loading").show();
//setTimeout(function() { onCallBack(videoID, timestamps); }, 2000);
};
function onCallBack(videoID, timeArray) {
$("#loading").hide();
$("#twitch").show();
var options = {
width: 600,
height: 300,
video: videoID,
};
var timeZero = -1; // initial time
player = new Twitch.Player("playa", options);
timeArray.forEach(function(time) {
if (timeZero == -1)
timeZero = time[0];
var timeStart = time[0];
var timeEnd = time[1];
var b = document.createElement("button");
b.className += " btn btn-outline-primary";
b.style.marginRight = "10px";
b.timeStart = timeStart;
b.timeEnd = timeEnd;
var date = new Date(null);
date.setSeconds(timeStart); // specify value for SECONDS here
var result = date.toISOString().substr(11, 8);
b.innerHTML = result;
b.addEventListener("click", function() {
clicked = 1;
player.seek(timeStart);
});
document.getElementById("timestamps").appendChild(b);
});
// document.getElementById("timestamps").childNodes[0].click();
player.setQuality(player.getQualities(4));
//player.seek(document.getElementById("timestamps").childNodes[0].timeStart);
//console.log(document.getElementById("timestamps").childNodes[0].timeStart);
window.setInterval(runEverySec, 1000);
}
var lastButton = 0;
function runEverySec() {
if (clicked == 1) {
var cTime = player.getCurrentTime();
var insideATime = 0;
var count = 0;
var childNodes = document.getElementById("timestamps").childNodes;
for (var i = 0; i < childNodes.length; i++) {
if (childNodes[i].timeStart < cTime && childNodes[i].timeEnd > cTime) {
insideATime = 1;
childNodes[i].className = "btn btn-raised btn-primary";
lastButton = i;
}
if (!(childNodes[i].timeStart < cTime && childNodes[i].timeEnd > cTime)) {
childNodes[i].className = "btn btn-outline-primary";
count += 1;
}
};
if (count == childNodes.length) {
if (lastButton < lastButton.length - 1);
console.log(lastButton + 1);
player.seek(childNodes[lastButton + 1].timeStart);
}
}
}
</script>
</body>
</html>