2017-10-31 14:57:26 +00:00
|
|
|
from django.core.validators import RegexValidator
|
|
|
|
|
2018-03-31 06:18:35 +00:00
|
|
|
# Supported formats:
|
|
|
|
# - http://(www.)youtube.com/watch?v=Dhjiu89G3
|
|
|
|
# - http://(www.)youtube.com/watch/Dhjiu89G3
|
|
|
|
# - http://youtu.be/Dhjiu89G3
|
2017-10-31 14:57:26 +00:00
|
|
|
|
|
|
|
class YoutubeURLValidator(RegexValidator):
|
|
|
|
regex = r'https?:\/\/(((www.)?youtube.com\/((watch\?v=)|(watch\/)))|(youtu.be\/))([A-z0-9]{1,11}).+'
|
2018-03-31 06:18:35 +00:00
|
|
|
|
|
|
|
# Supported Vimeo formats:
|
|
|
|
# - http://(www.)vimeo.com/258651879
|
|
|
|
# - http://player.vimeo.com/video/258651879
|
|
|
|
|
|
|
|
class VimeoURLValidator(RegexValidator):
|
|
|
|
regex = r'https?:\/\/(player|www.)?vimeo.com\/([0-9]{1,11}).+'
|
|
|
|
|
|
|
|
class YouTubeOrVimeoValidator(RegexValidator):
|
|
|
|
regex = r'https?:\/\/(player.|www.)?(vimeo\.com|youtu(be\.com|\.be))\/(video\/|embed\/|watch\?v=|v\/)?([A-Za-z0-9]{1,11}).+'
|