Пример #1
0
def show_edit(show):
    s = Show.query.get(show)
    if s is None:
        return "no show found"
    if request.args.get("inline"):
        template = "/shows/showform-inline.html"
    else:
        template = "/shows/showform.html"

    tags = []
    for tag in s.tags:
        tags.append(tag.tag.name)

    return render_template(
        template,
        show={
            "name": s.name,
            "description": s.description,
            "series": s.series,
            "users": s.users,
            "tags": ",".join(tags),
            "begin": to_user_timezone(s.begin).strftime("%s"),
            "logo": s.logo,
            "show": s.show,
            "duration": (s.end - s.begin).total_seconds() / 60,
        },
        imgur={"client": CONFIG.get("site", "imgur-client")},
        format=get_datetime_format(),
    )
Пример #2
0
def show_edit(show):
    s = Show.query.get(show)
    if s is None:
        return 'no show found'
        # TODO: proper error page
    if request.args.get('inline'):
        template = '/shows/showform-inline.html'
    else:
        template = '/shows/showform.html'

    tags = []
    for tag in s.tags:
        tags.append(tag.tag.name)

    return render_template(template,
                           show={'name': s.name,
                                 'description': s.description,
                                 'series': s.series,
                                 'users': s.users,
                                 'tags': ",".join(tags),
                                 'begin': to_user_timezone(s.begin).strftime('%s'),
                                 'logo': s.logo,
                                 'show': s.show,
                                 'duration': (s.end - s.begin).total_seconds() / 60},
                           imgur={'client': CONFIG.get('site', 'imgur-client')},
                           format=get_datetime_format())
Пример #3
0
 def get_icecast_config(self, all_streams=False):
     """returns the configuration XML for this Relay"""
     conf = rfk.icecast.IcecastConfig()
     conf.address = self.address
     conf.port = self.port
     conf.admin = self.admin_username
     conf.password = self.admin_password
     conf.hostname = self.address
     api_url = "http://%s%s" % (CONFIG.get('site', 'url'), '/backend/icecast/')
     if all_streams:
         for stream in Stream.query.all():
             mount = rfk.icecast.Mount()
             mount.api_url = api_url
             mount.mount = stream.mount
             mount.username = self.auth_username
             mount.password = self.auth_password
             conf.mounts.append(mount)
     else:
         for stream in self.streams:
             mount = rfk.icecast.Mount()
             mount.api_url = api_url
             mount.mount = stream.stream.mount
             mount.username = self.auth_username
             mount.password = self.auth_password
             conf.mounts.append(mount)
     if self.type == Relay.TYPE.RELAY:
         master = Relay.get_master()
         conf.master = master.address
         conf.master_user = master.relay_username
         conf.master_password = master.relay_password
         conf.master_port = master.port
     elif self.type == Relay.TYPE.MASTER:
         conf.relay_user = self.relay_username
         conf.relay_password = self.relay_password
     return conf.get_xml()
Пример #4
0
 def get_icecast_config(self, all_streams=False):
     """returns the configuration XML for this Relay"""
     conf = rfk.icecast.IcecastConfig()
     conf.address = self.address
     conf.port = self.port
     conf.admin = self.admin_username
     conf.password = self.admin_password
     conf.hostname = self.address
     api_url = "http://%s%s" % (CONFIG.get('site', 'url'),'/backend/icecast/')
     if all_streams:
         for stream in Stream.query.all():
             mount = rfk.icecast.Mount()
             mount.api_url = api_url 
             mount.mount = stream.mount
             mount.username = self.auth_username
             mount.password = self.auth_password
             conf.mounts.append(mount)
     else:
         for stream in self.streams:
             mount = rfk.icecast.Mount()
             mount.api_url = api_url
             mount.mount = stream.stream.mount
             mount.username = self.auth_username
             mount.password = self.auth_password
             conf.mounts.append(mount)
     if self.type == Relay.TYPE.RELAY:
         master = Relay.get_master()
         conf.master = master.address
         conf.master_user = master.relay_username
         conf.master_password = master.relay_password
         conf.master_port = master.port
     elif self.type == Relay.TYPE.MASTER:
         conf.relay_user = self.relay_username
         conf.relay_password = self.relay_password
     return conf.get_xml()
Пример #5
0
def new_show_form():
    if request.args.get('inline'):
        template = '/shows/showform-inline.html'
    else:
        template = '/shows/showform.html'
    return render_template(template,
                           imgur={'client': CONFIG.get('site', 'imgur-client')},
                           format=get_datetime_format())
Пример #6
0
def new_series():
    form = new_series_form(request.form)
    if request.method == "POST" and form.validate():
        series = Series(user=current_user,
                        public=form.public.data,
                        name=form.name.data,
                        description=form.description.data,
                        logo=form.image.data)
        rfk.database.session.add(series)
        rfk.database.session.commit()
        flash(gettext('Series added successfully'), 'info')
        return redirect(url_for('.list_series'))
    return render_template('shows/seriesform.html', form=form,
                           imgur={'client': CONFIG.get('site', 'imgur-client')})
Пример #7
0
def new_series():
    form = new_series_form(request.form)
    if request.method == "POST" and form.validate():
        series = Series(
            user=current_user,
            public=form.public.data,
            name=form.name.data,
            description=form.description.data,
            logo=form.image.data,
        )
        rfk.database.session.add(series)
        rfk.database.session.commit()
        flash("Series added successfully", "info")
        return redirect(url_for(".list_series"))
    return render_template("shows/seriesform.html", form=form, imgur={"client": CONFIG.get("site", "imgur-client")})
Пример #8
0
def get_serviceproxy():
    ap = AuthServiceProxy('http://{username}:{password}@{host}:{port}/'.format(username=CONFIG.get('armord', 'username'),
                                                                               password=CONFIG.get('armord', 'password'),
                                                                               host=CONFIG.get('armord', 'host'),
                                                                               port=CONFIG.get('armord', 'port')))
    return ap
Пример #9
0
 def file_exists(self):
     if self.filename is None:
         return False
     return os.path.exists(os.path.join(get_path(CONFIG.get('liquidsoap', 'looppath')), self.filename))
Пример #10
0
 def file_exists(self):
     if self.filename is None:
         return False
     return os.path.exists(
         os.path.join(get_path(CONFIG.get('liquidsoap', 'looppath')),
                      self.filename))
Пример #11
0
def new_show_form():
    if request.args.get("inline"):
        template = "/shows/showform-inline.html"
    else:
        template = "/shows/showform.html"
    return render_template(template, imgur={"client": CONFIG.get("site", "imgur-client")}, format=get_datetime_format())