-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex_old.php
449 lines (398 loc) · 14.2 KB
/
index_old.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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="icon" href="images/favicon.ico">
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=VT323">
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Calligraffitti">
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu:regular,bold&subset=Latin">
<link href="http://fonts.googleapis.com/css?family=Cabin+Sketch:bold" rel="stylesheet" type="text/css" >
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="text/html;" http-equiv="Content-Type" />
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />
<title>Groove-PHP</title>
<style type="text/css">
footer {
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
border: thin black solid;
}
#haupt {
border-left: thin black solid;
border-right: thin black solid;
}
header {
text-align:center;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
border: thin black solid;
}
#title {
font-size:20 pt;
font-family: 'Cabin Sketch';font-family:VT323;
}
</style>
</head>
<body>
<header onclick="self.location.href = 'index.php'">
<img src="images/Grooveshark.png" height="128px" width="128px" /><br />
<div id="title">We got the groove, you got the shark!</div>
</header>
<section id="haupt">
<?php
/*
Ported Python Version to PHP by Check
<check96@gmail.com>
I've not Included my pictures this would be illegal.
To Setup read the README File!
Orginal:
A Grooveshark song downloader in python
by George Stephanos <gaf.stephanos@gmail.com>
*/
// HEX
class randomColorGenerator
{
private $hexColor = array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
private $newColor = "";
private $colorBag = array();
function getColor()
{
$this->newColor= $this->hexColor[$this->genRandom()].
$this->hexColor[$this->genRandom()].
$this->hexColor[$this->genRandom()].
$this->hexColor[$this->genRandom()].
$this->hexColor[$this->genRandom()].
$this->hexColor[$this->genRandom()];
if(!in_array($this->newColor,$this->colorBag))
{
$this->colorBag[] = $this->newColor;
return $this->newColor;
}
}
function genRandom()
{
srand((float) microtime() * 10000000);
$random_col_keys = array_rand($this->hexColor, 2);
return $random_col_keys[0];
}
}
// Generate UUID
function gen_uuid() {
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
// 16 bits for "time_mid"
mt_rand( 0, 0xffff ),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
mt_rand( 0, 0x0fff ) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
mt_rand( 0, 0x3fff ) | 0x8000,
// 48 bits for "node"
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
);
}
$header = get_headers("http://www.grooveshark.com");
$id = substr($header[24],22,32);
$secretKey = md5($id);
// Strings
$Useragent = "Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1";
$Referer = "http://grooveshark.com/JSQueue.swf?20110216.04";
// Header !
$h["session"] = $id;
$h["uuid"] = gen_uuid();
$h["privacy"] = 0;
$h["Country"]["CC1"] = "0";
$h["Country"]["CC2"] = "0";
$h["Country"]["CC3"] = "0";
$h["Country"]["CC4"] = "0";
$h["Country"]["ID"] = "1";
// Get a Token /* Started here */
$p["method"] = "getCommunicationToken";
$p["parameters"]["secretKey"] = $secretKey;
$p["header"] = $h;
$p["header"]["client"] = "htmlshark";
$p["header"]["clientRevision"] = "20110606";
$opts = array(
'http'=>array(
'method'=>"POST",
'header'=>"User-Agent: $Useragent\r\n" .
"Referer: $Referer\r\n".
"Cookie: PHPSESSID=$id\r\n".
"Content-Type: application/json\r\n",
'content'=> "".json_encode($p).""
)
);
$context = stream_context_create($opts);
$file = file_get_contents('http://grooveshark.com/more.php', false, $context);
$decode = json_decode($file);
// Got TOKEN
$token = $decode->result;
/* Ends here! */
//prepToken! fixed :)
function prep_token($method,$token,$with)
{
$obj = new randomColorGenerator();
$hex2 = $obj -> getColor();
return $hex2.sha1($method.":".$token.$with.$hex2);
}
if($_POST['search'] AND $_POST['search'] != NULL)
{
$text = htmlentities(utf8_decode($_POST['searchvalue']));
echo "<center><div style='padding-top:10px;padding-bottom:10px;border-bottom:thin black solid;'>
<form action='' method='POST'>
<input type='text' name='searchvalue' value='$text' x-webkit-speech />
<input type='hidden' name='search' value='1'>
<input type='Submit' value='Search !'><br />
<a href='?rm=1'>DELETE:</a>
</form>
</div></center>";
//get Search Results EX ! /* Starts here */
$s["header"] = $h;
$s["header"]["clientRevision"] = "20110606";
$s["header"]["token"] = prep_token("getSearchResultsEx",$token,":backToTheScienceLab:");
$s["header"]["client"] = "htmlshark";
$s["method"] = "getSearchResultsEx";
$s["parameters"]["type"] = "Songs";
$s["parameters"]["query"] = "".$_POST['searchvalue']."";
$option = array(
'http'=>array(
'method'=>"POST",
'header'=>"User-Agent: $Useragent\r\n" .
"Referer: http://grooveshark.com/\r\n".
"Cookie: PHPSESSID=$id\r\n".
"Content-Type: application/json\r\n",
'content'=> "".json_encode($s).""
)
);
$contexts = stream_context_create($option);
$file2 = file_get_contents('http://grooveshark.com/more.php?getSearchResultsEx', false, $contexts);
$file2 = json_decode($file2);
while ($i < 11)
{
$ArtistID = $file2->result->result[$i-1]->ArtistID;
$SongID = $file2->result->result[$i-1]->SongID;
$Cover = $file2->result->result[$i-1]->CoverArtFilename;
$Artist = $file2->result->result[$i-1]->ArtistName;
$Album = $file2->result->result[$i-1]->AlbumName;
$Song = $file2->result->result[$i-1]->SongName;
if ($Cover != NULL)
{
echo "<br /> <img style='float:left' src='http://beta.grooveshark.com/static/amazonart/$Cover' align='top' height='70px' width='70px' /><div style='paddin-left:10px;'>Artist: $Artist <br/>
Album: $Album <br/>
Song: $Song
</div>
<div>
<form action='' method='POST'>
<input type='hidden' name='download' value='1'>
<input type='hidden' name='DownloadName' value='$Artist - $Album - $Song'>
<input type='hidden' name='SongID' value='$SongID'>
<input type='hidden' name='Song' value='$Song'>
<div style='align:right'><input type='Submit' value='Download !'></form></div>
<form action='' method='POST'>
<input type='hidden' name='ArtistSearch' value='1'>
<input type='hidden' name='ArtistID' value='$ArtistID'>
<input type='hidden' name='Artist' value='$Artist'>
<div style='align:right'><input type='Submit' value='More Songs from Artist !'></form></div></div><br />";
}
elseif ($Song != NULL)
{
echo "<br /><div style='padding-left:10px;'><form action='' method='POST'>Artist: $Artist - Album: $Album - Song: $Song
<input type='hidden' name='download' value='1'>
<input type='hidden' name='SongID' value='$SongID'>
<input type='hidden' name='DownloadName' value='$Artist - $Album - $Song'>
<div style=';align:right'><input type='Submit' value='Download'></div></form>
<form action='' method='POST'>
<input type='hidden' name='ArtistSearch' value='1'>
<input type='hidden' name='ArtistID' value='$ArtistID'>
<input type='hidden' name='Artist' value='$Artist'>
<div style='align:right'><input type='Submit' value='More Songs from Artist !'></form></div></div><br />";
}
$i++;
}
}
/* Ends Here */
/* Starts here */
elseif($_POST['download'] and $_POST['SongID'] != NULL)
{
$ps["parameters"]["mobile"] = "false";
$ps["parameters"]["prefetch"] = "false";
$ps["parameters"]["songID"] = $_POST['SongID'];
$ps["parameters"]["country"] = $h["Country"];
$ps["header"] = $h;
$ps["header"]["client"] = "jsqueue";
$ps["header"]["clientRevision"] = "20110606";
$ps["header"]["token"] = prep_token("getStreamKeyFromSongIDEx",$token,":bewareOfBearsharktopus:");
$ps["method"] = "getStreamKeyFromSongIDEx";
$optst = array(
'http'=>array(
'method'=>"POST",
'header'=>"User-Agent: $Useragent\r\n" .
"Referer: $Referer\r\n".
"Cookie: PHPSESSID=$id\r\n".
"Content-Type: application/json\r\n",
'content'=> "".json_encode($ps).""
)
);
$contextss = stream_context_create($optst);
$file4 = file_get_contents('http://grooveshark.com/more.php?getStreamKeyFromSongIDEx', false, $contextss);
if (is_dir("Songs") == false)
{
mkdir("Songs", 0777);
}
$Name = "".$_POST['DownloadName']."";
// This must not be Curl, but it's easier and cooler with curl :)
$keys = json_decode($file4);
$streamKey = $keys->result->streamKey;
$ip = $keys->result->ip;
$ch = curl_init();
$fp = fopen('Songs/'.$Name.'.mp3', "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch,CURLOPT_URL,'http://'.$ip.'/stream.php');
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, "streamKey=$streamKey");
curl_exec($ch);
curl_close($ch);
fclose($fp);
$ip = $_SERVER['SERVER_ADDR'];
// Ok, Download Complete, let's creat a simple m3u
$file = 'Songs/my.m3u';
$current = file_get_contents($file);
$current .= 'http://'.$_SERVER["HTTP_HOST"]."/Songs/".$Name.".mp3\n";
file_put_contents($file, $current);
echo "<center>
<div style='padding-bottom:10px;font-family:Ubuntu;font-size:20pt;'>
How to Download?
<br />
<div style='font-family:Ubuntu; font-size:12pt;'>
As a Stream:<br />
<audio controls='controls'>
<source src='Songs/".$Name.".mp3' type='audio/mpeg' />
</audio>
</div>
<div style='font-family:Ubuntu; font-size:12pt;'>
As a Link: <br />
<a href='Songs/".$Name.".mp3'>Download</a>
</div>
<div style='font-family:Ubuntu; font-size:12pt;'>
Or a m3u with all Songs, you've downloaded: <br />
<a href='Songs/my.m3u'>Download</a>
</div>
</div>
</center>";
/* Ends Here */
}
elseif ($_GET['rm'] == 1)
{
echo "<div>
<div style='font-family:Ubuntu;font-size:30pt;'><center>Delete:</center></div>
";
$ip = $_SERVER['SERVER_ADDR'];
if ($handle = opendir('Songs')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$gro = filesize('Songs/'.$file);
echo "<a href='Songs/".$file."'>$file</a>".", $gro<br />";
}
}
closedir($handle);
}
if($_GET['g'] == 1)
{
$File = $_GET['File'];
$unlink = unlink('Songs/'.$File);
}
else
{
echo '
<form action="" method="GET">
File ? <input type="text" name="File">
<input type="hidden" value="1" name="rm">
<input type="hidden" value="1" name="g"> <br />
<input type="Submit" value="Submit">
';
}
echo "</div>";
}
elseif($_POST['ArtistSearch'] and $_POST['ArtistID'] != NULL)
{
$p["parameters"]["artistID"] = $_POST['ArtistID'];
$p["parameters"]["isVerifiedOrPopular"] = 'isVerified';
$p["header"] = $h;
$p["header"]["client"] = "htmlshark";
$p["header"]["clientRevision"] = "20110606";
$p["header"]["token"] = prep_token("artistGetSongsEx",$token,":backToTheScienceLab:");
$p["method"] = "artistGetSongsEx";
$opts = array(
'http'=>array(
'method'=>"POST",
'header'=>"User-Agent: $Useragent\r\n" .
"Referer: $Referer\r\n".
"Cookie: PHPSESSID=$id\r\n".
"Content-Type: application/json\r\n",
'content'=> "".json_encode($p).""
)
);
$context = stream_context_create($opts);
$file = file_get_contents('http://grooveshark.com/more.php', false, $context);
$decode = json_decode($file);
while ($i < 11)
{
$ArtistID = $decode->result[$i-1]->ArtistID;
$SongID = $decode->result[$i-1]->SongID;
$Cover = $decode->result[$i-1]->CoverArtFilename;
$Artist = $decode->result[$i-1]->ArtistName;
$Album = $decode->result[$i-1]->AlbumName;
$Song = $decode->result[$i-1]->Name;
if ($Cover != NULL)
{
echo "<br /> <img style='float:left' src='http://beta.grooveshark.com/static/amazonart/$Cover' align='top' height='70px' width='70px' /><div style=''>Artist: $Artist <br/>
Album: $Album <br/>
Song: $Song
<div>
<form action='' method='POST'>
<input type='hidden' name='download' value='1'>
<input type='hidden' name='SongID' value='$SongID'>
<input type='hidden' name='DownloadName' value='$Artist - $Album - $Song'>
<input type='hidden' name='Song' value='$Song'>
<div style='align:right'><input type='Submit' value='Download !'></form></div>
</div><br />";
}
elseif ($Song != NULL)
{
echo "<br /><div style='padding-left:10px;padding-bottom:10px;'><form action='' method='POST'>Artist: $Artist - Album: $Album - Song: $Song
<input type='hidden' name='download' value='1'>
<input type='hidden' name='SongID' value='$SongID'>
<input type='hidden' name='DownloadName' value='$Artist - $Album - $Song'>
<div style=';align:right'><input type='Submit' value='Download'></div></form></div>";
}
$i++;
}
}
elseif ($_POST['search'] == false OR $_POST['search'] == NULL OR $_POST['ArtistSearch'] == false)
{
echo '<form method="POST" action="">
<!-- Just for fun -->
<center style="padding:40px;"><div style="padding-bottom:5px;"><input type="text" name="searchvalue" x-webkit-speech />
<input type="hidden" name="search" value="1">
<input type="Submit" value="Search !"></div><br />
<a href="?rm=1">DELETE:</a>
</center>';
}
else
{
echo "<pre> Sorry, not found </pre>";
}
?>
</section>
<footer>
<p><small style="padding-left:3px;font-family:Calligraffitti; font-size:12pt;">
Coded by Check in PHP. Created by George Stephanos.
<a href="http://www.groove-dl.co.cc/"> JTR's Grooveshark Downloader </a>
</small>
</p>
</footer>
</body>
</html>