# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - UstreamTv Macro

    A macro to embed Streams from ustream.tv on wiki pages.
    
    Usage: [[UstreamTv(streamcode)]]
    
    Parameters:
    
    	streamcode: The code of the stream you want to embed. You find this in the code in the string given under the video and marked as "Embed:".
    	
    Example:
    
    	[[UstreamTv(T12pR0aOs2YQxMP99AvhBg.usc)]]
    	
    	The Code to embed given at ustream looks like this:
    	
    	<embed width="416" height="340" flashvars="autoplay=true" src="http://ustream.tv/T12pR0aOs2YQxMP99AvhBg.usc" type="application/x-shockwave-flash" wmode="transparent" \>
    
    @copyright: 2007 by MoinMoin:RalfZosel 
    @license: GNU GPL, see COPYING for details.
"""

from MoinMoin import wikiutil

def execute(macro, args):
    streamcode = wikiutil.escape(args)
    result = '<embed width="416" height="340" flashvars="autoplay=true" src="http://ustream.tv/%s" type="application/x-shockwave-flash" wmode="transparent" \>' % (streamcode)
    return macro.formatter.rawHTML(result)
