forked from ChoiZ/php-playlist-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate.php
More file actions
80 lines (75 loc) · 2.82 KB
/
generate.php
File metadata and controls
80 lines (75 loc) · 2.82 KB
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
<?php
/*
* Playlist generator
*
* @version 2012-07-06T22:11:17Z (ISO-8601)
* @author François LASSERRE <choiz@me.com>·
* @license GNU GPL {@link http://www.gnu.org/licenses/gpl.html}
*/
$available_format = array('asx','m3u','pls','qtl','wax');
$radio = new stdClass;
$radio->website_url = "http://www.addictradio.net/";
$radio->stream_title = "Addict Radio Rock";
$radio->station = "addictrock";
$radio->stream_url = array(
"stream1.addictradio.net/".$radio->station.".mp3",
"stream2.addictradio.net/".$radio->station.".mp3",
"stream3.addictradio.net/".$radio->station.".mp3",
"stream4.addictradio.net/".$radio->station.".mp3",
"stream5.addictradio.net/".$radio->station.".mp3",
"stream6.addictradio.net/".$radio->station.".mp3",
);
$file = new stdClass;
$file->name = $radio->station;
$file->ext = $available_format[1];
if(isset($_GET['ext']) && $_GET['ext'] && in_array(strtolower($_GET['ext']),$format)) {
$file->ext = strtolower($_GET['ext']);
}
switch($file->ext) {
case 'asx':
header("Content-Type: audio/x-ms-asf");
header("Content-Disposition: attachment; filename=$file->name.$file->ext");
echo "<ASX Version=\"3.0\">\n<PARAM name=\"HTMLView\" value=\"$radio->website_url\" />\n";
foreach($radio->stream_url as $url) {
echo "<ENTRY>\n<REF HREF=\"http://$url\" />\n</ENTRY>\n";
}
echo "<Title>$radio->stream_title</Title>\n</ASX>";
break;
case 'm3u':
header("Content-Type: audio/x-mpegurl");
header("Content-Disposition: attachment; filename=$file->name.$file->ext");
echo "#EXTM3U";
foreach($radio->stream_url as $url) {
echo "\n#EXTINF:-1, $radio->stream_title\n$url";
}
break;
case 'pls':
header("Content-Type: audio/x-scpls");
header("Content-Disposition: attachment; filename=$file->name.$file->ext");
echo "[playlist]\nNumberOfEntries=".count($radio->stream_url)."\n";
$i=0;
foreach($radio->stream_url as $url) {
$i++;
echo "\nFile$i=http://$url\nTitle$i=$radio->stream_title\nLength$i=-1\n";
}
echo "\nVersion=2";
break;
case 'qtl':
header("Content-Type: application/x-quicktimeplayer");
header("Content-Disposition: attachment; filename=$file->name.$file->ext");
echo "<?xml version=\"1.0\"?>\n<?quicktime type=\"application/x-quicktime-media-link\"?>";
foreach($radio->stream_url as $url) {
echo "\n<embed src=\"icy://$url\" autoplay=\"true\" />";
}
break;
case 'wax':
header("Content-Type: audio/x-ms-wax");
header("Content-Disposition: attachment; filename=$file->name.$file->ext");
foreach($radio->stream_url as $url) {
echo "$url\n";
}
break;
default:
break;
}
?>