Exemplo n.º 1
0
def save_manifest_in_model(house_id, m3u8_manifest):
    
    # 
    # Search de Video, if exist return Error
    try:
	video = Video.objects.get(house_id=house_id)
	return False
    except:
	video = Video()
	video.house_id = house_id
	video.format   = 'hls'
	video.save()

    for rendition in m3u8_manifest.files:
	profile = Profile()
	profile.video = video
	profile.bandwidth  	= rendition['bandwidth']
        profile.average    	= rendition['average']
        profile.codecs     	= rendition['codecs']
        profile.resolution 	= rendition['resolution']
        profile.filename   	= rendition['filename']
	profile.version	   	= rendition['rendition'].header['version']
	profile.media_seq  	= rendition['rendition'].header['media_seq']
	profile.allow_cache	= rendition['rendition'].header['allow_cache']
	profile.target_duration = rendition['rendition'].header['target_duration']
	profile.save()
	for tsfile in rendition['rendition'].files:
	    profile_file = ProfileFile()
	    profile_file.profile  = profile
	    profile_file.number   = tsfile['number']
	    profile_file.extinf   = tsfile['extinf']
	    profile_file.filename = tsfile['filename']
	    profile_file.save()

    return True
Exemplo n.º 2
0
def cm_PostCuePoint(request):
    if request.method == 'GET':
        return TemplateResponse(request, 'cue_manager.html')

    if request.method != 'POST':
        status = http_METHOD_NOT_ALLOWED
        return HttpResponse('', status=status)

    if 'house_id' in request.POST.keys():
        house_id = request.POST['house_id']
    else:
       status = http_BAD_REQUEST
       return HttpResponse('', status=status)

    if house_id == '':
        status = http_BAD_REQUEST
        return HttpResponse('', status=status)

    languages = Language.objects.all()

    for key, value  in request.POST.iteritems():
        if key.endswith('_tc') and value != '':
            i, t = key.split('_')
            for lang in languages:
                lang_key = '%s_%s' % (i, lang.code)
                if lang_key in request.POST.keys() and request.POST[lang_key] != '':
                    try:
                        video = Video.objects.get(house_id = house_id)
                    except:
                        video = Video()
                        video.house_id = house_id
                        video.save()
                    cuepoint          = CuePoint()
                    cuepoint.video    = video
                    cuepoint.timecode = value
                    cuepoint.language = lang
                    cuepoint.name     = request.POST[lang_key]
                    cuepoint.save()

    status = http_POST_OK
    return TemplateResponse(request, 'cue_manager.html')