video-service-url-parser

1.0.1 • Public • Published

view on npm view on github npm npm module downloads

Video Services URL Parser

Supports

  • YouTube
  • Dailymotion
  • Vimeo

FIXME exports strategy not working

Video Service URL Parser

Getting Started

On the server

Install the module with: npm install video-service-url-parser

var video_service_url_parser = require('video-service-url-parser');
/*
  {
    service: 'youtube',
    videoId: 'uFHIEynduqM'
  }
*/
video_service_url_parser.parse("https://www.youtube.com/watch?v=uFHIEynduqM"); 

In the browser

Download the production version or the development version.

In your web page:

<script src="dist/video-service-url-parser.min.js"></script>
<script>
/*
  {
    service: 'youtube',
    videoId: 'uFHIEynduqM'
  }
*/
VideoServiceUrlParser("https://www.youtube.com/watch?v=uFHIEynduqM"); 
</script> 

In your code, you can attach video-service-url-parser's methods to any object.

<script src="dist/video-service-url-parser.min.js"></script>
<script>
/*
  {
    service: 'youtube',
    videoId: 'uFHIEynduqM'
  }
*/
VideoServiceUrlParser('http://www.youtube.com/watch?v=uFHIEynduqM');
</script> 

Usage

<script>
/*
  {
    service: 'youtube',
    videoId: 'uFHIEynduqM'
  }
*/
VideoServiceUrlParser('http://www.youtube.com/watch?v=uFHIEynduqM');
VideoServiceUrlParser('http://youtu.be/uFHIEynduqM&foo=bar&fooz=barz');
VideoServiceUrlParser('http://youtube.com/watch?v=uFHIEynduqM&foo=bar&fooz=barz');
VideoServiceUrlParser('http://www.youtube.com/embed/uFHIEynduqM&foo=bar&fooz=barz');
 
/*
  {
    service: 'vimeo',
    videoId: '43233380'
  }
*/
VideoServiceUrlParser('http://vimeo.com/43233380');
VideoServiceUrlParser('https://www.vimeo.com/43233380?foo=bar&fooz=barz');
</script> 

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Also, please don't edit files in the "dist" subdirectory as they are generated via Grunt. You'll find source code in the "lib" subdirectory!

License

Copyright (c) 2015 Thiago Andrade
Licensed under the MIT license.

Package Sidebar

Install

npm i video-service-url-parser

Weekly Downloads

13

Version

1.0.1

License

none

Last publish

Collaborators

  • thiagoh