Beispiel #1
0
class BaseTestModelSuite(unittest.TestCase):
    def setUp(self):
        app.config['TESTING'] = True
        app.config['CSRF_ENABLED'] = False
        app.config['DEBUG'] = False
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(
            BASE_DIR, TEST_DB)
        self.app = app.test_client()
        db.create_all()
        self.user = User('TestUser')
        self.user.save('testpassword')
        self.video = Video('TestVideo')
        self.video.save(hash='Teststring', user=self.user)
        self.video.add_path(
            join_path(app.config['VIDEO_SAVE_PATH'], self.video.id))

    def tearDown(self):
        db.session.remove()
        db.drop_all()
def videos_map():
    videos_with_coords = []
    user = cur_user()

    for video in Video.get():
        if video.geotags:
            videos_with_coords.append(video)

    return render_template('videos_map.html',
                           user=user,
                           videos=videos_with_coords)
Beispiel #3
0
def upload():
    form = enterdata()
    if form.is_submitted():
        s_time = form.start_time.data
        e_time = form.end_time.data
        new_task = Video(camera_id=form.camera_id.data,
                         start_time=form.start_time.data,
                         end_time=form.end_time.data,
                         filepath=form.filepath.data)
        db.session.add(new_task)
        db.session.commit()
        return redirect(url_for('video.upload'))
    return render_template('post.html', form=form)
def save_video(video_file, title):
    ext = secure_filename(video_file.filename).split('.')[-1]
    video_hash = md5(video_file.read()).hexdigest()
    video_file.seek(0)

    video = Video(title)
    video.save(video_hash, cur_user())
    videos.save(video_file, folder=str(video.id), name='video.' + ext)
    video.add_path(join_path(app.config['VIDEO_SAVE_PATH'], video.id))

    try:
        prepare_video(video.id, ext)
    except OSError:
        video.delete_video()
        return None
    return video
def main():
    user = cur_user()
    sub_items = []
    if user:
        subs = user.subscriptions
        for sub in subs:
            for video in sub.videos:
                sub_items.append(video)

    now = time = datetime.now(tz=None)
    video_pack = Video.get(need_geo=True)
    return render_template('main.html',
                           user=user,
                           items=video_pack[0],
                           sub_items=sub_items,
                           now=now,
                           geo_items=json.dumps(
                               [video.serialize() for video in video_pack[1]]))
def play(vid):
    video = Video.get(video_id=vid)
    if not video:
        abort = Aborter()
        return abort(404)

    user = cur_user()
    usr = User.get(login=video.user.login)

    if user and user not in video.viewers:
        video.add_viewer(user)

    likened = 0
    if user in video.likes:
        likened = 1
    if user in video.dislikes:
        likened = -1
    return render_template('video_page.html',
                           user=user,
                           vid=vid,
                           video=video,
                           lkd=likened,
                           usr=usr,
                           subscribed=(user in usr.subscribers))
def standardize_video_extension(video_id, ext):
    video = Video.get(video_id=video_id)
    video_path = join_path(video.path, 'video.' + ext)

    video_clip = VideoFileClip(video_path)
    video_clip.write_videofile(join_path(video.path, 'video.mp4'))