How to use get-video-id - 8 common examples

To help you get started, we’ve selected a few get-video-id examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wassgha / digital-signage / widgets / slideshow / src / Slide / Youtube.js View on Github external
renderSlideContent(data) {
    const { id, service } = getVideoId(data)
    /* eslint-disable-next-line no-console */
    if (!id || service !== 'youtube') console.error('Failed to parse Youtube URL')
    return (
      <div>
        </div>
github KohheePeace / slate-tuto / src / slate-editor / changes / insertVideo.js View on Github external
const insertVideo = (change, url) => {
  const videoId = getVideoId(url).id
  let src
  if (url.match(/youtube\.com/)) {
    src = `https://www.youtube.com/embed/${videoId}`
  } else if (url.match(/vimeo\.com/)) {
    src = `https://player.vimeo.com/video/${videoId}`
  } else {
    alert('Only accept Youtube or Vimeo url');  /* eslint-disable-line */
    return
  }

  change.insertBlock({
    type: BLOCKS.VIDEO,
    isVoid: true,
    data: { src, url }
  })
}
github meandavejustice / min-vid / webextension / lib / launch-video.js View on Github external
store.get().then(r => {
    const getUrlFn = opts.getUrlFn;
    const action = opts.action;

    delete opts.getUrlFn;
    delete opts.action;

    if (action === 'play') opts.playing = true;
    send(opts = Object.assign({
      id: uuid(),
      width: r.width,
      height: r.height,
      videoId: getVideoId(opts.url) ? getVideoId(opts.url).id : '',
      strings: getLocaleStrings(opts.domain, isAudio(opts.url)),
      // tabId: browser.tabs.TAB.id,
      launchUrl: opts.url,
      currentTime: 0,
      confirm: false,
      confirmContent: '{}'
    }, opts));

    // YouTube playlist handling
    if (opts.domain === 'youtube.com' && !!~opts.url.indexOf('list')) {
      if (!!~opts.url.indexOf('watch?v')) {
        const parsed = parse(opts.url.substr(opts.url.indexOf('?') + 1));
        youtubeHelpers.getPlaylistMeta({
          videoId: parsed.v,
          playlistId: parsed.list
        }, (meta) => {
github sanity-io / sanity / packages / example-studio / components / VideoEmbedInput / VideoEmbedInput.js View on Github external
handleSourceChange = event =&gt; {
    const {type} = this.props
    const inputValue = event.target.value

    this.setState({errorMessage: null})

    if (inputValue.length &lt; 3) {
      return
    }

    const result = getVideoId(inputValue)
    if (!result) {
      this.setState({
        result: null,
        errorMessage: ERROR_UNKNOWN_VIDEO_SERVICE
      })
      return
    }

    if (!result.id) {
      this.setState({
        result: null,
        errorMessage: ERROR_UNKNOWN_VIDEO_ID
      })
      return
    }
github Automattic / wp-calypso / client / state / reader / thumbnails / actions.js View on Github external
export const requestThumbnail = embedUrl => dispatch => {
	const { id, service } = getEmbedMetadata( embedUrl ) || {};
	switch ( service ) {
		case 'youtube': {
			const thumbnailUrl = `https://img.youtube.com/vi/${ id }/mqdefault.jpg`;
			dispatch( receiveThumbnail( embedUrl, thumbnailUrl ) );
			return Promise.resolve();
		}
		case 'videopress': {
			const thumbnailUrl = `https://thumbs.videopress.com/${ id }?c=1`;
			dispatch( receiveThumbnail( embedUrl, thumbnailUrl ) );
			return Promise.resolve();
		}
		case 'vimeo': {
			debug( `Requesting thumbnail for embed ${ embedUrl }` );
			dispatch( {
				type: READER_THUMBNAIL_REQUEST,
				embedUrl,
github sanity-io / sanity / packages / example-studio / components / VideoEmbedPreview.js View on Github external
function getEmbedCode(value) {
  if (!value || !value.url) {
    return <span>[Video]</span>
  }

  const videoId = (value &amp;&amp; value.url) ? getVideoId(value.url) : ''

  if (!videoId) {
    return <span>Unrecognized video service. Supported services: {Object.keys(SERVICES).join(', ')}</span>
  }
  if (!(videoId.service in SERVICES)) {
    return <span>Unsupported video service: {videoId.service}</span>
  }

  return SERVICES[videoId.service](videoId.id)
}
export default class YoutubeVideo extends React.Component {
github penta-jelly / re-radio / server / src / radio / songs-explorer / youtube / youtube.service.ts View on Github external
public parseVideoUrl(url: string): VideoReturnType {
    const { id, service } = getVideoId(url);
    if (!id) throw new InternalServerErrorException('Invalid url');
    if (service !== 'youtube') throw new NotAcceptableException(`Service ${service} is not supported yet`);
    return { id, service };
  }
github Automattic / wp-calypso / client / lib / post-normalizer / rule-content-detect-media.js View on Github external
const getAutoplayIframe = iframe => {
	const KNOWN_SERVICES = [ 'youtube', 'vimeo', 'videopress' ];
	const metadata = getEmbedMetadata( iframe.src );
	if ( metadata && includes( KNOWN_SERVICES, metadata.service ) ) {
		const autoplayIframe = iframe.cloneNode();
		if ( autoplayIframe.src.indexOf( '?' ) === -1 ) {
			autoplayIframe.src += '?autoplay=1';
		} else {
			autoplayIframe.src += '&autoplay=1';
		}
		return autoplayIframe.outerHTML;
	}
	return null;
};

get-video-id

Get the YouTube, Vimeo, Vine, VideoPress, TikTok, Microsoft Stream, Loom or Dailymotion video id from a url or embed string.

MIT
Latest version published 2 months ago

Package Health Score

75 / 100
Full package analysis

Popular get-video-id functions