Exemplo n.º 1
0
def edit_service(method: str, server: ServiceSettings):
    form = ServiceSettingsForm(obj=server)

    if method == 'POST' and form.validate_on_submit():
        server = form.update_entry(server)
        server.save()
        return jsonify(status='ok'), 200

    return render_template('service/edit.html', form=form)
Exemplo n.º 2
0
    def edit_service(self, sid):
        server = ServiceSettings.objects(id=sid).first()
        if server:
            return edit_service(request.method, server)

        response = {"status": "failed"}
        return jsonify(response), 404
Exemplo n.º 3
0
def _add_service(method: str):
    server = ServiceSettings()
    form = ServiceSettingsForm(obj=server)
    if method == 'POST' and form.validate_on_submit():
        new_entry = form.make_settings()
        new_entry.save()
        return jsonify(status='ok'), 200

    return render_template('service/add.html', form=form)
Exemplo n.º 4
0
 def __init__(self):
     service_settings = ServiceSettings.objects().first()  # FIXME
     if not service_settings:
         service_settings = ServiceSettings()
     service.set_settings(service_settings)
Exemplo n.º 5
0
    def getFile(self, randomShuffle):
        if randomShuffle:
            random.shuffle(self.files)
        if not len(self.files):
            self.logging.error(
                "No files in the array, cannot extract anything")
            return None
        return self.files.pop()


if __name__ == '__main__':
    parser = argparse.ArgumentParser(prog=PROJECT_NAME,
                                     usage='%(prog)s [options]')
    parser.add_argument('uri', help='Uri to m3u8 list')
    parser.add_argument('mongo_uri', help='MongoDB credentials')

    argv = parser.parse_args()

    mongo = connect(argv.mongo_uri)
    if mongo:
        service_settings = ServiceSettings.objects().first()
        m3u_parser = M3uParser(None)
        m3u_parser.readM3u(argv.uri)
        for file in m3u_parser.files:
            stream = make_test_life_stream(service_settings.feedback_directory)
            stream.input.urls[0].uri = file['link']
            stream.name = '{0}({1})'.format(file['tvg-group'], file['title'])
            service_settings.streams.append(stream)

        service_settings.save()