Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-video-url-parser

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-video-url-parser - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

lib/base.js

39

package.json
{
"name": "js-video-url-parser",
"version": "0.2.4",
"version": "0.2.5",
"description": "A parser to extract provider, video id, starttime and others from YouTube, Vimeo, ... urls",
"main": "dist/jsVideoUrlParser.js",
"main": "lib/index.js",
"repository": {

@@ -18,3 +18,5 @@ "type": "git",

"Youku",
"Coub"
"Coub",
"Wistia",
"SoundCloud"
],

@@ -30,17 +32,22 @@ "author": {

"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-jshint": "~0.11.0",
"grunt-contrib-qunit": "~0.5.2",
"grunt-contrib-concat": "~0.5.1",
"grunt-contrib-uglify": "~0.8.0"
"@babel/core": "^7.0.0-beta.38",
"@babel/preset-env": "^7.0.0-beta.38",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^8.2.1",
"babel-preset-minify": "^0.2.0",
"eslint": "^4.16.0",
"eslint-plugin-jest": "^21.7.0",
"jest": "^22.1.4",
"rollup": "^0.54.1",
"rollup-plugin-babel": "^4.0.0-beta.0",
"rollup-plugin-commonjs": "^8.2.6",
"rollup-plugin-minify-es": "^1.1.1",
"rollup-plugin-node-resolve": "^3.0.2"
},
"scripts": {
"test": "grunt test"
},
"files": [
"dist/",
"tests/",
"README.md",
"LICENSE"
]
"test": "./node_modules/.bin/jest --coverage",
"build": "./node_modules/.bin/rollup -c rollup.config.js",
"lint": "./node_modules/.bin/eslint . --fix",
"lintdryfix": "./node_modules/.bin/eslint . --fix-dry-run"
}
}

