def clean(self):
        cleaned_data = super(VideoForm, self).clean()

        file = cleaned_data.get('file')
        embed_url = cleaned_data.get('embed_url')

        if not file and not embed_url:
            raise forms.ValidationError("You must upload a file or provide an embed URL")

        if embed_url:
            try:
                cleaned_data['embed_object'] = get_embed_object(embed_url)
            except EmbedlyException, e:
                raise forms.ValidationError(str(e))
    def handle(self, *args, **options):
        num_updated = 0
        videos = Video.objects.all()

        for video in videos:
            if video.embed_url and not video.embed_object:
                print "Trying to update '%s'..." % video.name
                try:
                    video.embed_object = get_embed_object(video.embed_url)

                    if video.embed_object:
                        video.save()
                        num_updated = num_updated + 1
                        print "Successfully updated '%s'" % video.name
                    else:
                        print "Couldn't update '%s': No object returned" % video.name
                except EmbedlyException, e:
                    print "Couldn't update '%s': %s" % (video.name, str(e))