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.
  • [get | view] (2012-06-26 21:26:32, 1.6 KB) [[attachment:GlamMetalRadio.py]]
  • [get | view] (2010-06-02 22:02:32, 8.2 KB) [[attachment:RSSReader.py]]
  • [get | view] (2010-11-17 11:48:56, 2.5 KB) [[attachment:include.py]]
  • [get | view] (2011-09-07 11:55:07, 1.9 KB) [[attachment:moin.wsgi]]
  • [get | view] (2011-09-08 17:49:41, 2.8 KB) [[attachment:moinmoin.sh]]
  • [get | view] (2011-09-07 11:54:54, 1.0 KB) [[attachment:nginx.conf]]
  • [get | view] (2009-01-09 14:12:23, 136.3 KB) [[attachment:screenshot-piwik.png]]
  • [get | view] (2011-09-07 11:54:59, 0.5 KB) [[attachment:uwsgi.xml]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.