예제 #1
0
파일: test.py 프로젝트: atjandra001/fintech
    def test_07_register_unregister(self):
        """
        Testing register/unregister.
        """
        from vishap.contrib.plugins.vimeo.vishap_plugin import VimeoPlugin

        class Example2Plugin(BaseVideoPlugin):
            """
            Example plugin.
            """
            uid = "youtube"
            name = "Example with youtube ``uid``"
            url_pattern = "^(?P<prefix>(http\:\/\/www\.youtube\.com\/watch\?v=)|(http\:\/\/www\.youtube\.com\/v\/)|(http\:\/\/youtu\.be\/))(?P<value>[A-Za-z0-9\-=_]{11})"
            id_pattern = "^(?P<value>[A-Za-z0-9\-=_]{11})"
            thumbnail_pattern = "//img.youtube.com/vi/{0}/{1}.jpg"
            embed_code = """
            <iframe src="//www.youtube.com/embed/{video_id}" {options} frameborder="0" allowfullscreen></iframe>
            """

        plugin_registry.register(Example2Plugin)
        # Since key `ru` already exists in the registry it can't be replaced (without force-register).
        res = plugin_registry.register(Example2Plugin)
        self.assertTrue(not res)

        # Now with force-register it can.
        res = plugin_registry.register(Example2Plugin, force=True)
        self.assertTrue(res)

        # Once we have it there and it's forced, we can't register another.
        res = plugin_registry.register(Example2Plugin, force=True)
        self.assertTrue(not res)

        # Unregister non-forced language pack.
        res = plugin_registry.unregister(VimeoPlugin)
        self.assertTrue(
            res and not VimeoPlugin.uid in get_registered_plugin_uids())

        res = plugin_registry.unregister(Example2Plugin)
        self.assertTrue(not res
                        and Example2Plugin.uid in get_registered_plugin_uids())
예제 #2
0
파일: test.py 프로젝트: 18dubu/MMS
    def test_07_register_unregister(self):
        """
        Testing register/unregister.
        """
        from vishap.contrib.plugins.vimeo.vishap_plugin import VimeoPlugin

        class Example2Plugin(BaseVideoPlugin):
            """
            Example plugin.
            """
            uid = "youtube"
            name = "Example with youtube ``uid``"
            url_pattern = "^(?P<prefix>(http\:\/\/www\.youtube\.com\/watch\?v=)|(http\:\/\/www\.youtube\.com\/v\/)|(http\:\/\/youtu\.be\/))(?P<value>[A-Za-z0-9\-=_]{11})"
            id_pattern = "^(?P<value>[A-Za-z0-9\-=_]{11})"
            thumbnail_pattern = "//img.youtube.com/vi/{0}/{1}.jpg"
            embed_code = """
            <iframe src="//www.youtube.com/embed/{video_id}" {options} frameborder="0" allowfullscreen></iframe>
            """

        plugin_registry.register(Example2Plugin)
        # Since key `ru` already exists in the registry it can't be replaced (without force-register).
        res = plugin_registry.register(Example2Plugin)
        self.assertTrue(not res)

        # Now with force-register it can.
        res = plugin_registry.register(Example2Plugin, force=True)
        self.assertTrue(res)

        # Once we have it there and it's forced, we can't register another.
        res = plugin_registry.register(Example2Plugin, force=True)
        self.assertTrue(not res)

        # Unregister non-forced language pack.
        res = plugin_registry.unregister(VimeoPlugin)
        self.assertTrue(res and not VimeoPlugin.uid in get_registered_plugin_uids())

        res = plugin_registry.unregister(Example2Plugin)
        self.assertTrue(not res and Example2Plugin.uid in get_registered_plugin_uids())
예제 #3
0
파일: test.py 프로젝트: atjandra001/fintech
    def test_06_register_custom_plugin(self):
        """
        Test registering of a custom plugin.
        """
        class ExamplePlugin(BaseVideoPlugin):
            """
            Example plugin.
            """
            uid = "example"
            name = "Example"
            url_pattern = "^(?P<prefix>(http\:\/\/www\.youtube\.com\/watch\?v=)|(http\:\/\/www\.youtube\.com\/v\/)|(http\:\/\/youtu\.be\/))(?P<value>[A-Za-z0-9\-=_]{11})"
            id_pattern = "^(?P<value>[A-Za-z0-9\-=_]{11})"
            thumbnail_pattern = "//img.youtube.com/vi/{0}/{1}.jpg"
            embed_code = """
            <iframe src="//www.youtube.com/embed/{video_id}" {options} frameborder="0" allowfullscreen></iframe>
            """

        plugin_registry.register(ExamplePlugin)

        assert 'example' in get_registered_plugin_uids()
        res = render_video(self.youtube_urls[0], plugin_uid='example').strip()
        self.assertEqual(res, self.rendered_youtube_responsive_embed_codes[0])
        return res
