def detect_backend(url):
for backend_name in EMBED_VIDEO_BACKENDS:<EOL><INDENT>backend = import_by_path(backend_name)<EOL>if backend.is_valid(url):<EOL><INDENT>return backend(url)<EOL><DEDENT><DEDENT>raise UnknownBackendException<EOL>
Detect the right backend for given URL.

Goes over backends in ``settings.EMBED_VIDEO_BACKENDS``,
calls :py:func:`~VideoBackend.is_valid` and returns backend instance.

:param url: URL which is passed to `is_valid` methods of VideoBackends.
:type url: str

:return: Returns recognized VideoBackend
:rtype: VideoBackend