Skip to content

Commit

Permalink
Docs: Custom backends
Browse files Browse the repository at this point in the history
  • Loading branch information
yetty committed Aug 22, 2013
1 parent 2a4fe97 commit f7f6b4b
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,37 @@ Admin examples



Custom backends
###############################################

If you have specific needs and default backends don't suits you, you can write
your custom backend.

``my_project/my_app/backends.py``::

from embed_video.backends import VideoBackend

class CustomBackend(VideoBackend):
re_detect = re.compile(r'http://myvideo\.com/[0-9]+')
re_code = re.compile(r'http://myvideo\.com/(?P<code>[0-9]+)')

pattern_url = 'http://play.myvideo.com/c/%s/'
pattern_thumbnail_url = 'http://thumb.myvideo.com/c/%s/'

You can also overwrite :py:class:`~embed_video.backends.VideoBackend` methods,
if using regular expressions isn't good enough for you.

``my_project/my_project/settings.py``::

EMBED_VIDEO_BACKENDS = (
'embed_video.backends.YoutubeBackend',
'embed_video.backends.VimeoBackend',
'embed_video.backends.SoundCloudBackend',
'my_app.backends.CustomBackend',
)



Low level API examples
###############################################

Expand Down

0 comments on commit f7f6b4b

Please sign in to comment.