Пример #1
0
    def clean_video_url(self):
        video_url = self.cleaned_data['video_url']

        if video_url:
            try:
                video_type = video_type_registrar.video_type_for_url(video_url)
            except VideoTypeError, e:
                raise forms.ValidationError(e)
            if not video_type:
                for d in video_type_registrar.domains:
                    if d in video_url:
                        raise forms.ValidationError(
                            mark_safe(
                                _(u"""Please try again with a link to a video page.
                        <a href="mailto:%s">Contact us</a> if there's a problem."""
                                  ) % settings.FEEDBACK_EMAIL))

                raise forms.ValidationError(
                    mark_safe(
                        _(u"""You must link to a video on a compatible site (like YouTube) or directly to a
                    video file that works with HTML5 browsers. For example: http://mysite.com/myvideo.ogg or http://mysite.com/myipadvideo.m4v
                    <a href="mailto:%s">Contact us</a> if there's a problem."""
                          ) % settings.FEEDBACK_EMAIL))

            else:
                self._video_type = video_type
                # we need to use the cannonical url as the user provided might need
                # redirection (i.e. youtu.be/fdaf/), and django's validator will
                # choke on redirection (urllib2 for python2.6), see https://unisubs.sifterapp.com/projects/12298/issues/427646/comments
                video_url = video_type.video_url(video_type)

                if not url_exists(video_url):
                    raise forms.ValidationError(
                        _(u'This URL appears to be a broken link.'))
Пример #2
0
    def clean_video_url(self):
        video_url = self.cleaned_data['video_url']
        
        if video_url:
            try:
                video_type = video_type_registrar.video_type_for_url(video_url)
            except VideoTypeError, e:
                raise forms.ValidationError(e)
            if not video_type:
                for d in video_type_registrar.domains:
                    if d in video_url:
                        raise forms.ValidationError(mark_safe(_(u"""Please try again with a link to a video page. 
                        <a href="mailto:%s">Contact us</a> if there's a problem.""") % settings.FEEDBACK_EMAIL))
                    
                raise forms.ValidationError(mark_safe(_(u"""You must link to a video on a compatible site (like YouTube) or directly to a
                    video file that works with HTML5 browsers. For example: http://mysite.com/myvideo.ogg or http://mysite.com/myipadvideo.m4v
                    <a href="mailto:%s">Contact us</a> if there's a problem.""") % settings.FEEDBACK_EMAIL))
                             
            else:
                self._video_type = video_type
                # we need to use the cannonical url as the user provided might need
                # redirection (i.e. youtu.be/fdaf/), and django's validator will
                # choke on redirection (urllib2 for python2.6), see https://unisubs.sifterapp.com/projects/12298/issues/427646/comments
                video_url = video_type.video_url(video_type)

                if not url_exists(video_url) :
                    raise forms.ValidationError(_(u'This URL appears to be a broken link.'))
Пример #3
0
    def __call__(self, value):
        super(UniSubURLValidator, self).__call__(value)

        if self._verify_exists and not value.startswith('http://' + self.host):
            if not url_exists(value):
                raise forms.ValidationError(
                    _(u'This URL appears to be a broken link.'))
Пример #4
0
    def clean_url(self):
        url = self.cleaned_data['url']

        try:
            video_type = video_type_registrar.video_type_for_url(url)

            video_url = video_type.video_url(video_type)

            if video_type.requires_url_exists and  not url_exists(video_url) :
                raise forms.ValidationError(_(u'This URL appears to be a broken link.'))

        except VideoTypeError, e:
            raise forms.ValidationError(e)
Пример #5
0
    def clean_url(self):
        url = self.cleaned_data['url']
        
        try:
            video_type = video_type_registrar.video_type_for_url(url)

            video_url = video_type.video_url(video_type)

            if not url_exists(video_url) :
                raise forms.ValidationError(_(u'This URL appears to be a broken link.'))

        except VideoTypeError, e:
            raise forms.ValidationError(e)
Пример #6
0
    def __call__(self, value):
        super(UniSubURLValidator, self).__call__(value)

        if self._verify_exists and not value.startswith('http://'+self.host):
            if not url_exists(value):
                raise forms.ValidationError(_(u'This URL appears to be a broken link.'))