jazzband / django-embed-video

Django app for easy embedding YouTube and Vimeo videos and music from SoundCloud.

Home Page:http://django-embed-video.rtfd.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gracefully catch errors if video is "Private"

psyferre opened this issue · comments

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"


Can you make a PR please?