Backends¶
- exception embed_video.backends.EmbedVideoException[source]¶
Parental class for all embed_video exceptions
- class embed_video.backends.SoundCloudBackend(url, is_secure=False)[source]¶
Backend for SoundCloud URLs.
- exception embed_video.backends.UnknownBackendException[source]¶
Exception thrown if video backend is not recognized.
- exception embed_video.backends.UnknownIdException[source]¶
Exception thrown if backend is detected, but video ID cannot be parsed.
- class embed_video.backends.VideoBackend(url, is_secure=False)[source]¶
Base class used as parental class for backends.
class MyBackend(VideoBackend): ...
- allow_https = True¶
Sets if HTTPS version allowed for specific backend.
- get_embed_code(width, height)[source]¶
Returns embed code rendered from template template_name.
- get_thumbnail_url()[source]¶
Returns thumbnail URL folded from pattern_thumbnail_url and parsed code.
- get_url()[source]¶
Returns URL folded from pattern_url and parsed code.
- classmethod is_valid(url)[source]¶
Class method to control if passed url is valid for current backend. By default it is done by re_detect regex.
- pattern_thumbnail_url = None¶
Pattern in which the code is inserted to get thumbnail url.
Example: http://static.myvideo.com/thumbs/%s
- pattern_url = None¶
Pattern in which the code is inserted.
Example: http://myvideo.com?code=%s
- re_code = None¶
Compiled regex (re.compile()) to search code in URL.
Example: re.compile(r'myvideo\.com/\?code=(?P<code>\w+)')
- re_detect = None¶
Compilede regec (re.compile()) to detect, if input URL is valid for current backend.
Example: re.compile(r'^http://myvideo\.com/.*')
- template_name = 'embed_video/embed_code.html'¶
Name of embed code template used by get_embed_code().
Passed template variables: {{ backend }} (instance of VideoBackend), {{ width }}, {{ height }}
- exception embed_video.backends.VideoDoesntExistException[source]¶
Exception thrown if video doesn’t exist
- embed_video.backends.detect_backend(url)[source]¶
Detect the right backend for given URL.
Goes over backends in settings.EMBED_VIDEO_BACKENDS, calls is_valid() and returns backend instance.