-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
126 lines (112 loc) · 5.43 KB
/
main.js
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
/*#########################################################################
# #
# Simple script shamelessly recopied from Cool Streams #
# #
# Copyright #
# (C) 2007, 2008 Nikolaj Hald Nielsen <[email protected]> #
# (C) 2008 Peter ZHOU <[email protected]> #
# (C) 2008 Mark Kretschmann <[email protected]> #
# (C) 2008 Georges Dubus <[email protected]> #
# (C) 2008 Nickolay Bunev <[email protected]> #
# (C) 2008 Andreas Wuest <[email protected]> #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the #
# Free Software Foundation, Inc., #
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #
##########################################################################*/
/*
# the following pages seem to contain a rather complete radio stream list :-)
#
# http://www.listenlive.eu/luxembourg.html
#
# http://de.delicast.com/radio/Deutschland/t:1/Fritz
# http://www.realradios.com/europe/germany
# http://www.radio-ech.de/links_r.html
# http://www.listenlive.eu/germany.html
# http://tiscali.project-fx.de/
# http://de.wikipedia.org/wiki/Hochschulradio
# http://www.antenne.de/antenne/radio/frequenzen/stream.php
*/
Importer.loadQtBinding("qt.core");
Importer.loadQtBinding("qt.gui");
function Station( name, url, homepage, favicon, logo )
{
this.name = name;
this.url = url;
this.homepage = homepage;
this.favicon = favicon;
// this.logo = logo;
this.logo = "";
}
Importer.include("sender.js");
// create after the sender.js import, so we can access the number of stations
script = new RadioLU();
script.populate.connect( onPopulating );
script.customize.connect( onCustomize );
function RadioLU()
{
// last argument is the filter box
// length - 1, because we have one dummy
ScriptableServiceScript.call( this, "Radio Luxemburg", 1, "List of " + (stationArray.length - 1) +
" Luxemburg Radio Stations", "Enjoy it", true );
}
function onPopulating( level, callbackData, filter )
{
Amarok.debug( " Populating station level..." );
Amarok.debug( " filter: " + filter );
Amarok.debug( " Number stations: " + stationArray.length );
filter = filter.replace( "%20", "" );
var currentFilter = filter.toLowerCase();
//add the station streams as leaf nodes
for ( i = 0; i < stationArray.length; i++ )
{
streamItemName = stationArray[i].name.toLowerCase();
if (( currentFilter == "" ) || ( streamItemName.indexOf( currentFilter ) != -1 )) {
// skip the dummy with no name
if (stationArray[i].name == "") {
continue;
}
item = Amarok.StreamItem;
item.level = 0;
item.callbackData = "";
item.itemName = stationArray[i].name;
item.playableUrl = stationArray[i].url;
// show logo, if not available show favicon
item.infoHtml = "<center>Radiostream von <b>" + item.itemName + "</b>.</br></center>";
if ( stationArray[i].logo != "" ) {
item.infoHtml += "<center><br><img width='50%' src='" + stationArray[i].logo + "'></br></br></center>";
} else if ( stationArray[i].favicon != "" ) {
item.infoHtml += "<center><img src='" + stationArray[i].favicon + "'></br></center>";
}
// link to homepage
if (stationArray[i].homepage != "") {
item.infoHtml += "<center><small>Homepage: <a href='" +
stationArray[i].homepage + "' target='_blank'>" +
stationArray[i].homepage + "</a></small></center>";
}
item.coverUrl = stationArray[i].favicon;
script.insertItem( item );
}
}
script.donePopulating();
}
function onCustomize() {
Amarok.debug ( "loading icon: " + Amarok.Info.scriptPath() + "/icon.png" );
var icon = new QPixmap( Amarok.Info.scriptPath() + "/icon.png" );
script.setIcon( icon );
Amarok.debug ( "loading pixmap: " + Amarok.Info.scriptPath() + "/emblem.png" );
var emblem = new QPixmap( Amarok.Info.scriptPath() + "/emblem.png" );
script.setEmblem( emblem );
Amarok.debug ( "on customize: OK" );
}