def yt(request): if request.method == 'POST': form = YTVideoForm(request.POST, request.FILES) user = request.user if request.user.is_authenticated else None if form.is_valid(): handle_youtube_video(form.cleaned_data['name'], form.cleaned_data['url'], user=user, rate=form.cleaned_data['nth'], rescale=form.cleaned_data['rescale'] if 'rescale' in form.cleaned_data else 0) else: raise ValueError else: raise NotImplementedError return redirect('video_list')