jazzband / django-embed-video

Django app for easy embedding YouTube and Vimeo videos and music from SoundCloud.
http://django-embed-video.rtfd.org
MIT License
383 stars 137 forks source link

Gracefully catch errors if video is "Private" #83

Closed psyferre closed 2 months ago

psyferre commented 6 years ago

If there a way to gracefully catch errors if a user enters a video link that is marked "private"?

Example: Client user uploads a video to Vimeo and accidentally leaves that video "Private", then enters the video url in the application. The template attempts to retrieve the thumbnail (as illustrated in the docs) and throws an internal server error.

I've replaced all my calls for thumbnails with a fault-tolerant method, but it might be a good idea to handle this out of the box. For anyone else in my situation, this works for me...

    @property
    def thumbnail_url(self):
        """Attempt getting the thumbnail url.  If this doesn't work, return a "problem" graphic"""
        try:
            video = detect_backend(self.link)
            return video.thumbnail
        except VideoDoesntExistException:
            return "/static/images/video-problem.png"
SalahAdDin commented 6 years ago

Can you make a PR please?