예제 #4
0
파일: test.py 프로젝트: 18dubu/MMS
    def test_06_register_custom_plugin(self):
        """
        Test registering of a custom plugin.
        """
        class ExamplePlugin(BaseVideoPlugin):
            """
            Example plugin.
            """
            uid = "example"
            name = "Example"
            url_pattern = "^(?P<prefix>(http\:\/\/www\.youtube\.com\/watch\?v=)|(http\:\/\/www\.youtube\.com\/v\/)|(http\:\/\/youtu\.be\/))(?P<value>[A-Za-z0-9\-=_]{11})"
            id_pattern = "^(?P<value>[A-Za-z0-9\-=_]{11})"
            thumbnail_pattern = "//img.youtube.com/vi/{0}/{1}.jpg"
            embed_code = """
            <iframe src="//www.youtube.com/embed/{video_id}" {options} frameborder="0" allowfullscreen></iframe>
            """

        plugin_registry.register(ExamplePlugin)

        assert 'example' in get_registered_plugin_uids()
        res = render_video(self.youtube_urls[0], plugin_uid='example').strip()
        self.assertEqual(res, self.rendered_youtube_responsive_embed_codes[0])
        return res
예제 #5
0
__title__ = 'vishap.contrib.plugins.vimeo.vishap_plugin'
__author__ = 'Artur Barseghyan'
__copyright__ = 'Copyright (c) 2013-2015 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
__all__ = ('VimeoPlugin', )

from vishap.base import BaseVideoPlugin, plugin_registry


class VimeoPlugin(BaseVideoPlugin):
    """
    Vimeo plugin.
    """
    uid = "vimeo"
    name = "Vimeo"
    url_pattern = "^(?P<prefix>(http(s)?\:\/\/www\.vimeo\.com\/)|" \
                  "(http(s)?\:\/\/vimeo\.com\/))(?P<value>\d*)"
    id_pattern = "^(?P<value>\d*{11})"
    embed_code = """
    <iframe src="//player.vimeo.com/video/{video_id}" {options} frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
    """


plugin_registry.register(VimeoPlugin)
예제 #6
0
__title__ = 'vishap.contrib.plugins.youtube.vishap_plugin'
__author__ = 'Artur Barseghyan'
__copyright__ = 'Copyright (c) 2013-2015 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
__all__ = ('YoutubePlugin',)

from vishap.base import BaseVideoPlugin, plugin_registry

class YoutubePlugin(BaseVideoPlugin):
    """
    Youtube plugin.
    """
    uid = "youtube"
    name = "Youtube"
    url_pattern = "^(?P<prefix>(https?\:\/\/www\.youtube\.com\/watch\?v=)|" \
                  "(https?\:\/\/www\.youtube\.com\/v\/)|" \
                  "(https?\:\/\/youtu\.be\/))(?P<value>[A-Za-z0-9\-=_]{11})"
    id_pattern = "^(?P<value>[A-Za-z0-9\-=_]{11})"
    thumbnail_pattern = "//img.youtube.com/vi/{0}/{1}.jpg"
    embed_code = """
    <iframe src="//www.youtube.com/embed/{video_id}" {options} frameborder="0" allowfullscreen></iframe>
    """

plugin_registry.register(YoutubePlugin)
예제 #7
0
파일: vishap_plugin.py 프로젝트: 18dubu/MMS
__title__ = 'vishap.contrib.plugins.vimeo.vishap_plugin'
__author__ = 'Artur Barseghyan'
__copyright__ = 'Copyright (c) 2013-2015 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
__all__ = ('VimeoPlugin',)

from vishap.base import BaseVideoPlugin, plugin_registry

class VimeoPlugin(BaseVideoPlugin):
    """
    Vimeo plugin.
    """
    uid = "vimeo"
    name = "Vimeo"
    url_pattern = "^(?P<prefix>(http(s)?\:\/\/www\.vimeo\.com\/)|" \
                  "(http(s)?\:\/\/vimeo\.com\/))(?P<value>\d*)"
    id_pattern = "^(?P<value>\d*{11})"
    embed_code = """
    <iframe src="//player.vimeo.com/video/{video_id}" {options} frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
    """

plugin_registry.register(VimeoPlugin)