-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathccc.php
165 lines (146 loc) · 4.33 KB
/
ccc.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
<?php
#------------------------------------------
# Plugin for WDTV Live
# Recordings from CCC events. Profit
#
# @author Ricardo Ribalda
# @version 0.1
# @date 13/01/2011
#
#------------------------------------------
include ('funciones.php');
function _pluginCreateEventList() {
$queryData= array();
$events= array (
array(
"name" => "22C3",
"ico" => "http://oi52.tinypic.com/23lnlzt.jpg",
"url" => "http://mirror.fem-net.de/CCC/22C3/video/",
),
array(
"name" => "23C3",
"ico" => "http://oi54.tinypic.com/2hgftdj.jpg",
"url" => "http://mirror.fem-net.de/CCC/23C3/video/",
),
array(
"name" => "24C3",
"ico" => "http://oi53.tinypic.com/ieo7xz.jpg",
"url" => "http://mirror.fem-net.de/CCC/24C3/mp4/",
),
array(
"name" => "25C3",
"ico" => "http://oi56.tinypic.com/aw9jet.jpg",
"url" => "http://mirror.fem-net.de/CCC/25C3/video_h264_720x576/",
),
array(
"name" => "26C3",
"ico" => "http://oi52.tinypic.com/29oljxx.jpg",
"url" => "http://mirror.fem-net.de/CCC/26C3/mp4/",
),
array(
"name" => "27C3",
"ico" => "http://oi51.tinypic.com/211m1w2.jpg",
"url" => "http://mirror.fem-net.de/CCC/27C3/mp4-h264-HQ/",
),
array(
"name" => "CCCamp07",
"ico" => "http://oi53.tinypic.com/zjcew7.jpg",
"url" => "http://mirror.fem-net.de/CCC/CCCamp07/video/m4v/",
),
array(
"name" => "SIGINT09",
"ico" => "http://oi55.tinypic.com/2n6yfyb.jpg",
"url" => "http://mirror.fem-net.de/CCC/sigint09/video/",
),
array(
"name" => "LoungeMusic-27C3",
"ico" => "http://oi51.tinypic.com/2mzjswy.jpg",
"url" => "http://breitband.ccc.de/27c3/lounge/mp3/",
),
);
foreach ($events as $event){
$aux=array(
"station_url"=>$event["url"],
);
$retMediaItems[]=array(
"id" => 'umsp://plugins/ccc?'.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("/mp4$/i",$link))||
(preg_match("/m4v$/i",$link))))
continue;
$title=$link;
$ico="http://oi56.tinypic.com/245bx4m.jpg";
$album="CCC Event";
//Parse filename if possible
if (preg_match("/([^_-]*)[_-]([^_-]*)[-_]([de][en])[-_](.*)....$/i",$link,$ma)){
$album=$ma[1];
if ($ma[3]=="de")
$ico="http://oi56.tinypic.com/14j55x1.jpg";
else
$ico="http://oi54.tinypic.com/dpzpc2.jpg";
$title=ucfirst(strtr($ma[4],"_-"," "));
if (preg_match("/(.*) COMPATIBLE$/",$title,$ma))
$title=$ma[1];
}
else if (preg_match("/([^_-]*)[_-]([de][en])[-_]([^_-]*)[-_](.*)....$/i",$link,$ma)){
$album=$ma[1];
if ($ma[2]=="de")
$ico="http://oi56.tinypic.com/14j55x1.jpg";
else
$ico="http://oi54.tinypic.com/dpzpc2.jpg";
$title=ucfirst(strtr($ma[4],"_-"," "));
}
else if (preg_match("/^27c3_Lounge_(.*)....$/i",$link,$ma)){
$title=ucfirst(strtr($ma[1],"_-"," "));
}
$retMediaItem=array();
$retMediaItem["id"] = 'umsp://plugins/ccc?'.urlencode($link);
$retMediaItem["dc:title"]=$title;
$retMediaItem["res"]=$url.$link;
$retMediaItem["upnp:album_art"]=$ico;
$retMediaItem["upnp:author"]= "Chaos Computer Club";
$retMediaItem["upnp:album"]= $album;
if ((preg_match("/mp4$/i",$link))||(preg_match("/m4v$/i",$link))){
$retMediaItem["protocolInfo"]='http-get:*:video/mpeg:*';
$retMediaItem["upnp:class"]='object.item.videoItem';
}
if (preg_match("/mp3$/i",$link)){
$retMediaItem["res"]="http://localhost/umsp/plugins/mp3-proxy.php?itemURL=".$url.$link;
$retMediaItem["protocolInfo"]='http-get:*:audio/mpeg:*';
$retMediaItem["upnp:class"]='object.item.audioItem';
}
$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://mirror.fem-net.de/CCC/23C3/video/"));
?>