This repository has been archived by the owner on Jan 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
results.php
executable file
·377 lines (339 loc) · 24 KB
/
results.php
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<?php
// init twig services
require __DIR__ . '/vendor/autoload.php';
use Twig\Environment;
use Twig\Loader\FilesystemLoader;
$loader = new FilesystemLoader(__DIR__ . '/templates');
$twig = new Environment($loader);
include("includes/youtubei/search.php");
include("includes/config.inc.php");
if (!isset($_GET['search'])) {
echo $twig->render("noquery.html.twig");
} else {
$query = $_GET['search'];
$mainResponseObject = json_decode(requestSearch($query));
// search "refinements" (aka other suggestions)
if (isset($mainResponseObject->refinements)) {
$refinements = $mainResponseObject->refinements;
}
// start parsing search results (creepy)
if (isset($mainResponseObject->contents->twoColumnSearchResultsRenderer->primaryContents->sectionListRenderer->contents[0]->itemSectionRenderer->contents)) {
$items = $mainResponseObject->contents->twoColumnSearchResultsRenderer->primaryContents->sectionListRenderer->contents[0]->itemSectionRenderer->contents;
// check if this is "did you mean"
$arr = 0;
if (isset($items[0]->didYouMeanRenderer)) {
// start from element 1
$arr = 1;
}
// also skip channels
elseif (isset($items[0]->channelRenderer)) {
$arr = 1;
}
// we wanna find out how many results are there
// so that we can prevent looping too much if there's
// less than desired amount of results
if (sizeof($items) <= $resultsCount) {
$loopRounds = sizeof($items);
} else {
$loopRounds = $resultsCount;
}
// ok we done here now go to the HTML section below...
} else {
require('includes/html/noresults.php');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>YouTube - Broadcast Yourself.</title>
<link rel="stylesheet" type="text/css" href="yts/cssbin/styles.css">
<link rel="icon" href="yts/imgbin/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="yts/imgbin/favicon.ico" type="image/x-icon">
<link rel="alternate" type="application/rss+xml" title="YouTube - Recently Added Videos [RSS]" href="http://www.youtube.com/rss/global/recently_added.rss">
<script type="text/javascript">
onLoadFunctionList = new Array();
function performOnLoadFunctions() {
for (var i in onLoadFunctionList) {
onLoadFunctionList[i]();
}
}
</script>
<meta name="description" content="Share your videos with friends and family">
<meta name="keywords" content="video,sharing,camera phone,video phone">
</head>
<body onload="performOnLoadFunctions();">
<table width="800" cellspacing="0" cellpadding="0" border="0" align="center">
<tbody>
<tr>
<td style="padding-bottom: 25px;" bgcolor="#FFFFFF">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr valign="top">
<td rowspan="2" style="padding: 0px 5px 5px 5px;" width="130"><a href="/index.php"><img src="yts/imgbin/logo_sm.gif" alt="YouTube" style="vertical-align: middle; " width="120" height="48" border="0"></a></td>
<td valign="top">
<table width="670" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr valign="top">
<td style="padding: 0px 5px 0px 5px; font-style: italic;">Upload, tag and share your videos worldwide!</td>
<td align="right">
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td><a href="/signup.php"><strong>Sign Up</strong></a></td>
<td style="padding: 0px 5px 0px 5px;">|</td>
<td><a href="/login.php">Log In</a></td>
<td style="padding: 0px 5px 0px 5px;">|</td>
<td style="padding-right: 5px;"><a href="/help.php">Help</a></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr valign="bottom">
<td>
<!-- tab table -->
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td>
<table style="background-color: #DDDDDD; margin: 5px 2px 1px 0px; border-bottom: 1px solid #DDDDDD;" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td><img src="yts/imgbin/box_login_tl.gif" width="5" height="5"></td>
<td><img src="yts/imgbin/pixel.gif" width="1" height="5"></td>
<td><img src="yts/imgbin/box_login_tr.gif" width="5" height="5"></td>
</tr>
<tr>
<td><img src="yts/imgbin/pixel.gif" width="5" height="1"></td>
<td style="padding: 0px 20px 5px 20px; font-size: 13px; font-weight: bold;"><a href="/index.php">Home</a></td>
<td><img src="yts/imgbin/pixel.gif" width="5" height="1"></td>
</tr>
</tbody>
</table>
</td>
<td>
<table style="background-color: #BECEEE; margin: 5px 2px 1px 0px;" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td><img src="yts/imgbin/box_login_tl.gif" width="5" height="5"></td>
<td><img src="yts/imgbin/pixel.gif" width="1" height="5"></td>
<td><img src="yts/imgbin/box_login_tr.gif" width="5" height="5"></td>
</tr>
<tr>
<td><img src="yts/imgbin/pixel.gif" width="5" height="1"></td>
<td style="padding: 0px 20px 5px 20px; font-size: 13px; font-weight: bold;"><a href="/browse.php">Videos</a></td>
<td><img src="yts/imgbin/pixel.gif" width="5" height="1"></td>
</tr>
</tbody>
</table>
</td>
<td>
<table style="background-color: #BECEEE; margin: 5px 2px 1px 0px;" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td><img src="yts/imgbin/box_login_tl.gif" width="5" height="5"></td>
<td><img src="yts/imgbin/pixel.gif" width="1" height="5"></td>
<td><img src="yts/imgbin/box_login_tr.gif" width="5" height="5"></td>
</tr>
<tr>
<td><img src="yts/imgbin/pixel.gif" width="5" height="1"></td>
<td style="padding: 0px 20px 5px 20px; font-size: 13px; font-weight: bold;"><a href="/channels">Channels</a></td>
<td><img src="yts/imgbin/pixel.gif" width="5" height="1"></td>
</tr>
</tbody>
</table>
</td>
<td>
<table style="background-color: #BECEEE; margin: 5px 2px 1px 0px;" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td><img src="yts/imgbin/box_login_tl.gif" width="5" height="5"></td>
<td><img src="yts/imgbin/pixel.gif" width="1" height="5"></td>
<td><img src="yts/imgbin/box_login_tr.gif" width="5" height="5"></td>
</tr>
<tr>
<td><img src="yts/imgbin/pixel.gif" width="5" height="1"></td>
<td style="padding: 0px 20px 5px 20px; font-size: 13px; font-weight: bold;"><a href="/my_friends.php">Friends</a></td>
<td><img src="yts/imgbin/pixel.gif" width="5" height="1"></td>
</tr>
</tbody>
</table>
</td>
<td>
<table style="background-color: #BECEEE; margin: 5px 2px 1px 0px;" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td><img src="yts/imgbin/box_login_tl.gif" width="5" height="5"></td>
<td><img src="yts/imgbin/pixel.gif" width="1" height="5"></td>
<td><img src="yts/imgbin/box_login_tr.gif" width="5" height="5"></td>
</tr>
<tr>
<td><img src="yts/imgbin/pixel.gif" width="5" height="1"></td>
<td style="padding: 0px 20px 5px 20px; font-size: 13px; font-weight: bold;"><a href="/my_videos_upload.php">Upload</a></td>
<td><img src="yts/imgbin/pixel.gif" width="5" height="1"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table style="margin-bottom: 10px;" width="800" cellspacing="0" cellpadding="0" border="0" bgcolor="#DDDDDD" align="center">
<tbody>
<tr>
<td><img src="yts/imgbin/box_login_tl.gif" width="5" height="5"></td>
<td><img src="yts/imgbin/pixel.gif" width="1" height="5"></td>
<td><img src="yts/imgbin/box_login_tr.gif" width="5" height="5"></td>
</tr>
<tr>
<td><img src="yts/imgbin/pixel.gif" width="5" height="1"></td>
<td style="padding: 2px;" width="790" align="center">
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td style="font-size: 10px;"> </td>
<td><a href="/my_videos.php">My Videos</a></td>
<td style="padding: 0px 10px 0px 10px;">|</td>
<td><a href="/my_favorites.php">My Favorites</a></td>
<td style="padding: 0px 10px 0px 10px;">|</td>
<td><a href="/my_messages.php">My Messages</a></td>
<td style="padding: 0px 10px 0px 10px;">|</td>
<td><a href="/subscription_center">My Subscriptions</a></td>
<td style="padding: 0px 10px 0px 10px;">|</td>
<td><a href="/pl_manager">My Playlists</a></td>
<td style="padding: 0px 10px 0px 10px;">|</td>
<td><a href="/my_profile.php">My Profile</a></td>
<td style="font-size: 10px;"> </td>
</tr>
</tbody>
</table>
</td>
<td><img src="yts/imgbin/pixel.gif" width="5" height="1"></td>
</tr>
<tr>
<td style="border-bottom: 1px solid #FFFFFF"><img src="yts/imgbin/box_login_bl.gif" width="5" height="5"></td>
<td style="border-bottom: 1px solid #BBBBBB"><img src="yts/imgbin/pixel.gif" width="1" height="5"></td>
<td style="border-bottom: 1px solid #FFFFFF"><img src="yts/imgbin/box_login_br.gif" width="5" height="5"></td>
</tr>
</tbody>
</table>
<table style="margin-bottom: 10px;" cellspacing="0" cellpadding="0" border="0" align="center">
<tbody>
<tr>
<form name="searchForm" id="searchForm" method="get" action="results.php">
<td style="padding-right: 5px;"><input tabindex="1" type="text" name="search" maxlength="128" value="<?php echo htmlspecialchars($_GET['search']); ?>" style="color:#ff3333; font-size: 12px; width: 300px;"></td>
<td>
<input type="submit" name="search_videos" value="Search Videos">
</form>
</td>
</tr>
</tbody>
</table>
<div style="color: #333; margin-bottom: 10px;">Related Tags:
<?php
if (isset($refinements)) {
foreach ($refinements as $refinement) {
?>
<a href="results.php?search=<?php echo $refinement; ?>"><?php echo $refinement; ?></a>
<?php
}
}
?>
</div>
<table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#CCCCCC" align="center">
<tbody>
<tr>
<td><img src="yts/imgbin/box_login_tl.gif" width="5" height="5"></td>
<td width="100%"><img src="yts/imgbin/pixel.gif" width="1" height="5"></td>
<td><img src="yts/imgbin/box_login_tr.gif" width="5" height="5"></td>
</tr>
<tr>
<td><img src="yts/imgbin/pixel.gif" width="5" height="1"></td>
<td>
<?php
for ($i = $arr; $i < $loopRounds; $i++) {
// declare vars
// the array format used in watch.php is too annoying
// so everything is it's own variable now! yay!
if (isset($items[$i]->videoRenderer)) {
$videoId = $items[$i]->videoRenderer->videoId;
$videoTitle = $items[$i]->videoRenderer->title->runs[0]->text;
//$videoDescription = $items[$]->videoRenderer->
$videoThumbnail = $items[$i]->videoRenderer->thumbnail->thumbnails[0]->url;
$videoAuthor = $items[$i]->videoRenderer->longBylineText->runs[0]->text;
$videoViews = $items[$i]->videoRenderer->viewCountText->simpleText;
$videoRuntime = $items[$i]->videoRenderer->lengthText->simpleText;
$videoUploadTime = $items[$i]->videoRenderer->publishedTimeText->simpleText;
$authorChannelId = $items[$i]->videoRenderer->longBylineText->runs[0]->navigationEndpoint->browseEndpoint->browseId;
?>
<div class="moduleEntry">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr valign="top">
<td>
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td><a href="watch.php?v=<?php echo $videoId; ?>&search=youtube"><img src="<?php echo $videoThumbnail; ?>" class="moduleEntryThumb" width="100" height="75"></a></td>
</tr>
</tbody>
</table>
</td>
<td width="100%">
<div class="moduleEntryTitle"><a href="watch.php?v=<?php echo $videoId; ?>&search=youtube"><?php echo $videoTitle; ?></a></div>
<div class="moduleEntryDescription">I think YouTube is very exciting.</div>
<div class="moduleEntryTags">
Tags // <a href="/results.php?search=professor">professor</a> : <a href="/results.php?search=mind">mind</a> : <a href="/results.php?search=secrets">secrets</a> : <a href="/results.php?search=cannabis">cannabis</a>
</div>
<div class="moduleEntryDetails">Channels // <a href="/channels_portal.php?c=3">Education & Instructional</a> : <a href="/channels_portal.php?c=8">Hobbies & Interests</a> : <a href="/channels_portal.php?c=9">Humor</a>
</div>
<div class="moduleEntryDetails">Added: <?php echo $videoUploadTime; ?> by <a href="profile.php?id=<?php echo $authorChannelId; ?>"><?php echo $videoAuthor; ?></a></div>
<div class="moduleEntryDetails">Runtime: <?php echo $videoRuntime; ?> | Views: <?php echo $videoViews; ?> | Comments: 0</div>
</td>
</tr>
</tbody>
</table>
</div>
<?php
} elseif (isset($items[$i]->channelRenderer)) {
$i += 1;
}
?>
<?php
}
?>
<!-- begin paging -->
<div style="font-size: 13px; font-weight: bold; color: #444; text-align: right; padding: 5px 0px 5px 0px;">
Results Page:
<span style="color: #444; background-color: #FFFFFF; padding: 1px 4px 1px 4px; border: 1px solid #999; margin-right: 5px;">1</span>
</div>
<!-- end paging -->
</td>
<td><img src="yts/imgbin/pixel.gif" width="5" height="1"></td>
</tr>
<tr>
<td><img src="yts/imgbin/box_login_bl.gif" width="5" height="5"></td>
<td><img src="yts/imgbin/pixel.gif" width="1" height="5"></td>
<td><img src="yts/imgbin/box_login_br.gif" width="5" height="5"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<?php include("includes/html/footer.php") ?>
</body>
</html>
<?php
}
// end file
?>