Attachment 'GlamMetalRadio.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 u"""
3 MoinMoin - GlamMetalRAdio macro Version 0.1 ALPHA
4 This macro will include your a laut.fm radio over an object tag
5
6 """
7
8 from MoinMoin import wikiutil
9 import simplejson as json
10 import urllib2
11 Dependencies = ['time'] #do not cache, because we want updates of new songs
12
13 def macro_GlamMetalRadio(macro):
14 request = macro.request
15 html = u""
16 parameters = []
17
18 #loading current song and output the artist name and title
19 try:
20 current = urllib2.urlopen("http://api.laut.fm/station/rockheavy/current_song",None,2).read()
21 data = json.loads(current)
22 track = wikiutil.escape(data["artist"]["name"]) + " mit '" + wikiutil.escape(data["title"]) + "'"
23 except:
24 track = ""
25 try:
26 track = track + " von " + wikiutil.escape(data["releaseyear"])
27 except:
28 pass
29
30 #generate the html code and javascript popup function
31 html = u"""
32 <div class="GlamMetalRadio">
33
34 <script language="javascript" type="text/javascript">
35 <!--
36 function popitup(url) {
37 newwindow=window.open(url,'name','height=320,width=310');
38 if (window.focus) {newwindow.focus()}
39 return false;
40 }
41 // -->
42 </script>
43
44 <a href="http://www.laut.fm/standalone.php?station=rockheavy" title"Glam Metal Radio" onclick="return popitup('http://www.laut.fm/standalone.php?station=rockheavy')">
45 Glam Metal Radiostation
46 </a>
47
48 <p class="track">%s</p>
49
50 </div>
51 """ % track
52
53
54 return macro.formatter.rawHTML(html)
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.