本文整理汇总了Python中mediacore.lib.util.url_for函数的典型用法代码示例。如果您正苦于以下问题:Python url_for函数的具体用法?Python url_for怎么用?Python url_for使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了url_for函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_uris
def get_uris(self, media_file):
"""Return a list of URIs from which the stored file can be accessed.
:type media_file: :class:`~mediacore.model.media.MediaFile`
:param media_file: The associated media file object.
:rtype: list
:returns: All :class:`StorageURI` tuples for this file.
"""
uris = []
# Remotely accessible URL
url = url_for(controller='/media', action='serve', id=media_file.id,
slug=media_file.media.slug, container=media_file.container,
qualified=True)
uris.append(StorageURI(media_file, 'http', url, None))
# An optional streaming RTMP URI
rtmp_server_uri = self._data.get('rtmp_server_uri', None)
if rtmp_server_uri:
uris.append(StorageURI(media_file, 'rtmp', media_file.unique_id, rtmp_server_uri))
# Remotely *download* accessible URL
url = url_for(controller='/media', action='serve', id=media_file.id,
slug=media_file.media.slug, container=media_file.container,
qualified=True, download=1)
uris.append(StorageURI(media_file, 'download', url, None))
# Internal file URI that will be used by MediaController.serve
path = urlunsplit(('file', '', self._get_path(media_file.unique_id), '', ''))
uris.append(StorageURI(media_file, 'file', path, None))
return uris
示例2: test_can_generate_static_url_with_proxy_prefix
def test_can_generate_static_url_with_proxy_prefix(self):
self.pylons_config['proxy_prefix'] = '/proxy'
request = self.init_fake_request(server_name='server.example')
request.environ['SCRIPT_NAME'] = '/proxy'
assert_equals('/proxy/media', url_for('/media'))
qualified_media_url = url_for('/media', qualified=True)
assert_equals('http://server.example:80/proxy/media', qualified_media_url)
示例3: embed_iframe
def embed_iframe(media, width=400, height=225, frameborder=0, **kwargs):
"""Return an <iframe> tag that loads our universal player.
:type media: :class:`mediacore.model.media.Media`
:param media: The media object that is being rendered, to be passed
to all instantiated player objects.
:rtype: :class:`genshi.builder.Element`
:returns: An iframe element stream.
"""
src = url_for(controller="/media", action="embed_player", slug=media.slug, qualified=True)
tag = Element("iframe", src=src, width=width, height=height, frameborder=frameborder, **kwargs)
return tag
示例4: flashvars
def flashvars(self):
"""Return a python dict of flashvars for this player."""
youtube = self.get_uris(container='youtube')
rtmp = self.get_uris(scheme=RTMP)
http = self.get_uris(scheme=HTTP)
audio_desc = self.get_uris(type=AUDIO_DESC)
captions = self.get_uris(type=CAPTIONS)
vars = {
'image': thumb_url(self.media, 'l', qualified=self.qualified),
'autostart': self.autoplay,
}
if youtube:
vars['provider'] = 'youtube'
vars['file'] = str(youtube[0])
elif rtmp:
if len(rtmp) > 1:
# For multiple RTMP bitrates, use Media RSS playlist
vars = {}
vars['playlistfile'] = url_for(
controller='/media',
action='jwplayer_rtmp_mrss',
slug=self.media.slug,
)
else:
# For a single RTMP stream, use regular Flash vars.
rtmp_uri = rtmp[0]
vars['file'] = rtmp_uri.file_uri
vars['streamer'] = rtmp_uri.server_uri
vars['provider'] = 'rtmp'
else:
http_uri = http[0]
vars['provider'] = self.providers[http_uri.file.type]
vars['file'] = str(http_uri)
plugins = []
if rtmp:
plugins.append('rtmp')
if audio_desc:
plugins.append('audiodescription');
vars['audiodescription.file'] = audio_desc[0].uri
if captions:
plugins.append('captions');
vars['captions.file'] = captions[0].uri
if plugins:
vars['plugins'] = ','.join(plugins)
return vars
示例5: embed_iframe
def embed_iframe(media, width=400, height=225, frameborder=0, **kwargs):
"""Return an <iframe> tag that loads our universal player.
:type media: :class:`mediacore.model.media.Media`
:param media: The media object that is being rendered, to be passed
to all instantiated player objects.
:rtype: :class:`genshi.builder.Element`
:returns: An iframe element stream.
"""
src = url_for(controller='/media', action='embed_player', slug=media.slug,
qualified=True)
tag = Element('iframe', src=src, width=width, height=height,
frameborder=frameborder, **kwargs)
# some software is known not to work with self-closing iframe tags
# ('<iframe ... />'). Several WordPress instances are affected as well as
# TWiki http://opensource.mediacore.com/community/topic/embed-iframe-closing-tag
tag.append('')
return tag
示例6: js_url
def js_url(self):
return url_for('/scripts/third-party/jw_player/jwplayer.min.js',
qualified=self.qualified)
示例7: swf_url
def swf_url(self):
return url_for('/scripts/third-party/jw_player/player.swf',
qualified=self.qualified)
示例8: update_params
def update_params(self, d):
super(LinkifyMixin, self).update_params(d)
d.link = url_for(d.link)
示例9: swf_url
def swf_url(self):
"""Return the flash player URL."""
return url_for('/m3u8player/public/scripts/third-party/HLSProviderChromeless.swf', qualified=self.qualified)
示例10: js
def js(source):
if config['debug'] and source in js_sources_debug:
return url_for(js_sources_debug[source])
return url_for(js_sources[source])
示例11: swf_url
def swf_url(self):
"""Return the flash player URL."""
return url_for('/scripts/third-party/jw_player/player.swf',
qualified=self.qualified)