Esempio n. 1
0
    def add_vod_proxy_omdb(self, oid):
        server = current_user.get_current_server()
        if server:
            stream_object = server.make_proxy_vod()
            form = ProxyVodStreamForm(obj=stream_object.stream())
            if request.method == 'GET':
                res = omdb.imdbid(oid)
                form.name.data = res['title']
                form.tvg_logo.data = res['poster']
                if res['type'] == 'series':
                    form.vod_type.data = constants.VodType.SERIES
                form.country.data = res['country']
                form.description.data = res['plot']
                form.user_score.data = float(res['imdb_rating']) * 10
                form.group.data = res['genre'].replace(',', ';')
                form.prime_date.data = datetime.datetime.strptime(
                    res['released'], '%d %b %Y')
                runt_raw = res['runtime']
                minutes = re.findall('\\d+', runt_raw)
                if minutes:
                    # runt = datetime.time(minute=int(minutes[0]))
                    # mseconds = (runt.hour * 60000 + runt.minute) * 60000 + runt.second * 1000 + runt.microsecond / 1000
                    form.duration.data = int(minutes[0]) * 60000

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

            return render_template('stream/vod_proxy/add.html', form=form)
        return jsonify(status='failed'), 404
Esempio n. 2
0
    def add_own_proxy_vod(self):
        stream = ProxyVodStream.make_stream(None)
        form = ProxyVodStreamForm(obj=stream)
        form.price.validators = []
        if request.method == 'POST' and form.validate_on_submit():
            new_entry = form.make_entry()
            new_entry.save()
            current_user.add_own_stream(new_entry)
            return jsonify(status='ok'), 200

        return render_template('stream/vod_proxy/add.html', form=form)
Esempio n. 3
0
    def add_proxy_vod(self):
        server = current_user.get_current_server()
        if server:
            stream_object = server.make_proxy_vod()
            form = ProxyVodStreamForm(obj=stream_object.stream())
            if request.method == 'POST' and form.validate_on_submit():
                new_entry = form.make_entry()
                new_entry.save()
                server.add_stream(new_entry)
                return jsonify(status='ok'), 200

            return render_template('stream/vod_proxy/add.html', form=form)
        return jsonify(status='failed'), 404