-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathmod_channel_info_dev.php
executable file
·164 lines (125 loc) · 3.99 KB
/
mod_channel_info_dev.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
<?php
if(isset($_GET["mode"])) { $_POST = $_GET; }
include("html_head.php");
?>
<div class="rowTab">
<div class="sectionTab">
<h1>Channel Info Module</h1>
</div>
</div>
<div class="rowTab">
<div class="fullTab">
<p>This module retrieves different kinds of information for a channel from the <a href="https://developers.google.com/youtube/v3/docs/channels/list" target="_blank">channels/list</a> API endpoint
from a specified channel id or channel URL. The following resources are requested: brandingSettings, status, id, snippet, contentDetails, statistics, and topicDetails.</p>
<p>Output is a direct print of the API response.</p>
</div>
</div>
<div class="rowTab">
<div class="sectionTab"><h1>Parameters</h1></div>
</div>
<div class="rowTab">
<div class="sectionTab"><h2>The channel(s) to investigate:</h2></div>
</div>
<form action="mod_channel_info_dev.php" method="post">
<div class="rowTab">
<div class="oneTab"></div>
<div class="twoTab">Channel id or URL:</div>
<div class="threeTab">
<input name="hash" value="<?php if(isset($_POST["hash"])) { echo $_POST["hash"]; } ?>" />
</div>
<div class="fourTab">(e.g. "https://www.youtube.com/@BernhardRiederAmsterdam/" or "UCtxGqPJPPi8ptAzB029jpYA")</div>
</div>
<div class="rowTab">
<div class="sectionTab"><h2>Run:</h2></div>
</div>
<div class="rowTab">
<div class="oneTab">
<div class="g-recaptcha" data-sitekey="6Lf093MUAAAAAIRLVzHqfIq9oZcOnX66Dju7e8sr"></div>
</div>
</div>
<div class="rowTab">
<div class="oneTab"><input type="submit" /></div>
</div>
</form>
<?php
if(isset($_POST["hash"])) {
echo '<div class="rowTab">
<div class="sectionTab"><h1>Results</h1></div>
</div>
<div class="rowTab">';
if($_POST["hash"] == "") {
echo "Missing channel id.";
exit;
}
if(RECAPTCHA) {
if($_POST["g-recaptcha-response"] == "") {
echo "Recaptcha missing.";
exit;
}
testcaptcha($_POST["g-recaptcha-response"]);
}
$hash = $_POST["hash"];
if(preg_match("/http/", $hash)) {
$restquery = "https://www.googleapis.com/youtube/v3/search?part=snippet&q=". urlencode($hash)."&type=channel&fields=items(id(kind,channelId))";
$reply = doAPIRequest($restquery);
$hash = $reply->items[0]->id->channelId;
}
getInfo($hash);
}
function getInfo($hash) {
$restquery = "https://www.googleapis.com/youtube/v3/channels?part=brandingSettings,status,id,snippet,contentDetails,statistics,topicDetails&id=".$hash;
$reply = doAPIRequest($restquery);
echo '<table class="resulttable">';
foreach($reply->items[0] as $key => $var) {
echo '<tr class="resulttable">';
echo '<td class="resulttableHi"><b>'.$key.'</b></td>';
if(gettype($var) != "object" && gettype($var2) != "array") {
echo '<td class="resulttable">'.$var.'</td>';
} else {
echo '<td class="resulttable">';
echo '<table style="display:inline">';
foreach($var as $key2 => $var2) {
echo '<tr>';
echo '<td><b>'.$key2.'</b></td>';
if(gettype($var2) != "object" && gettype($var2) != "array") {
echo '<td>'.$var2.'</td>';
} else {
echo '<td class="resulttable">';
echo '<table style="display:inline">';
foreach($var2 as $key3 => $var3) {
echo '<tr>';
echo '<td><b>'.$key3.'</b></td>';
if(gettype($var3) != "object" && gettype($var3) != "array") {
echo '<td>'.$var3.'</td>';
} else {
echo '<td class="resulttable">';
echo '<table style="display:inline">';
foreach($var3 as $key4 => $var4) {
echo '<tr>';
echo '<td><b>'.$key4.'</b></td>';
if(gettype($var4) != "object" && gettype($var) != "array") {
echo '<td>'.$var4.'</td>';
} else {
echo '<td>'.$var4.'</td>';
}
echo '</tr>';
}
echo '</table>';
echo '</td>';
}
echo '</tr>';
}
echo '</table>';
echo '</td>';
}
echo '</tr>';
}
echo '</table>';
echo '</td>';
}
echo '</tr>';
}
echo '</table></div>';
}
?>
<?php include("html_foot.php"); ?>