2021-10-01 10:29:16 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# -------------------------------------------------------------------------
|
|
|
|
# This is a sample controller
|
|
|
|
# this file is released under public domain and you can use without limitations
|
|
|
|
# -------------------------------------------------------------------------
|
|
|
|
|
2021-10-11 16:33:52 +02:00
|
|
|
import io
|
2021-10-08 15:18:30 +02:00
|
|
|
#from transcription_tools import create_vtt
|
|
|
|
transcription_tools = local_import('transcription_tools', reload=True)
|
|
|
|
|
2021-10-11 16:33:52 +02:00
|
|
|
# app_folder = ''
|
|
|
|
# video_path = 'applications/transcription/uploads/media_file.file.bc22f2543688e775.aW1hZ2VmaWxtX2V0ZWFjaGluZ29yZy5tcDQ=.mp4'
|
|
|
|
model = 'private/model'
|
|
|
|
|
|
|
|
|
2021-10-01 10:29:16 +02:00
|
|
|
# ---- example index page ----
|
|
|
|
def index():
|
2021-10-08 15:18:30 +02:00
|
|
|
media_files = db().select(db.media_file.ALL, orderby=db.media_file.title)
|
|
|
|
return dict(media_files=media_files)
|
2021-10-08 09:44:50 +02:00
|
|
|
|
2021-10-11 16:33:52 +02:00
|
|
|
|
2021-10-08 15:18:30 +02:00
|
|
|
@auth.requires_membership('manager')
|
2021-10-11 16:33:52 +02:00
|
|
|
def manage():
|
2021-10-08 15:18:30 +02:00
|
|
|
grid = SQLFORM.smartgrid(db.media_file, linked_tables=['post'])
|
2021-10-08 09:44:50 +02:00
|
|
|
return dict(grid=grid)
|
2021-10-01 10:29:16 +02:00
|
|
|
|
2021-10-11 16:33:52 +02:00
|
|
|
|
|
|
|
def webvtt_single_line():
|
|
|
|
media_file = db.media_file(request.args(0, cast=int)) or redirect(URL('index'))
|
|
|
|
media_path = '{}/{}/{}'.format(request.folder, 'uploads', media_file.file)
|
|
|
|
model_path = '{}/{}'.format(request.folder, model)
|
|
|
|
transkription = transcription_tools.vtt_single_line(model_path, media_path)
|
|
|
|
db(db.media_file.id == media_file.id).update(vtt_single_line=transkription)
|
|
|
|
redirect(request.env.http_referer)
|
|
|
|
|
|
|
|
def webvtt():
|
|
|
|
media_file = db.media_file(request.args(0, cast=int)) or redirect(URL('index'))
|
|
|
|
media_path = '{}/{}/{}'.format(request.folder, 'uploads', media_file.file)
|
|
|
|
model_path = '{}/{}'.format(request.folder, model)
|
|
|
|
transkription = transcription_tools.vtt(model_path, media_path)
|
|
|
|
db(db.media_file.id == media_file.id).update(vtt=transkription)
|
|
|
|
redirect(request.env.http_referer)
|
|
|
|
|
|
|
|
|
|
|
|
def download_webvtt_single_line():
|
|
|
|
media_file = db.media_file(request.args(0, cast=int)) or redirect(URL('index'))
|
|
|
|
webvtt = media_file.vtt_single_line
|
|
|
|
response.headers['Content-Type']='text/vtt'
|
|
|
|
response.headers['Content-Disposition']='attachment; filename=transcript.vtt'
|
|
|
|
f = io.StringIO(webvtt)
|
|
|
|
return(f)
|
|
|
|
|
|
|
|
def download_webvtt():
|
|
|
|
media_file = db.media_file(request.args(0, cast=int)) or redirect(URL('index'))
|
|
|
|
webvtt = media_file.vtt
|
|
|
|
response.headers['Content-Type']='text/vtt'
|
|
|
|
response.headers['Content-Disposition']='attachment; filename=transcript.vtt'
|
|
|
|
f = io.StringIO(webvtt)
|
|
|
|
return(f)
|
|
|
|
|
2021-10-01 10:29:16 +02:00
|
|
|
|
|
|
|
def user():
|
2021-10-11 16:33:52 +02:00
|
|
|
return dict(form=auth())
|