Ejemplo n.º 1
0
async def vtt(request, srt):
    t = Transcribe()
    table = dynamodb.Table('Videos')
    db_query = table.get_item(Key={'id': srt}, ConsistentRead=True)
    item = db_query.get('Item')
    if item is None:
        abort(404)
    return response.text(t.srt_mem_to_vtt_mem(item['subs']))
Ejemplo n.º 2
0
async def sub_edit(request, id):
    try:
        jinja_response = {}
        table = dynamodb.Table('Videos')
        db_query = table.get_item(Key={'id': id}, ConsistentRead=True)
        transcribe = Transcribe()
        db_item = db_query['Item']
        subtitle = transcribe.srt_to_edit(db_item['subs'])
        request['session']['vtt'] = transcribe.srt_mem_to_vtt_mem(
            db_item['subs'])
        jinja_response.update({'subtitles': subtitle})
        jinja_response.update({'vtt': '{}'.format(id)})
        jinja_response.update({'id': id})
        jinja_response.update({'video': db_item['link']})

        return jinja_response
    except:
        abort(404)
Ejemplo n.º 3
0
async def interrim_vtt(request):
    variables = request.form
    srt = variables['id'][0]
    start = variables['start'][0]
    end = variables['end'][0]
    text = variables['text'][0]
    index = int(variables['index'][0])
    t = Transcribe()
    if request['session'].get('vtt') is None:
        table = dynamodb.Table('Videos')
        db_query = table.get_item(Key={'id': srt}, ConsistentRead=True)
        item = db_query.get('Item')
        request['session']['vtt'] = t.srt_mem_to_vtt_mem(item['subs'])
    curr_vtt = request['session']['vtt']
    curr_vtt = t.make_change_vtt(curr_vtt, index, start, end, text)
    request['session']['vtt'] = curr_vtt
    return response.json({
        'status': 'ok',
        'uri': '/edit/vtt/{}.vtt'.format(srt)
    })