const YOUTUBE = /^(?:https:\/\/)?(?:www.)?(?:youtube.com\/watch\?v=|youtu.be\/)([a-zA-Z0-9_-]{11})(?:.+)?$/;
const VIMEO = /^(?:https:\/\/)?(?:www.)?vimeo.com\/([a-zA-Z0-9]*)$/;
const SRF = /^(?:https:\/\/)?(?:www.)?srf.ch\/(?:[\w/-]*)[?&]id=([\w-]+)(?:[&\w=-]*)$/;

export function isYoutubeUrl(url) {
  return YOUTUBE.test(url);
}

export function isVimeoUrl(url) {
  return VIMEO.test(url);
}

export function isSrfUrl(url) {
  return SRF.test(url);
}

export function getVideoId(url) {
  if (isYoutubeUrl(url)) {
    return YOUTUBE.exec(url)[1];
  } else if (isVimeoUrl(url)) {
    return VIMEO.exec(url)[1];
  } else if (isSrfUrl(url)) {
    return SRF.exec(url)[1];
  } else {
    return '';
  }
}
