From a92593bfce94a62587df406322b8ad06cda5cea1 Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Mon, 7 May 2018 11:42:34 +0200 Subject: [PATCH] added original YouTube macro from moinmo.in macro market --- YouTube.py | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 YouTube.py diff --git a/YouTube.py b/YouTube.py new file mode 100644 index 0000000..5c59abd --- /dev/null +++ b/YouTube.py @@ -0,0 +1,149 @@ +# -*- coding: iso-8859-1 -*- +u""" + MoinMoin - YouTube macro Version 0.6 + Displays an embedded object with the wanted video or + displays a list of videos (videobar). + + <> + Default is to use the current pagename as keyword. + + Examples: + * <> + * <> + * <> + + @copyright: 2008 by MarcelHäfner (http://moinmo.in/MarcelHäfner), + 2010 by ThomasWaldmann (http://moinmo.in/ThomasWaldmann) + @license: GNU GPL, see COPYING for details. + + Attention! The "keyword" part is created with the "Google AJAX Search API Tools". + Licence Information can be viewed under: http://code.google.com/intl/de-DE/apis/ajaxsearch/terms.html + + @TODO: + * Change the hardcoded https string into http/https depending on the requested url. + * Don't use the google ajax stuff. + * Check if youtube videos are disabled (mimetypes_xss). + +""" + +from MoinMoin import wikiutil + + +def macro_YouTube(macro, id, keyword): + request = macro.request + _ = request.getText + html = u"" + + if id is None and keyword is None: + # default: keyword will be used and default to current page name + keyword = macro.formatter.page.page_name + + if keyword is not None: + # for the videobar to display the flash videos (keyword) + parameters = { + "keyword": wikiutil.escape(keyword), + "msg_youtubelink": _("View the related videos on YouTube."), + } + html = u""" +
+ + + + +
+ Loading... +
+ + + + + + + + + + + + + + +
+ """ % parameters + + if id is not None: + # for the embedded flashplayer to play a single video (id) + parameters = { + "id": wikiutil.escape(id), + "msg_youtubelink": _("View the video on YouTube."), + } + html = u""" +
+ + + + + + + + + + + + +
+ """ % parameters + + return macro.formatter.rawHTML(html) +