示例#1
0
def list_streams():
    """List all streams"""
    streams = StreamModel.query()
    form = StreamForm()
    if form.is_submitted():
        if form.validate():
            stream = StreamModel(stream_name=form.stream_name.data,
                                 stream_type=form.stream_type.data,
                                 stream_hostname=form.stream_hostname.data,
                                 stream_port=form.stream_port.data,
                                 stream_sid=form.stream_sid.data,
                                 stream_mount=form.stream_mount.data,
                                 added_by=users.get_current_user())
            try:
                stream.put()
                stream_id = stream.key.id()
                flash(u'Stream %s successfully saved.' % stream_id, 'success')
                return redirect(url_for('list_streams'))
            except CapabilityDisabledError:
                flash(u'App Engine Datastore is currently in read-only mode.',
                      'info')
                return redirect(url_for('list_streams'))
        else:
            flash(u'Error validating stream. Please check your input.',
                  'error')
    return render_template('list_streams.html', streams=streams, form=form)
示例#2
0
def list_streams():
    """List all streams"""
    streams = StreamModel.query()
    form = StreamForm()
    if form.is_submitted():
        if form.validate():
            stream = StreamModel(
                stream_name = form.stream_name.data,
                stream_type = form.stream_type.data,
                stream_hostname = form.stream_hostname.data,
                stream_port = form.stream_port.data,
                stream_sid = form.stream_sid.data,
                stream_mount = form.stream_mount.data,
                added_by = users.get_current_user()
            )
            try:
                stream.put()
                stream_id = stream.key.id()
                flash(u'Stream %s successfully saved.' % stream_id, 'success')
                return redirect(url_for('list_streams'))
            except CapabilityDisabledError:
                flash(u'App Engine Datastore is currently in read-only mode.', 'info')
                return redirect(url_for('list_streams'))
        else:
            flash(u'Error validating stream. Please check your input.', 'error')
    return render_template('list_streams.html', streams=streams, form=form)
示例#3
0
def edit_stream(stream_id):
    stream = StreamModel.get_by_id(stream_id)
    form = StreamForm(obj=stream)
    if form.validate_on_submit():
        stream.stream_name = form.data.get('stream_name')
        stream.stream_type = form.data.get('stream_type')
        stream.stream_hostname = form.data.get('stream_hostname')
        stream.stream_port = form.data.get('stream_port')
        stream.stream_sid = form.data.get('stream_sid')
        stream.stream_mount = form.data.get('stream_mount')
        stream.put()
        flash(u'Stream %s successfully saved.' % stream_id, 'success')
        return redirect(url_for('list_streams'))
    return render_template('edit_stream.html', stream=stream, form=form)
示例#4
0
def edit_stream(stream_id):
    stream = StreamModel.get_by_id(stream_id)
    form = StreamForm(obj=stream)
    if form.validate_on_submit():
        stream.stream_name = form.data.get('stream_name')
        stream.stream_type = form.data.get('stream_type')
        stream.stream_hostname = form.data.get('stream_hostname')
        stream.stream_port = form.data.get('stream_port')
        stream.stream_sid = form.data.get('stream_sid')
        stream.stream_mount = form.data.get('stream_mount')
        stream.put()
        flash(u'Stream %s successfully saved.' % stream_id, 'success')
        return redirect(url_for('list_streams'))
    return render_template('edit_stream.html', stream=stream, form=form)
示例#5
0
文件: app.py 项目: xumarcus/ytdl20
 def __post_init__(self):
     self.stream_form = StreamForm()
     self.stream_form.stream_url.choices = [
         (dash.url, '%s (%s)' % (AUDIO_FORMATS[dash.format_id],
                                 humanfriendly.format_size(dash.filesize)))
         for dash in self.formats if dash.format_id in AUDIO_FORMATS
     ]
     self.download_form = DownloadForm()
     self.download_form.download_format.choices = [
         (dash.format_id,
          '%s (%s)' % (VIDEO_FORMATS[dash.format_id],
                       humanfriendly.format_size(dash.filesize)))
         for dash in self.formats if dash.format_id in VIDEO_FORMATS
     ]