@@ -14,17 +14,17 @@ jsVideoUrlParser [![Build Status](https://travis-ci.org/Zod-/jsVideoUrlParser.svg)](https://travis-ci.org/Zod-/jsVideoUrlParser) [![Gitter](https://badges.gitter.im/Zod-/jsVideoUrlParser.svg)](https://gitter.im/Zod-/jsVideoUrlParser?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

- Coub
- Wistia
- SoundCloud
# grunt
# Building Locally
```
npm install
npm run lint
npm run test
npm run build
```
```shell
$ grunt
$ grunt build
$ grunt test
$ grunt dist
#build and test specific plugins
$ grunt --youtube --vimeo
$ grunt build --youtube --vimeo
$ grunt test --youtube --vimeo
$ grunt dist --youtube --vimeo
# npm
```
npm install js-video-url-parser
```

@@ -35,11 +35,20 @@ # bower

```
# npm
```
npm install js-video-url-parser
```
# Usage
## Node
## ES2015+ / Webpack
```
urlParser = require('js-video-url-parser');
// All plugins
import urlParser from "js-video-url-parser";
// Choose individual plugins
import urlParser from "js-video-url-parser/lib/base";
import "js-video-url-parser/lib/provider/canalplus';
import "js-video-url-parser/lib/provider/coub';
import "js-video-url-parser/lib/provider/dailymotion';
import "js-video-url-parser/lib/provider/twitch';
import "js-video-url-parser/lib/provider/vimeo';
import "js-video-url-parser/lib/provider/wistia';
import "js-video-url-parser/lib/provider/youku';
import "js-video-url-parser/lib/provider/youtube';
```

@@ -120,8 +129,8 @@ ## Parsing

Add a new file in the `src/plugins/provider/` directory with the template found [here](src/plugins/provider/Template.js) and also add it in the [Gruntfile](https://github.com/Zod-/jsVideoUrlParser/blob/master/Gruntfile.js#L13).
Add a new file in the `lib/provider/` directory with the template found [here](lib/provider/template.js) and also add it to [index.js](lib/index.js).
<br>
Add some tests in `tests/src/plugins/provider/` with the template found
[here](tests/src/plugins/provider/Template.js).
Add some tests in `lib/provider/` with the template found
[here](lib/provider/template.test.js).
Run `grunt build test --template` to create the parser and test your plugin.
Run `npm run test` to create the parser and test your plugin.

@@ -656,1 +665,233 @@ # Plugins

```
## Wistia
#### Supported media types:
* `'video'`: Regular videos.
* `'embedvideo'`: Any links that do not include the channel name are embedded links.
#### Supported url formats:
* `'long'`(default): Regular urls.
* `'embed'`: Regular embedded urls using iframe.
* `'embedjsonp'`: jsonp specific embedded urls.
#### Creating urls with different media types:
| mediaType/formats| long | embed | embedjsonp |
| ------------- | :--: | :--: | :--: |
| **video** | ✓ | ✓ | ✓ |
| **embedvideo** | X | ✓ | ✓ |
#### Special parameters:
* `'params.start'`: The number where the video should begin in seconds.
#### Parsing Examples:
```javascript
> urlParser.parse('https://appboss.wistia.com/medias/lpu6bgplle');
{ mediaType: 'video',
channel: 'appboss',
id: 'lpu6bgplle',
provider: 'wistia'
}
> urlParser.parse('https://fast.wistia.com/embed/iframe/lpu6bgplle');
> urlParser.parse('https://fast.wistia.com/embed/medias/lpu6bgplle.jsonp');
> urlParser.parse('https://content.wistia.com/customer-stories/bizzabo?wvideo=lpu6bgplle');
> urlParser.parse('https://wistia.com/blog/soapbox-videos-for-the-holidays?wvideo=lpu6bgplle');
> urlParser.parse('https://wistia.com/library/how-to-look-good-on-a-webcam?wvideo=lpu6bgplle');
> urlParser.parse('https://wistia.com/solutions/sales?wvideo=lpu6bgplle');
{ mediaType: 'embedvideo',
id: 'lpu6bgplle',
provider: 'wistia'
}
> urlParser.parse('https://appboss.wistia.com/medias/lpu6bgplle?wtime=1m30s');
{ mediaType: 'video',
channel: 'appboss',
id: 'lpu6bgplle',
provider: 'wistia'
params: {
start: 90
}
}
> urlParser.parse('https://fast.wistia.com/embed/iframe/lpu6bgplle?wtime=30');
{ mediaType: 'embedvideo',
id: 'lpu6bgplle',
provider: 'wistia'
params: {
start: 90
}
}
```
#### Creation Examples:
```javascript
> urlParser.create({
videoInfo: {
provider: 'wistia',
channel: 'appboss',
id: 'lpu6bgplle',
mediaType: 'video'
},
format: <format>
})
'long': 'https://appboss.wistia.com/medias/lpu6bgplle'
'embed': 'https://fast.wistia.com/embed/iframe/lpu6bgplle'
'embedjsonp': 'https://fast.wistia.com/embed/medias/lpu6bgplle.jsonp'
> urlParser.create({
videoInfo: {
provider: 'wistia',
channel: 'appboss',
id: 'lpu6bgplle',
mediaType: 'video'
},
params: {
start: 90
},
format: <format>
})
'long': 'https://appboss.wistia.com/medias/lpu6bgplle?wtime=90'
'embed': 'https://fast.wistia.com/embed/iframe/lpu6bgplle?wtime=90'
'embedjsonp': 'https://fast.wistia.com/embed/medias/lpu6bgplle.jsonp'
> urlParser.create({
videoInfo: {
provider: 'wistia',
id: 'lpu6bgplle',
mediaType: 'embedvideo'
},
format: <format>
})
'embed': 'https://fast.wistia.com/embed/iframe/lpu6bgplle'
'embedjsonp': 'https://fast.wistia.com/embed/medias/lpu6bgplle.jsonp'
> urlParser.create({
videoInfo: {
provider: 'wistia',
id: 'lpu6bgplle',
mediaType: 'embedvideo'
},
params: {
start: 90
},
format: <format>
})
'embed': 'https://fast.wistia.com/embed/iframe/lpu6bgplle?wtime=90'
'embedjsonp': 'https://fast.wistia.com/embed/medias/lpu6bgplle.jsonp'
```
## SoundCloud
#### Supported media types:
* `'track'`: Regular tracks.
* `'playlist'`: Lists of tracks, including albums, singles, EPs, playlists.
* `'embedtrack'`: Embed track is a seperate media type because SoundCloud uses different ids to embed.
* `'embedplaylist'`: Same reason as embedtrack.
#### Supported url formats:
* `'long'`(default): Regular urls.
* `'embed'`: Embedded urls using iframe.
#### Creating urls with different media types:
| mediaType/formats| long | embed |
| ------------- | :--: | :--: | :--: |
| **track** | ✓ | X |
| **playlist** | ✓ | X |
| **embedtrack** | ✓ | ✓ |
| **embedplaylist** | ✓ | ✓ |
#### Special parameters:
* `'list'`: On playlist types the list property will be set with the list id.
* `'channel'`: The channel containing the track or playlist. Will not be set with embed types.
* `'params.start'`: The number where the video should begin in seconds.
#### Parsing Examples:
```javascript
> urlParser.parse('https://soundcloud.com/julian-hangst-rfer/odsf0dif92w3j_adfw-edf-1-asdf-1');
{ mediaType: 'track',
channel: 'julian-hangst-rfer',
id: 'odsf0dif92w3j_adfw-edf-1-asdf-1',
provider: 'soundcloud'
}
> urlParser.parse('https://soundcloud.com/julian-hangst-rfer/sets/dif92w-e_e');
{ mediaType: 'playlist',
channel: 'julian-hangst-rfer',
list: 'dif92w-e_e',
provider: 'soundcloud'
}
> urlParser.parse('https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/388050272');
> urlParser.parse('https://api.soundcloud.com/tracks/388050272');
{ mediaType: 'embedtrack',
id: '388050272',
provider: 'soundcloud'
}
> urlParser.parse('https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/playlists/430366544');
> urlParser.parse('https://api.soundcloud.com/playlists/430366544');
{ mediaType: 'embedplaylist',
list: '430366544',
provider: 'soundcloud'
}
> urlParser.parse('https://soundcloud.com/julian-hangst-rfer/odsf0dif92w3j_adfw-edf-1-asdf-1#t=0:30');
{ mediaType: 'track',
channel: 'julian-hangst-rfer',
id: 'odsf0dif92w3j_adfw-edf-1-asdf-1',
provider: 'soundcloud',
params: {
start: 30
}
}
```
#### Creation Examples:
```javascript
> urlParser.create({
videoInfo: {
provider: 'soundcloud',
channel: 'julian-hangst-rfer',
id: 'odsf0dif92w3j_adfw-edf-1-asdf-1',
mediaType: 'track'
},
format: <format>
})
'long': 'https://soundcloud.com/julian-hangst-rfer/odsf0dif92w3j_adfw-edf-1-asdf-1'
> urlParser.create({
videoInfo: {
provider: 'soundcloud',
channel: 'julian-hangst-rfer',
list: 'dif92w-e_e',
mediaType: 'playlist'
},
format: <format>
})
'long': 'https://soundcloud.com/julian-hangst-rfer/sets/dif92w-e_e'
> urlParser.create({
videoInfo: {
provider: 'soundcloud',
id: '388050272',
mediaType: 'embedtrack'
},
format: <format>
})
'long': 'https://api.soundcloud.com/tracks/388050272'
'embed': 'https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/388050272'
> urlParser.create({
videoInfo: {
provider: 'soundcloud',
list: '430366544',
mediaType: 'embedplaylist'
},
format: <format>
})
'long': 'https://api.soundcloud.com/playlist/430366544'
'embed': 'https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/playlist/430366544'
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc