示例#1
0
文件: __init__.py 项目: keios/PyRfK
def make_output(dir):
    script = u''
    streams = Stream.query.all()
    for stream in streams:
        if stream.type == Stream.TYPES.OGG:
            file = 'output_vorbis.liq'
        elif stream.type == Stream.TYPES.AACP:
            file = 'output_aacp.liq'
        elif stream.type == Stream.TYPES.MP3:
            file = 'output_mp3.liq'
        elif stream.type == Stream.TYPES.OPUS:
            file = 'output_opus.liq'
        else:
            continue
        template_string = open(_get_template_path(file), 'r').read()
        template = Template(template_string)
        master = Relay.get_master()
        script += template.substitute(name=stream.code,
                                      description=stream.name,
                                      quality=stream.quality,
                                      host=master.address,
                                      port=master.port,
                                      username=master.auth_username,
                                      password=master.auth_password,
                                      mount=stream.mount,
                                      url=rfk.CONFIG.get('site', 'url'))
    if isinstance(streams, str):
        streams = streams.decode('utf-8')
    if not isinstance(streams, unicode):
        streams = unicode(streams)
    return script
示例#2
0
def make_output(dir):
    script = u''
    streams = Stream.query.all()
    for stream in streams:
        if stream.type == Stream.TYPES.OGG:
            file = 'output_vorbis.liq'
        elif stream.type == Stream.TYPES.AACP:
            file = 'output_aacp.liq'
        elif stream.type == Stream.TYPES.MP3:
            file = 'output_mp3.liq'
        elif stream.type == Stream.TYPES.OPUS:
            file = 'output_opus.liq'
        else:
            continue
        template_string = open(_get_template_path(file), 'r').read()
        template = Template(template_string)
        master = Relay.get_master()
        script += template.substitute(name=stream.code,
                                      description=stream.name,
                                      quality=stream.quality,
                                      host=master.address,
                                      port=master.port,
                                      username=master.auth_username,
                                      password=master.auth_password,
                                      mount=stream.mount,
                                      url=rfk.CONFIG.get('site', 'url'))
    if isinstance(streams, str):
        streams = streams.decode('utf-8')
    if not isinstance(streams, unicode):
        streams = unicode(streams)
    return script