platypush/backend/http/app/routes/plugins/media/stream.py
def add_media():
    """
    This route can be used by the `media` plugin to add streaming content over HTTP
    """

    args = {}
    try:
        args = json.loads(request.data.decode('utf-8'))
    except Exception as e:
        abort(400, 'Invalid JSON request: {}'.format(str(e)))

    source = args.get('source')
    if not source:
        abort(400, 'The request does not contain any source')

    subtitles = args.get('subtitles')
    try:
        media_hndl = register_media(source, subtitles)
        ret = dict(media_hndl)
        if media_hndl.subtitles:
            ret['subtitles_url'] = get_remote_base_url() + \
                '/media/subtitles/' + media_hndl.media_id + '.vtt'
        return jsonify(ret)
    except FileNotFoundError as e:
        abort(404, str(e))
    except AttributeError as e:
        abort(400, str(e))
    except Exception as e:
        logger().exception(e)
        abort(500, str(e))

    This route can be used by the `media` plugin to add streaming content over HTTP
    
This route can be used by the `media` plugin to add streaming content over HTTP
This route can be used by the ` media ` plugin to add streaming content over HTTP
def add_media():
    args = {}
    try:
        args = json.loads(request.data.decode('utf-8'))
    except Exception as e:
        abort(400, 'Invalid JSON request: {}'.format(str(e)))
    source = args.get('source')
    if not source:
        abort(400, 'The request does not contain any source')
    subtitles = args.get('subtitles')
    try:
        media_hndl = register_media(source, subtitles)
        ret = dict(media_hndl)
        if media_hndl.subtitles:
            ret['subtitles_url'] = get_remote_base_url() + \
                '/media/subtitles/' + media_hndl.media_id + '.vtt'
        return jsonify(ret)
    except FileNotFoundError as e:
        abort(404, str(e))
    except AttributeError as e:
        abort(400, str(e))
    except Exception as e:
        logger().exception(e)
        abort(500, str(e))
def add_media ( ) : args = { } try : args = json . loads ( request . data . decode ( 'utf-8' ) ) except Exception as e : abort ( 400 , 'Invalid JSON request: {}' . format ( str ( e ) ) ) source = args . get ( 'source' ) if not source : abort ( 400 , 'The request does not contain any source' ) subtitles = args . get ( 'subtitles' ) try : media_hndl = register_media ( source , subtitles ) ret = dict ( media_hndl ) if media_hndl . subtitles : ret [ 'subtitles_url' ] = get_remote_base_url ( ) + '/media/subtitles/' + media_hndl . media_id + '.vtt' return jsonify ( ret ) except FileNotFoundError as e : abort ( 404 , str ( e ) ) except AttributeError as e : abort ( 400 , str ( e ) ) except Exception as e : logger ( ) . exception ( e ) abort ( 500 , str ( e ) )
This route can be used by the `media` plugin to add streaming content over HTTP
This route can be used by the ` media ` plugin to add streaming content over HTTP
"""
    This route can be used by the `media` plugin to add streaming content over HTTP
    """