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

    A macro to embed YouTube-videos on wiki pages.
    
    Usage: [[YouTube(videocode)]]
    
    Parameters:
    
    	videocode: The code of the video you want to embed. You find this in the URL given next to the YouTube video.
    	
    Example:
    
    	[[YouTube(SWmehf9okWM)]]
    	
    	The URL given at YouTube looks like this: http://www.youtube.com/watch?v=SWmehf9okWM
    
    @copyright: 2007 by MoinMoin:RalfZosel 
    @license: GNU GPL, see COPYING for details.
"""

from MoinMoin import wikiutil

def execute(macro, args):
    videocode = wikiutil.escape(args)
    result = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/%s"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/%s" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>' % (videocode, videocode)
    return macro.formatter.rawHTML(result)

