15 lines
570 B
Python
15 lines
570 B
Python
from django.utils.translation import gettext_lazy as _
|
|
from django.core.exceptions import ValidationError
|
|
|
|
def validate_stream_url(value, protocols=['rtmp://', 'srt://']):
|
|
# Make sure that the URL uses one of the allowed protocols
|
|
if not any([value.startswith(protocol) for protocol in protocols]):
|
|
raise ValidationError(
|
|
_('Invalid URL: %(value)s. Must start with one of the following: %(protocols)s'),
|
|
params={'value': value, 'protocols': ', '.join(protocols)},
|
|
)
|
|
|
|
# TODO: Add more validation here
|
|
|
|
return value
|