Esempio n. 1
0
def notify(request, key):
    """Process vid.ly notification requests."""
    # Verify key matches stored key.
    if key != settings.NOTIFY_KEY:
        return HttpResponseForbidden()

    notification = parseNotify(request)

    # Check for finished videos.
    for task in notification['tasks']:
        if task.finished:
            video = get_object_or_none(Video, shortlink=task.shortlink)
            if video is not None:
                video.state = 'complete'
                video.save()
                send_video_complete_email(video)

    # Check for video errors
    for error in notification['errors']:
        video = get_object_or_none(Video, shortlink=error.shortlink)
        if video is not None:
            video.state = 'error'
            video.save()
            send_video_error_email(video)

    return HttpResponse()
Esempio n. 2
0
def notify(request):
    """Process vid.ly notification requests."""
    notification = parseNotify(request)

    # Verify that user id matches to avoid spoofing (kind've weak)
    if notification and notification['user_id'] == settings.VIDLY_USER_ID:
        try:
            video = Video.objects.get(shortlink=notification['shortlink'])
            video.state = 'complete'
            video.save()
        except Video.DoesNotExist:
            log.warning('Vid.ly notification with shortlink that does not '
                        'exist: %s' % notification['shortlink'])

    return HttpResponse()