How to use the js-video-url-parser.parse function in js-video-url-parser

To help you get started, we’ve selected a few js-video-url-parser 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 hennessyevan / netlify-cms-widget-youtube / src / Control.js View on Github external
writeOut = e => {
		if (this.props.field.get("extraInfo")) {
			try {
				const { id, provider, mediaType } = urlParser.parse(e.target.value);
				const videoInfo = urlParser.parse(e.target.value);
				this.props.onChange({
					url: e.target.value,
					id: id,
					mediaType: mediaType,
					imageURL: urlParser.create({
						videoInfo,
						format: "longImage",
						params: { imageQuality: "maxresdefault" }
					})
				});
			} catch (err) {
				console.error("Not a valid Youtube URL");
				this.props.onChange(e.target.value);
			}
		} else {
			this.props.onChange(e.target.value);
github Canner / canner-slate-editor / packages / renderer / renderer / src / components / videoPopover.js View on Github external
checkSource(rule: string, value: string, callback: any) {
    try {
      const videoObj = videoParser.parse(value);

      if (
        (videoObj && videoObj.provider === "youtube") ||
        videoObj.provider === "dailymotion" ||
        videoObj.provider === "vimeo" ||
        videoObj.provider === "youku"
      ) {
        callback();
        return;
      }

      return callback("URL not support");
    } catch (e) {
      return callback("URL not support");
    }
  }
github hennessyevan / netlify-cms-widget-youtube / src / Control.js View on Github external
fetchFromAPI = e => {
		const { id = "" } = urlParser.parse(e.target.value) || "";
		const APIKey = this.props.field.get("APIkey");
		const data = fetch(
			`https://www.googleapis.com/youtube/v3/videos?part=snippet&id=${id}&key=${APIKey}`
		)
			.then(res => res.json())
			.then(json => {
				if (json !== undefined) {
					this.setState({ valid: true, data: json.items[0].snippet });
				} else {
					this.setState({ valid: false });
				}
			})
			.catch(err => {
				this.setState({ valid: false, data: {} });
				return false;
			});
github orange-alliance / the-orange-alliance / src / app / dialogs / match / dialog-match.ts View on Github external
searchVideo() {
    if (this.match && this.match.videoURL) {
      const video = urlParser.parse(this.match.videoURL);
      let embedURL = urlParser.create({
        videoInfo: video,
        params: 'internal',
        format: 'embed'
      });

      if (embedURL) {
        if (embedURL.startsWith('//')) {
          embedURL = 'https:' + embedURL;
        }
        this.videoSafeURL = this.sanitizer.bypassSecurityTrustResourceUrl(embedURL);
      }
    }
  }
}
github moshfeu / y2mp3 / src / services / api.ts View on Github external
export function isYoutubeURL(url: string): boolean {
  return !!url && !!urlParser.parse(url);
}
github Canner / canner-slate-editor / packages / renderer / renderer / src / components / videoPopover.js View on Github external
form.validateFields((err, values) => {
      if (!err) {
        const href = values.href;
        if (href) {
          const videoObj = videoParser.parse(href);
          let slateObj: Object = {};

          if (videoObj && videoObj.provider === "youtube") {
            slateObj = {
              type: youtubeType,
              isVoid: true,
              data: { [idKey]: videoObj.id }
            };
          } else if (videoObj && videoObj.provider === "dailymotion") {
            slateObj = {
              type: dailymotionType,
              isVoid: true,
              data: { [idKey]: videoObj.id }
            };
          } else if (videoObj && videoObj.provider === "vimeo") {
            slateObj = {
github moshfeu / y2mp3 / src / services / api.ts View on Github external
export function fetchVideos(term: string): Promise {
  const parsedTerm = urlParser.parse(term);
  if (!parsedTerm) {
    return Promise.resolve([]);
  }
  if (parsedTerm.list) {
    return fetchVideosFromList(term);
  }
  return fetchVideoFromSingle(term);
}
github hennessyevan / netlify-cms-widget-youtube / src / Control.js View on Github external
validateURL = e => {
		if (urlParser.parse(e.target.value)) {
			this.setState({ valid: true });
		} else {
			this.setState({ valid: false });
		}

		this.writeOut(e);
	};

js-video-url-parser

A parser to extract provider, video id, starttime and others from YouTube, Vimeo, ... urls

MIT
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis

Popular js-video-url-parser functions