Пример #1
0
    def playlist(self, sid):
        server = ServiceSettings.objects(id=sid).first()
        if server:
            return Response(server.generate_playlist(),
                            mimetype='application/x-mpequrl'), 200

        return jsonify(status='failed'), 404
Пример #2
0
    def remove(self):
        servers = ServiceSettings.objects()
        for server in servers:
            server.remove_provider(current_user)

        current_user.delete()
        return redirect(url_for('HomeView:index'))
Пример #3
0
    def remove(self):
        sid = request.form['sid']
        server = ServiceSettings.objects(id=sid).first()
        if server:
            server.delete()
            return jsonify(status='ok'), 200

        return jsonify(status='failed'), 404
Пример #4
0
    def edit(self, sid):
        server = ServiceSettings.objects(id=sid).first()
        form = ServiceSettingsForm(obj=server)

        if request.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)
Пример #5
0
    def provider_remove(self, sid):
        data = request.get_json()
        pid = data['pid']
        provider = ProviderUser.objects(id=pid).first()
        server = ServiceSettings.objects(id=sid).first()
        if provider and server:
            server.remove_provider(provider)
            provider.remove_server(server)
            return jsonify(status='ok'), 200

        return jsonify(status='failed'), 404
Пример #6
0
    def add(self):
        form = SignupForm()
        if request.method == 'POST' and form.validate_on_submit():
            new_entry = form.make_entry()
            servers = ServiceSettings.objects()
            for server in servers:
                new_entry.add_server(server)
            new_entry.save()
            return jsonify(status='ok'), 200

        return render_template('subscriber/add.html', form=form)
Пример #7
0
    def subscriber_add(self, sid):
        form = SignupForm()
        if request.method == 'POST' and form.validate_on_submit():
            server = ServiceSettings.objects(id=sid).first()
            if server:
                new_entry = form.make_entry()
                new_entry.add_server(server)

                server.add_subscriber(new_entry)
                return jsonify(status='ok'), 200

        return render_template('service/subscriber/add.html', form=form)
Пример #8
0
    def provider_add(self, sid):
        form = ServerProviderForm()
        if request.method == 'POST' and form.validate_on_submit():
            email = form.email.data.lower()
            provider = ProviderUser.objects(email=email).first()
            server = ServiceSettings.objects(id=sid).first()
            if server and provider:
                admin = ProviderPair(provider.id, form.role.data)
                server.add_provider(admin)
                provider.add_server(server)
                return jsonify(status='ok'), 200

        return render_template('service/provider/add.html', form=form)
Пример #9
0
    def signup(self):
        form = SignupForm(country=get_country_code_by_remote_addr(request.remote_addr))
        if request.method == 'POST':
            if not form.validate_on_submit():
                flash_error(form.errors)
                return render_template('home/signup.html', form=form)

            email = form.email.data.lower()
            if not is_valid_email(email, False):
                flash_error('Invalid email.')
                return render_template('home/signup.html', form=form)

            existing_user = _get_subscriber_by_email(email)
            if existing_user:
                return redirect(url_for('HomeView:signin'))

            new_user = SubscriberUser.make_subscriber(email, form.first_name.data, form.last_name.data,
                                                      form.password.data, form.country.data, form.language.data)
            new_user.save()

            servers = ServiceSettings.objects()
            for serv in servers:
                new_user.add_server(serv)
                serv.add_subscriber(new_user)

            token = self._confirm_link_generator.dumps(email, salt=HomeView.SALT_LINK)
            confirm_url = url_for('HomeView:confirm_email', token=token, _external=True)
            config = app.config['PUBLIC_CONFIG']
            html = render_template('home/email/activate.html', confirm_url=confirm_url,
                                   contact_email=config['support']['contact_email'], title=config['site']['title'],
                                   company=config['company']['title'])
            msg = Message(subject='Confirm Email', recipients=[email], html=html)
            mail.send(msg)
            flash_success('Please check email: {0}.'.format(email))
            return redirect(url_for('HomeView:signin'))

        return render_template('home/signup.html', form=form)
Пример #10
0
    def providers(self, sid):
        server = ServiceSettings.objects(id=sid).first()
        if server:
            return render_template('service/providers.html', server=server)

        return redirect(url_for('ProviderView:dashboard'))
Пример #11
0
from mongoengine import connect

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

from pyfastocloud_models.stream.entry import TestLifeStream
from pyfastocloud_models.service.entry import ServiceSettings
from pyfastocloud_models.utils.m3u_parser import M3uParser

PROJECT_NAME = 'test_life'

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()
        m3u_parser.read_m3u(argv.uri)
        m3u_parser.parse()
        for file in m3u_parser.files:
            stream = TestLifeStream.make_stream(service_settings)
            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()