-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefcon.php
240 lines (218 loc) · 7.43 KB
/
defcon.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
<?php
#------------------------------------------
# Plugin for WDTV Live
# Recordings from Defcon events. Profit
#
# @author Ricardo Ribalda
# @version 0.1
# @date 13/01/2011
#
#------------------------------------------
include ('funciones.php');
function _pluginCreateEventList() {
$queryData= array();
$events= array (
array(
"name" => "DEF CON 1",
"ico" => "http://defcon.org/images/defcon-1/defcon-1-logo-1.jpg",
"url" => "http://defcon.org/html/links/dc-archives/dc-1-archive.html",
),
array(
"name" => "DEF CON 2",
"ico" => "http://defcon.org/images/defcon-2/defcon-2-logo-1.jpg",
"url" => "http://defcon.org/html/links/dc-archives/dc-2-archive.html",
),
array(
"name" => "DEF CON 3",
"ico" => "http://defcon.org/images/defcon-3/defcon-3-logo-1.jpg",
"url" => "http://defcon.org/html/links/dc-archives/dc-3-archive.html",
),
array(
"name" => "DEF CON 4",
"ico" => "http://defcon.org/images/defcon-4/defcon-4-logo-1.jpg",
"url" => "http://defcon.org/html/links/dc-archives/dc-4-archive.html",
),
array(
"name" => "DEF CON 5",
"ico" => "http://defcon.org/images/defcon-5/dc-5-31.jpg",
"url" => "http://defcon.org/html/links/dc-archives/dc-5-archive.html",
),
array(
"name" => "DEF CON 6",
"ico" => "http://defcon.org/images/defcon-6/dc6-logob.jpg",
"url" => "http://defcon.org/html/links/dc-archives/dc-6-archive.html",
),
array(
"name" => "DEF CON 7",
"ico" => "http://defcon.org/images/defcon-7/dc7logoblack-header.jpg",
"url" => "http://defcon.org/html/links/dc-archives/dc-7-archive.html",
),
array(
"name" => "DEF CON 8",
"ico" => "http://defcon.org/images/defcon-8/dc-8-pill.jpg",
"url" => "http://defcon.org/html/links/dc-archives/dc-8-archive.html",
),
array(
"name" => "DEF CON 9",
"ico" => "http://defcon.org/images/defcon-9/dc9-archive-logo.jpg",
"url" => "http://defcon.org/html/links/dc-archives/dc-9-archive.html",
),
array(
"name" => "DEF CON 10",
"ico" => "http://defcon.org/images/defcon-10/dc-0A-badge-inv.jpg",
"url" => "http://defcon.org/html/links/dc-archives/dc-10-archive.html",
),
array(
"name" => "DEF CON 11",
"ico" => "http://defcon.org/images/defcon-11/dc-11-badge/dc-11-badge.jpg",
"url" => "http://defcon.org/html/links/dc-archives/dc-11-archive.html",
),
array(
"name" => "DEF CON 12",
"ico" => "http://defcon.org/images/defcon-12/dc12-badge2.jpg",
"url" => "http://defcon.org/html/links/dc-archives/dc-12-archive.html",
),
array(
"name" => "DEF CON 13",
"ico" => "http://defcon.org/images/defcon-13/dc13-badges/dc-13-badge-cu.jpg",
"url" => "http://defcon.org/html/links/dc-archives/dc-13-archive.html",
),
array(
"name" => "DEF CON 14",
"ico" => "http://defcon.org/images/defcon-14/dc-14-sm.jpg",
"url" => "http://defcon.org/html/links/dc-archives/dc-14-archive.html",
),
array(
"name" => "DEF CON 15",
"ico" => "http://defcon.org/images/defcon-15/dc-15-archive.jpg",
"url" => "http://defcon.org/html/links/dc-archives/dc-15-archive.html",
),
array(
"name" => "DEF CON 16",
"ico" => "http://defcon.org/images/defcon-16/dc-16-logo.png",
"url" => "http://defcon.org/html/links/dc-archives/dc-16-archive.html",
),
array(
"name" => "DEF CON 17",
"ico" => "http://defcon.org/images/defcon-17/dc-17-logo.png",
"url" => "http://defcon.org/html/links/dc-archives/dc-17-archive.html",
),
array(
"name" => "DEF CON 18",
"ico" => "http://defcon.org/images/defcon-18/dc-18-logo_smsq.png",
"url" => "http://defcon.org/html/links/dc-archives/dc-18-archive.html",
),
);
foreach ($events as $event){
$aux=array(
"station_url"=>$event["url"],
);
$retMediaItems[]=array(
"id" => 'umsp://plugins/defcon?'.http_build_query($aux,'pluginvar_'),
"dc:title" => $event["name"],
"upnp:album_art" => $event["ico"],
"upnp:class" => "object.container",
);
}
return $retMediaItems;
}
function _pluginCreateEventItems($url){
$indexfile=file($url);
//Find links
$links=array();
foreach ($indexfile as $line){
if (preg_match_all("/href=\"([^\"]+)\"/i",$line,$hrefs)){
foreach ($hrefs[1] as $href)
$links[]=$href;
}
}
$retMediaItems=array();
foreach ($links as $link){
//Select only media files
if (!((preg_match("/mp3$/i",$link))||
(preg_match("/m4b$/i",$link))||
(preg_match("/rm$/i",$link))||
(preg_match("/mp4$/i",$link))||
(preg_match("/m4v$/i",$link))))
continue;
//hhtps->http
$link=preg_replace("/^https/","http",$link);
//Create title
preg_match("/\/([^\/]*)$/i",$link,$ma);
$file=$ma[1];
preg_match("/(.*)\....?$/i",$file,$ma);
$file=$ma[1];
$album="DefCon";
$author="Electronic Frontier Fundation";
$title=ucfirst(strtr($file,"_-"," "));
if (preg_match("/^DEF *CON ([^ ]+) Hacking Conference Presentation By -* *([^-]*) - (.*)$/i",$file,$ma)){
$album="DefCon".$ma[1];
$author=ucfirst(strtr($ma[2],"_-"," "));
$title=ucfirst(strtr($ma[3],"_-"," "));
}
else if (preg_match("/^Defcon([^-]+)-([^-]+)-(.*)$/i",$file,$ma)){
$album="DefCon".$ma[1];
$author=ucfirst(strtr($ma[2],"_-"," "));
$title=ucfirst(strtr($ma[3],"_-"," "));
}
else if (preg_match("/[^-]*-Defcon_([^-]+)-v[^-]*-([^-]+)-(.*)$/i",$file,$ma)){
$album="DefCon".$ma[1];
$author=ucfirst(strtr($ma[2],"_-"," "));
$title=ucfirst(strtr($ma[3],"_-"," "));
}
else if (preg_match("/[^-]*-Defcon_([^-]+)-[^-]+-([^-]+)-(.*)$/i",$file,$ma)){
$album="DefCon".$ma[1];
$author=ucfirst(strtr($ma[2],"_-"," "));
$title=ucfirst(strtr($ma[3],"_-"," "));
}
else if (preg_match("/([^_-]*)[_-]Defcon[^-]+-([^-]+)-(.*)$/i",$file,$ma)){
$album=$ma[1]." DefCon";
$author=ucfirst(strtr($ma[2],"_-"," "));
$title=ucfirst(strtr($ma[3],"_-"," "));
}
else if (preg_match("/([^ ]*) Defcon V[^ ]+ - ([^-]+) - (.*)$/i",$file,$ma)){
$album=$ma[1]." DefCon";
$author=ucfirst(strtr($ma[2],"_-"," "));
$title=ucfirst(strtr($ma[3],"_-"," "));
}
else if (preg_match("/dc-([^-]*)-(.*)$/i",$file,$ma)){
$album="DefCon".$ma[1];
$title=ucfirst(strtr($ma[2],"_-"," "));
}
else if (preg_match("/([^_]*)_Defcon_v[^-]*-([^-]+)-(.*)$/i",$file,$ma)){
$album=$ma[1]." DefCon";
$author=ucfirst(strtr($ma[2],"_-"," "));
$title=ucfirst(strtr($ma[3],"_-"," "));
}
$retMediaItem=array();
if ((preg_match("/mp4$/i",$link))||(preg_match("/m4v$/i",$link))){
$retMediaItem["res"]=$link;
$retMediaItem["protocolInfo"]='http-get:*:video/mpeg:*';
$retMediaItem["upnp:class"]='object.item.videoItem';
}
if ((preg_match("/mp3$/i",$link))||(preg_match("/m4b$/i",$link))||(preg_match("/rm$/i",$link))){
$retMediaItem["res"]=$link;
//$retMediaItem["res"]="http://localhost/umsp/plugins/mp3-proxy.php?itemURL=".$link;
$retMediaItem["protocolInfo"]='http-get:*:audio/mpeg:*';
$retMediaItem["upnp:class"]='object.item.audioItem';
}
$retMediaItem["id"] = 'umsp://plugins/defcon?'.urlencode($link);
$retMediaItem["dc:title"]=$title;
//$retMediaItem["dc:title"]=$link;
$retMediaItem["upnp:author"]= $author;
$retMediaItem["upnp:album"]= $album;
$retMediaItems[]=$retMediaItem;
}
return $retMediaItems;
}
function _pluginMain($prmQuery){
$queryData=array();
parse_str($prmQuery,$queryData);
if (isset($queryData['station_url'])){
return _pluginCreateEventItems($queryData['station_url']);
}
return _pluginCreateEventList();
}
//print_r(_pluginMain(""));
//print_r(_pluginCreateEventItems("http://defcon.org/html/links/dc-archives/dc-1-archive.html"));
?>