Exemplo n.º 1
0
    def get_uris(self, media_file):
        """Return a list of URIs from which the stored file can be accessed.

        :type media_file: :class:`~mediadrop.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
Exemplo n.º 2
0
    def get_uris(self, media_file):
        """Return a list of URIs from which the stored file can be accessed.

        :type media_file: :class:`~mediadrop.model.media.MediaFile`
        :param media_file: The associated media file object.
        :rtype: list
        :returns: All :class:`StorageURI` tuples for this file.

        """
        uid = media_file.unique_id
        url = os.path.join(self._data[HTTP_DOWNLOAD_URI], uid)
        uris = [StorageURI(media_file, 'http', url, None)]
        rtmp_server = self._data.get(RTMP_SERVER_URI, None)
        if rtmp_server:
            uris.append(StorageURI(media_file, 'rtmp', uid, rtmp_server))
        return uris
Exemplo n.º 3
0
    def get_uris(self, media_file):
        """Return a list of URIs from which the stored file can be accessed.

        :type media_file: :class:`~mediadrop.model.media.MediaFile`
        :param media_file: The associated media file object.
        :rtype: list
        :returns: All :class:`StorageURI` tuples for this file.

        """
        uid = media_file.unique_id
        play_url = 'http://player.vimeo.com/video/%s' % uid
        web_url = 'http://vimeo.com/%s' % uid
        return [
            StorageURI(media_file, 'vimeo', play_url, None),
            StorageURI(media_file, 'www', web_url, None),
        ]
Exemplo n.º 4
0
    def get_uris(self, media_file):
        """Return a list of URIs from which the stored file can be accessed.

        :type media_file: :class:`~mediadrop.model.media.MediaFile`
        :param media_file: The associated media file object.
        :rtype: list
        :returns: All :class:`StorageURI` tuples for this file.

        """
        uid = media_file.unique_id
        if uid.startswith('rtmp://'):
            sep_index = uid.find(RTMP_URI_DIVIDER) # can raise ValueError
            if sep_index < 0:
                log.warn('File %r has an invalidly formatted unique ID for RTMP.', media_file)
                return []
            server_uri = uid[:sep_index]
            file_uri = uid[sep_index + len(RTMP_URI_DIVIDER):]
            return [StorageURI(media_file, 'rtmp', file_uri, server_uri)]
        return [StorageURI(media_file, 'http', uid, None)]
Exemplo n.º 5
0
    def get_uris(self, media_file):
        """Return a list of URIs from which the stored file can be accessed.

        :type media_file: :class:`~mediadrop.model.media.MediaFile`
        :param media_file: The associated media file object.
        :rtype: list
        :returns: All :class:`StorageURI` tuples for this file.

        """
        params = self._data.get('player_params', {})
        params = dict((k, int(v)) for k, v in params.iteritems())
        play_url = 'http://youtube%s.com/embed/%s?%s' % (
            self._data.get('nocookie', False) and '-nocookie' or '',
            media_file.unique_id,
            urlencode(params, True),
        )
        web_url = 'http://youtube.com/watch?v=%s' % media_file.unique_id
        return [
            StorageURI(media_file, 'youtube', play_url, None),
            StorageURI(media_file, 'www', web_url, None),
        ]
Exemplo n.º 6
0
    def get_uris(self, media_file):
        """Return a list of URIs from which the stored file can be accessed.

        :type media_file: :class:`~mediadrop.model.media.MediaFile`
        :param media_file: The associated media file object.
        :rtype: list
        :returns: All :class:`StorageURI` tuples for this file.

        """
        web_id, embed_lookup = media_file.unique_id.split(' ')
        play_url = 'http://blip.tv/play/%s' % embed_lookup

        # Old blip.tv URLs had a numeric ID in the URL, now they're wordy.
        try:
            web_url = 'http://blip.tv/file/%s' % int(web_id, 10)
        except ValueError:
            web_url = 'http://blip.tv/%s' % web_id

        return [
            StorageURI(media_file, 'bliptv', play_url, None),
            StorageURI(media_file, 'www', web_url, None),
        ]
Exemplo n.º 7
0
 def test_can_play_ignores_empty_container(self):
     class FakePlayer(FileSupportMixin):
         supported_containers = set(['mp4'])
         supported_schemes = set([RTMP])
     fake_player = FakePlayer()
     media_file = MediaFile()
     media_file.container = ''
     media_file.type = VIDEO
     uri = StorageURI(media_file, 'rtmp', 'test',
         server_uri='rtmp://stream.host.example/play')
     assert_equals('', uri.file.container,
         message='It is important that the server uri has no container.')
     assert_equals((True, ), fake_player.can_play([uri]))