1 | 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)
|
2 | ================
|
3 |
|
4 | A javascript parser to extract informations like provider, id, channel, start time from media urls.
|
5 |
|
6 | Currently supports
|
7 | - YouTube
|
8 | - Vimeo
|
9 | - Twitch
|
10 | - Dailymotion
|
11 | - Canal+
|
12 | - Youku
|
13 | - Coub
|
14 | - Wistia
|
15 | - SoundCloud
|
16 |
|
17 | # Building Locally
|
18 | ```
|
19 | npm install
|
20 | npm run lint
|
21 | npm run test
|
22 | npm run build
|
23 | ```
|
24 |
|
25 | # npm
|
26 | ```
|
27 | npm install js-video-url-parser
|
28 | ```
|
29 |
|
30 | # bower
|
31 | ```shell
|
32 | bower install js-video-url-parser
|
33 | ```
|
34 |
|
35 | # Usage
|
36 | ## ES2015+ / Webpack
|
37 | ```
|
38 | // All plugins
|
39 | import urlParser from "js-video-url-parser";
|
40 |
|
41 | // Choose individual plugins
|
42 | import urlParser from "js-video-url-parser/lib/base";
|
43 | import "js-video-url-parser/lib/provider/canalplus';
|
44 | import "js-video-url-parser/lib/provider/coub';
|
45 | import "js-video-url-parser/lib/provider/dailymotion';
|
46 | import "js-video-url-parser/lib/provider/twitch';
|
47 | import "js-video-url-parser/lib/provider/vimeo';
|
48 | import "js-video-url-parser/lib/provider/wistia';
|
49 | import "js-video-url-parser/lib/provider/youku';
|
50 | import "js-video-url-parser/lib/provider/youtube';
|
51 |
|
52 | ```
|
53 | ## Parsing
|
54 |
|
55 | Parsing a url will return a videoInfo object with all the information
|
56 |
|
57 | ```javascript
|
58 | > urlParser.parse('http://www.youtube.com/watch?v=HRb7B9fPhfA')
|
59 | { mediaType: 'video',
|
60 | id: 'HRb7B9fPhfA',
|
61 | provider: 'youtube' }
|
62 |
|
63 | > urlParser.parse('https://vimeo.com/97276391')
|
64 | { mediaType: 'video',
|
65 | id: '97276391',
|
66 | provider: 'vimeo' }
|
67 | ```
|
68 |
|
69 | Any url parameters expect for ids will be saved in the params object. Some
|
70 | providers have special parameters for example the start parameter which dictates
|
71 | at how many seconds the video starts. Special parameters can be found in the
|
72 | different descriptions for the providers.
|
73 | ```javascript
|
74 | > urlParser.parse('https://www.youtube.com/watch?v=6xLcSTDeB7A&index=25&list=PL46F0A159EC02DF82&t=1m40')
|
75 | {
|
76 | provider: 'youtube',
|
77 | id: 'yQaAGmHNn9s',
|
78 | list: 'PL46F0A159EC02DF82',
|
79 | mediaType: 'video',
|
80 | params: {
|
81 | start: 100,
|
82 | index: '25'
|
83 | }
|
84 | }
|
85 | ```
|
86 |
|
87 | Parsing an incorrect url will return undefined
|
88 | ```javascript
|
89 | > urlParser.parse('https://www.youuutube.com/watch?v=97276391')
|
90 | undefined
|
91 | ```
|
92 |
|
93 | ## Url Creation
|
94 |
|
95 | The videoInfo objects can be turned back into urls with the `.create` function.
|
96 | The required parameter for this is the videoInfo object itself. Optional ones are
|
97 | the format of the url and the url parameters that should be added. Each provider
|
98 | has it's own default format.
|
99 |
|
100 | ```javascript
|
101 | > urlParser.create({
|
102 | videoInfo: {
|
103 | provider: 'youtube',
|
104 | id: 'HRb7B9fPhfA',
|
105 | mediaType: 'video'
|
106 | },
|
107 | format: 'long',
|
108 | params: {
|
109 | foo: 'bar'
|
110 | }
|
111 | })
|
112 | 'https://www.youtube.com/watch?foo=bar&v=HRb7B9fPhfA'
|
113 | ```
|
114 | Parsing and creating can also be chained together to clean up an url for example.
|
115 | If you still want to reuse the generated parameters object you can use the keyword
|
116 | `'internal'` as params.
|
117 |
|
118 | ```javascript
|
119 | > urlParser.create({
|
120 | videoInfo: urlParser.parse('https://youtube.com/watch?foo=bar&v=HRb7B9fPhfA')
|
121 | })
|
122 | 'https://www.youtube.com/watch?v=HRb7B9fPhfA'
|
123 |
|
124 | > urlParser.create({
|
125 | videoInfo: urlParser.parse('https://youtube.com/watch?foo=bar&v=HRb7B9fPhfA'),
|
126 | params: 'internal'
|
127 | })
|
128 | 'https://www.youtube.com/watch?foo=bar&v=HRb7B9fPhfA'
|
129 | ```
|
130 |
|
131 | ## Adding a provider
|
132 |
|
133 | 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).
|
134 | <br>
|
135 | Add some tests in `lib/provider/` with the template found
|
136 | [here](lib/provider/template.test.js).
|
137 |
|
138 | Run `npm run test` to create the parser and test your plugin.
|
139 |
|
140 | # Plugins
|
141 |
|
142 | ## YouTube
|
143 |
|
144 | #### Supported media types:
|
145 | * `'video'`: Regular videos which can also be livestreams.
|
146 | * `'playlist'`: YouTube playlist.
|
147 | * `'share'`: Shared YouTube videos that link to a special website and are not actual videos themselves.
|
148 | * `'channel'`: YouTube channels, which are the same as users.
|
149 |
|
150 | #### Supported url formats:
|
151 | * `'short'`: Shortened urls.
|
152 | * `'long'`(default): Regular urls.
|
153 | * `'embed'`: Embedded urls.
|
154 | * `'shortImage'`: Shortened thumbnail urls.
|
155 | * `'longImage'`: Regular thumbnail urls.
|
156 |
|
157 | #### Creating urls with different media types:
|
158 |
|
159 | | mediaType/formats| short | long | embed | shortImage | longImage |
|
160 | | ------------- | :--: | :--: | :--: | :--: | :--: |
|
161 | | **video** | ✓ | ✓ | ✓ | ✓ | ✓ |
|
162 | | **playlist** | X | ✓ | ✓ | X | X |
|
163 | | **share** | X | ✓ | X | X | X |
|
164 | | **channel** | X | ✓ | X | X | X |
|
165 |
|
166 | #### Special parameters:
|
167 | * `'name'`: Sometimes you get the name of a channel instead of the `'id'`.
|
168 | * `'params.start'`: The number where the video should begin in seconds.
|
169 | * `'params.imageQuality'`: Custom parameter for generating different qualities of thumbnail urls.
|
170 | * `'0', '1', '2', '3', 'default', 'hqdefault'(default), 'mqdefault', 'sddefault', 'maxresdefault'`
|
171 |
|
172 | #### Parsing Examples:
|
173 | ```javascript
|
174 | > urlParser.parse('http://www.youtube.com/watch?v=HRb7B9fPhfA');
|
175 | > urlParser.parse('http://youtu.be/HRb7B9fPhfA');
|
176 | > urlParser.parse('https://m.youtube.com/details?v=HRb7B9fPhfA');
|
177 | > urlParser.parse('https://gdata.youtube.com/feeds/api/videos/HRb7B9fPhfA/related');
|
178 | > urlParser.parse('https://i.ytimg.com/vi/HRb7B9fPhfA/hqdefault.jpg');
|
179 | > urlParser.parse('https://img.youtube.com/vi/HRb7B9fPhfA/hqdefault.jpg');
|
180 | { mediaType: 'video',
|
181 | id: 'HRb7B9fPhfA',
|
182 | provider: 'youtube' }
|
183 |
|
184 | > urlParser.parse('http://www.youtube.com/embed/videoseries?list=PL46F0A159EC02DF82');
|
185 | > urlParser.parse('http://www.youtube.com/playlist?list=PL46F0A159EC02DF82');
|
186 | { mediaType: 'playlist',
|
187 | list: 'PL46F0A159EC02DF82',
|
188 | provider: 'youtube'}
|
189 |
|
190 | > urlParser.parse('http://www.youtube.com/watch?v=yQaAGmHNn9s&list=PL46F0A159EC02DF82');
|
191 | { mediaType: 'video',
|
192 | id: 'yQaAGmHNn9s',
|
193 | list: 'PL46F0A159EC02DF82',
|
194 | provider: 'youtube'
|
195 | }
|
196 |
|
197 | > urlParser.parse('http://www.youtube.com/watch?v=yQaAGmHNn9s&list=PL46F0A159EC02DF82#t=1m40');
|
198 | { mediaType: 'video',
|
199 | id: 'yQaAGmHNn9s',
|
200 | list: 'PL46F0A159EC02DF82',
|
201 | provider: 'youtube'
|
202 | params: {
|
203 | start: 100
|
204 | }
|
205 | }
|
206 |
|
207 | > urlParser.parse('https://www.youtube.com/channel/UCzQUP1qoWDoEbmsQxvdjxgQ');
|
208 | { mediaType: 'channel',
|
209 | id: 'UCzQUP1qoWDoEbmsQxvdjxgQ',
|
210 | provider: 'youtube'
|
211 | }
|
212 |
|
213 | > urlParser.parse('https://www.youtube.com/user/PowerfulJRE');
|
214 | > urlParser.parse('https://www.youtube.com/c/PowerfulJRE');
|
215 | { mediaType: 'channel',
|
216 | name: 'PowerfulJRE',
|
217 | provider: 'youtube'
|
218 | }
|
219 | ```
|
220 |
|
221 | #### Creation Examples:
|
222 | ```javascript
|
223 | > urlParser.create({
|
224 | videoInfo: {
|
225 | provider: 'youtube',
|
226 | id: 'HRb7B9fPhfA',
|
227 | mediaType: 'video'
|
228 | },
|
229 | format: <format>
|
230 | })
|
231 | 'long': 'https://www.youtube.com/watch?v=HRb7B9fPhfA'
|
232 | 'short': 'https://youtu.be/HRb7B9fPhfA'
|
233 | 'embed': 'https://www.youtube.com/embed/HRb7B9fPhfA'
|
234 | 'shortImage': 'https://i.ytimg.com/vi/HRb7B9fPhfA/hqdefault.jpg'
|
235 | 'longImage': 'https://img.youtube.com/vi/HRb7B9fPhfA/hqdefault.jpg'
|
236 |
|
237 | > urlParser.create({
|
238 | videoInfo: {
|
239 | provider: 'youtube',
|
240 | id: 'HRb7B9fPhfA',
|
241 | mediaType: 'video'
|
242 | },
|
243 | params: {
|
244 | start: 90
|
245 | },
|
246 | format: <format>
|
247 | })
|
248 | 'long': 'https://www.youtube.com/watch?v=HRb7B9fPhfA#t=90'
|
249 | 'short': 'https://youtu.be/HRb7B9fPhfA#t=90'
|
250 | 'embed': 'https://www.youtube.com/embed/HRb7B9fPhfA?start=90'
|
251 |
|
252 | > urlParser.create({
|
253 | videoInfo: {
|
254 | provider: 'youtube',
|
255 | id: 'HRb7B9fPhfA',
|
256 | list: 'PL46F0A159EC02DF82',
|
257 | mediaType: 'video'
|
258 | },
|
259 | format: <format>
|
260 | })
|
261 | 'long': 'https://www.youtube.com/watch?list=PL46F0A159EC02DF82&v=HRb7B9fPhfA'
|
262 | 'embed': 'https://www.youtube.com/embed/HRb7B9fPhfA?list=PL46F0A159EC02DF82'
|
263 |
|
264 | > urlParser.create({
|
265 | videoInfo: {
|
266 | provider: 'youtube',
|
267 | list: 'PL46F0A159EC02DF82',
|
268 | mediaType: 'playlist'
|
269 | },
|
270 | format: <format>
|
271 | })
|
272 | 'long': 'https://www.youtube.com/playlist?feature=share&list=PL46F0A159EC02DF82'
|
273 | 'embed': 'https://www.youtube.com/embed?list=PL46F0A159EC02DF82&listType=playlist'
|
274 |
|
275 | > urlParser.create({
|
276 | videoInfo: {
|
277 | provider: 'youtube',
|
278 | id: 'UCzQUP1qoWDoEbmsQxvdjxgQ',
|
279 | mediaType: 'channel'
|
280 | },
|
281 | format: 'long'
|
282 | })
|
283 | 'long': 'https://www.youtube.com/channel/UCzQUP1qoWDoEbmsQxvdjxgQ'
|
284 |
|
285 | > urlParser.create({
|
286 | videoInfo: {
|
287 | provider: 'youtube',
|
288 | name: 'PowerfulJRE',
|
289 | mediaType: 'channel'
|
290 | },
|
291 | format: 'long'
|
292 | })
|
293 | 'long': 'https://www.youtube.com/c/PowerfulJRE'
|
294 |
|
295 | > urlParser.create({
|
296 | videoInfo: {
|
297 | provider: 'youtube',
|
298 | id: 'HRb7B9fPhfA',
|
299 | mediaType: 'video'
|
300 | },
|
301 | params:{
|
302 | imageQuality: <quality>
|
303 | },
|
304 | format: 'shortImage'
|
305 | })
|
306 | '0': 'https://i.ytimg.com/vi/HRb7B9fPhfA/0.jpg'
|
307 | '1': 'https://i.ytimg.com/vi/HRb7B9fPhfA/1.jpg'
|
308 | '2': 'https://i.ytimg.com/vi/HRb7B9fPhfA/2.jpg'
|
309 | '3': 'https://i.ytimg.com/vi/HRb7B9fPhfA/3.jpg'
|
310 | 'hqdefault': 'https://i.ytimg.com/vi/HRb7B9fPhfA/hqdefault.jpg'
|
311 | 'sddefault': 'https://i.ytimg.com/vi/HRb7B9fPhfA/sddefault.jpg'
|
312 | 'mqdefault': 'https://i.ytimg.com/vi/HRb7B9fPhfA/mqdefault.jpg'
|
313 | 'maxresdefault': 'https://i.ytimg.com/vi/HRb7B9fPhfA/maxresdefault.jpg'
|
314 |
|
315 | > urlParser.create({
|
316 | videoInfo: {
|
317 | provider: 'youtube',
|
318 | id: 'HRb7B9fPhfA',
|
319 | mediaType: 'video'
|
320 | },
|
321 | params:{
|
322 | imageQuality: <quality>
|
323 | },
|
324 | format: 'longImage'
|
325 | })
|
326 | '0': 'https://img.youtube.com/vi/HRb7B9fPhfA/0.jpg'
|
327 | '1': 'https://img.youtube.com/vi/HRb7B9fPhfA/1.jpg'
|
328 | '2': 'https://img.youtube.com/vi/HRb7B9fPhfA/2.jpg'
|
329 | '3': 'https://img.youtube.com/vi/HRb7B9fPhfA/3.jpg'
|
330 | 'hqdefault': 'https://img.youtube.com/vi/HRb7B9fPhfA/hqdefault.jpg'
|
331 | 'sddefault': 'https://img.youtube.com/vi/HRb7B9fPhfA/sddefault.jpg'
|
332 | 'mqdefault': 'https://img.youtube.com/vi/HRb7B9fPhfA/mqdefault.jpg'
|
333 | 'maxresdefault': 'https://img.youtube.com/vi/HRb7B9fPhfA/maxresdefault.jpg'
|
334 | ```
|
335 |
|
336 | ## Vimeo
|
337 |
|
338 | #### Supported media types:
|
339 | * `'video'`: Regular videos
|
340 |
|
341 | #### Supported url formats:
|
342 | * `'long'`(default): Regular urls.
|
343 | * `'embed'`: Embedded urls.
|
344 |
|
345 | #### Creating urls with different media types:
|
346 |
|
347 | | mediaType/formats| long | embed |
|
348 | | ------------- | :--: | :--: |
|
349 | | **video** | ✓ | ✓ |
|
350 |
|
351 | #### Special parameters:
|
352 | * `'params.start'`: The number where the video should begin in seconds.
|
353 |
|
354 | #### Parsing Examples:
|
355 | ```javascript
|
356 | > urlParser.parse('https://vimeo.com/97276391');
|
357 | > urlParser.parse('https://vimeo.com/channels/staffpicks/97276391');
|
358 | { id: '97276391',
|
359 | mediaType: 'video',
|
360 | provider: 'vimeo' }
|
361 |
|
362 | > urlParser.parse('https://vimeo.com/album/2903155/video/96186586');
|
363 | { id: '96186586',
|
364 | mediaType: 'video',
|
365 | provider: 'vimeo' }
|
366 |
|
367 | > urlParser.parse('https://vimeo.com/groups/shortfilms/videos/97688625');
|
368 | { id: '97688625',
|
369 | mediaType: 'video',
|
370 | provider: 'vimeo' }
|
371 |
|
372 | > urlParser.parse('http://vimeopro.com/staff/frame/video/24069938');
|
373 | { id: '24069938',
|
374 | mediaType: 'video',
|
375 | provider: 'vimeo' }
|
376 |
|
377 | > urlParser.parse('https://vimeo.com/97276391#t=1m30s');
|
378 | { id: '97276391',
|
379 | mediaType: 'video',
|
380 | provider: 'vimeo',
|
381 | params: {
|
382 | start: 90
|
383 | }
|
384 | }
|
385 | ```
|
386 |
|
387 | #### Creation Examples:
|
388 | ```javascript
|
389 | > urlParser.create({
|
390 | videoInfo: {
|
391 | provider: 'vimeo',
|
392 | id: '97276391',
|
393 | mediaType: 'video'
|
394 | },
|
395 | format: <format>
|
396 | })
|
397 | 'long': 'https://vimeo.com/97276391'
|
398 | 'embed': '//player.vimeo.com/video/97276391'
|
399 |
|
400 | > urlParser.create({
|
401 | videoInfo: {
|
402 | provider: 'vimeo',
|
403 | id: '97276391',
|
404 | mediaType: 'video',
|
405 | params: {
|
406 | start: 90
|
407 | }
|
408 | },
|
409 | format: <format>
|
410 | })
|
411 | 'long': 'https://vimeo.com/97276391#t=90'
|
412 | 'embed': '//player.vimeo.com/video/97276391#t=90'
|
413 | ```
|
414 |
|
415 | ## Twitch
|
416 |
|
417 | #### Supported media types:
|
418 | * `'stream'`: Streams which are just a direct url to a channel.
|
419 | * `'video'`: Part of streams or history of a full stream.
|
420 | * `'clip'`: Short video clips that can be created by anyone on a stream.
|
421 |
|
422 | #### Supported url formats:
|
423 | * `'long'`(default): Regular urls.
|
424 | * `'embed'`: Embedded urls.
|
425 |
|
426 | #### Creating urls with different media types:
|
427 |
|
428 | | mediaType/formats| long | embed |
|
429 | | ------------- | :--: | :--: |
|
430 | | **stream** | ✓ | ✓ |
|
431 | | **video** | ✓ | ✓ |
|
432 | | **clip** | ✓ | ✓ |
|
433 |
|
434 | #### Special parameters:
|
435 | * `'params.start'`: The number where the video should begin in seconds.
|
436 |
|
437 | ```javascript
|
438 | > urlParser.parse('http://www.twitch.tv/rains8');
|
439 | > urlParser.parse('http://www.twitch.tv/widgets/live_embed_player.swf?channel=rains8');
|
440 | > urlParser.parse('http://twitch.tv/rains8/chat');
|
441 | { mediaType: 'stream',
|
442 | channel: 'rains8',
|
443 | provider: 'twitch' }
|
444 |
|
445 | > urlParser.parse('http://www.twitch.tv/75292411');
|
446 | { mediaType: 'video',
|
447 | id: 'v75292411',
|
448 | provider: 'twitch' }
|
449 |
|
450 | > urlParser.parse('http://www.twitch.tv/75292411?t=1m30s');
|
451 | { mediaType: 'video',
|
452 | id: 'v75292411',
|
453 | provider: 'twitch',
|
454 | params: {
|
455 | start: 90
|
456 | }
|
457 | }
|
458 |
|
459 | > urlParser.parse('https://clips.twitch.tv/SuspiciousImpartialLarkItsBoshyTime');
|
460 | > urlParser.parse('https://clips.twitch.tv/embed?clip=SuspiciousImpartialLarkItsBoshyTime');
|
461 | { mediaType: 'clip',
|
462 | id: 'SuspiciousImpartialLarkItsBoshyTime',
|
463 | provider: 'twitch' }
|
464 | ```
|
465 |
|
466 | #### Creation Examples:
|
467 | ```javascript
|
468 | > urlParser.create({
|
469 | videoInfo: {
|
470 | provider: 'twitch',
|
471 | channel: 'rains8',
|
472 | mediaType: 'stream'
|
473 | },
|
474 | format: <format>
|
475 | })
|
476 | 'long': 'https://twitch.tv/rains8'
|
477 | 'embed': 'https://player.twitch.tv/?channel=rains8'
|
478 |
|
479 | > urlParser.create({
|
480 | videoInfo: {
|
481 | provider: 'twitch',
|
482 | id: 'v75292411',
|
483 | mediaType: 'video'
|
484 | },
|
485 | format: <format>
|
486 | })
|
487 | 'long': 'https://twitch.tv/75292411'
|
488 | 'embed': 'https://player.twitch.tv/?video=v75292411'
|
489 |
|
490 | > urlParser.create({
|
491 | videoInfo: {
|
492 | provider: 'twitch',
|
493 | id: 'v75292411',
|
494 | mediaType: 'video',
|
495 | params: {
|
496 | start: 90
|
497 | }
|
498 | },
|
499 | format: <format>
|
500 | })
|
501 | 'long': 'https://twitch.tv/75292411?t=90s'
|
502 | 'embed': 'https://player.twitch.tv/?video=v75292411?=90s'
|
503 |
|
504 | > urlParser.create({
|
505 | videoInfo: {
|
506 | provider: 'twitch',
|
507 | id: 'SuspiciousImpartialLarkItsBoshyTime',
|
508 | mediaType: 'clip'
|
509 | },
|
510 | format: <format>
|
511 | })
|
512 | 'long': 'https://clips.twitch.tv/SuspiciousImpartialLarkItsBoshyTime'
|
513 | 'embed': 'https://clips.twitch.tv/embed?clip=SuspiciousImpartialLarkItsBoshyTime'
|
514 | ```
|
515 |
|
516 | ## Dailymotion
|
517 |
|
518 | #### Supported media types:
|
519 | * `'video'`: Regular videos.
|
520 |
|
521 | #### Supported url formats:
|
522 | * `'short'`: Shortened urls.
|
523 | * `'long'`(default): Regular urls.
|
524 | * `'embed'`: Embedded urls.
|
525 |
|
526 | #### Creating urls with different media types:
|
527 |
|
528 | | mediaType/formats| short | long | embed |
|
529 | | ------------- | :--: | :--: | :--: |
|
530 | | **video** | ✓ | ✓ | ✓ |
|
531 |
|
532 | #### Special parameters:
|
533 | * `'params.start'`: The number where the video should begin in seconds.
|
534 |
|
535 | #### Parsing Examples:
|
536 | ```javascript
|
537 | > urlParser.parse('http://www.dailymotion.com/video/x1e2b95_bruce-lee-nin-kayip-kedisi_animals');
|
538 | > urlParser.parse('http://www.dailymotion.com/video/x1e2b95');
|
539 | > urlParser.parse('http://dai.ly/x1e2b95');
|
540 | > urlParser.parse('http://www.dailymotion.com/embed/video/x1e2b95');
|
541 | { mediaType: 'video',
|
542 | id: 'x1e2b95',
|
543 | provider: 'dailymotion' }
|
544 |
|
545 | > urlParser.parse('http://www.dailymotion.com/video/x1e2b95_bruce-lee-nin-kayip-kedisi_animals?start=10');
|
546 | > urlParser.parse('http://www.dailymotion.com/embed/video/x1e2b95?start=10');
|
547 | > urlParser.parse('http://www.dailymotion.com/video/x1e2b95?start=10');
|
548 | { mediaType: 'video',
|
549 | id: 'x1e2b95',
|
550 | provider: 'dailymotion',
|
551 | params: {
|
552 | start: 10
|
553 | }
|
554 | }
|
555 | ```
|
556 |
|
557 | #### Creation Examples:
|
558 | ```javascript
|
559 | > urlParser.create({
|
560 | videoInfo: {
|
561 | provider: 'dailymotion',
|
562 | id: 'x1e2b95',
|
563 | mediaType: 'video'
|
564 | },
|
565 | format: <format>
|
566 | })
|
567 | 'long': 'https://www.dailymotion.com/video/x1e2b95'
|
568 | 'short': 'https://dai.ly/x1e2b95'
|
569 | 'embed': '//www.dailymotion.com/embed/video/x1e2b95'
|
570 |
|
571 | > urlParser.create({
|
572 | videoInfo: {
|
573 | provider: 'dailymotion',
|
574 | id: 'x1e2b95',
|
575 | mediaType: 'video',
|
576 | params: {
|
577 | start: 10
|
578 | }
|
579 | },
|
580 | format: <format>
|
581 | })
|
582 | 'long': 'https://www.dailymotion.com/video/x1e2b95?start=10'
|
583 | 'short': 'https://dai.ly/x1e2b95?start=10'
|
584 | 'embed': '//www.dailymotion.com/embed/video/x1e2b95?start=10'
|
585 | ```
|
586 |
|
587 | ## Coub
|
588 |
|
589 | #### Supported media types:
|
590 | * `'video'`: Regular videos.
|
591 |
|
592 | #### Supported url formats:
|
593 | * `'long'`(default): Regular urls.
|
594 | * `'embed'`: Embedded urls.
|
595 |
|
596 | #### Creating urls with different media types:
|
597 |
|
598 | | mediaType/formats| long | embed |
|
599 | | ------------- | :--: | :--: |
|
600 | | **video** | ✓ | ✓ |
|
601 |
|
602 | #### Parsing Examples:
|
603 | ```javascript
|
604 | > urlParser.parse('https://coub.com/view/by7sm');
|
605 | > urlParser.parse('//coub.com/embed/by7sm');
|
606 | { mediaType: 'video',
|
607 | id: 'by7sm',
|
608 | provider: 'coub' }
|
609 | ```
|
610 |
|
611 | #### Creation Examples:
|
612 | ```javascript
|
613 | > urlParser.create({
|
614 | videoInfo: {
|
615 | provider: 'coub',
|
616 | id: 'by7sm',
|
617 | mediaType: 'video'
|
618 | },
|
619 | format: <format>
|
620 | })
|
621 | 'long': 'https://coub.com/view/by7sm'
|
622 | 'embed': '//coub.com/embed/by7sm'
|
623 | ```
|
624 |
|
625 | ## Youku
|
626 |
|
627 | #### Supported media types:
|
628 | * `'video'`: Regular videos.
|
629 |
|
630 | #### Supported url formats:
|
631 | * `'long'`(default): Regular urls.
|
632 | * `'static'`: Video player that fills out the whole website.
|
633 | * `'embed'`: Embedded urls.
|
634 | * `'flash'`: Flash embedded urls.
|
635 |
|
636 | #### Creating urls with different media types:
|
637 |
|
638 | | mediaType/formats| long | static | embed | flash |
|
639 | | ------------- | :--: | :--: | :--: | :--: |
|
640 | | **video** | ✓ | ✓ | ✓ | ✓ |
|
641 |
|
642 | #### Parsing Examples:
|
643 | ```javascript
|
644 | > urlParser.parse('http://player.youku.com/embed/XMTQ3OTM4MzMxMg');
|
645 | > urlParser.parse('http://player.youku.com/player.php/sid/XMTQ3OTM4MzMxMg/v.swf');
|
646 | > urlParser.parse('http://v.youku.com/v_show/id_XMTQ3OTM4MzMxMg');
|
647 | > urlParser.parse('http://static.youku.com/v1.0.0638/v/swf/loader.swf?VideoIDS=XMTQ3OTM4MzMxMg');
|
648 | { mediaType: 'video',
|
649 | id: 'XMTQ3OTM4MzMxMg',
|
650 | provider: 'youku' }
|
651 | ```
|
652 |
|
653 | #### Creation Examples:
|
654 | ```javascript
|
655 | > urlParser.create({
|
656 | videoInfo: {
|
657 | provider: 'youku',
|
658 | id: 'XMTQ3OTM4MzMxMg',
|
659 | mediaType: 'video'
|
660 | },
|
661 | format: <format>
|
662 | })
|
663 | 'embed': 'http://player.youku.com/embed/XMTQ3OTM4MzMxMg',
|
664 | 'long': 'http://v.youku.com/v_show/id_XMTQ3OTM4MzMxMg',
|
665 | 'flash': 'http://player.youku.com/player.php/sid/XMTQ3OTM4MzMxMg/v.swf',
|
666 | 'static': 'http://static.youku.com/v1.0.0638/v/swf/loader.swf?VideoIDS=XMTQ3OTM4MzMxMg'
|
667 | ```
|
668 |
|
669 | ## Canal+
|
670 |
|
671 | #### Supported media types:
|
672 | * `'video'`: Regular videos.
|
673 |
|
674 | #### Supported url formats:
|
675 | * `'embed'`(default): Embedded urls.
|
676 |
|
677 | #### Creating urls with different media types:
|
678 |
|
679 | | mediaType/formats| embed |
|
680 | | ------------- | :--: |
|
681 | | **video** | ✓ |
|
682 |
|
683 | #### Parsing Examples:
|
684 | ```javascript
|
685 | > urlParser.parse('http://player.canalplus.fr/embed/?param=cplus&vid=1365175');
|
686 | > urlParser.parse('http://www.canalplus.fr/humour/pid1784-les-guignols.html?vid=1365175');
|
687 | { mediaType: 'video',
|
688 | id: '1365175',
|
689 | provider: 'canalplus' }
|
690 | ```
|
691 |
|
692 | #### Creation Examples:
|
693 | ```javascript
|
694 | > urlParser.create({
|
695 | videoInfo: {
|
696 | provider: 'canalplus',
|
697 | id: '1365175',
|
698 | mediaType: 'video'
|
699 | },
|
700 | format: <format>
|
701 | })
|
702 | 'embed': 'http://player.canalplus.fr/embed/?param=cplus&vid=1365175',
|
703 | ```
|
704 |
|
705 | ## Wistia
|
706 |
|
707 | #### Supported media types:
|
708 | * `'video'`: Regular videos.
|
709 | * `'embedvideo'`: Any links that do not include the channel name are embedded links.
|
710 |
|
711 | #### Supported url formats:
|
712 | * `'long'`(default): Regular urls.
|
713 | * `'embed'`: Regular embedded urls using iframe.
|
714 | * `'embedjsonp'`: jsonp specific embedded urls.
|
715 |
|
716 | #### Creating urls with different media types:
|
717 |
|
718 | | mediaType/formats| long | embed | embedjsonp |
|
719 | | ------------- | :--: | :--: | :--: |
|
720 | | **video** | ✓ | ✓ | ✓ |
|
721 | | **embedvideo** | X | ✓ | ✓ |
|
722 |
|
723 | #### Special parameters:
|
724 | * `'params.start'`: The number where the video should begin in seconds.
|
725 |
|
726 | #### Parsing Examples:
|
727 | ```javascript
|
728 | > urlParser.parse('https://appboss.wistia.com/medias/lpu6bgplle');
|
729 | { mediaType: 'video',
|
730 | channel: 'appboss',
|
731 | id: 'lpu6bgplle',
|
732 | provider: 'wistia'
|
733 | }
|
734 |
|
735 | > urlParser.parse('https://fast.wistia.com/embed/iframe/lpu6bgplle');
|
736 | > urlParser.parse('https://fast.wistia.com/embed/medias/lpu6bgplle.jsonp');
|
737 | > urlParser.parse('https://content.wistia.com/customer-stories/bizzabo?wvideo=lpu6bgplle');
|
738 | > urlParser.parse('https://wistia.com/blog/soapbox-videos-for-the-holidays?wvideo=lpu6bgplle');
|
739 | > urlParser.parse('https://wistia.com/library/how-to-look-good-on-a-webcam?wvideo=lpu6bgplle');
|
740 | > urlParser.parse('https://wistia.com/solutions/sales?wvideo=lpu6bgplle');
|
741 | { mediaType: 'embedvideo',
|
742 | id: 'lpu6bgplle',
|
743 | provider: 'wistia'
|
744 | }
|
745 |
|
746 | > urlParser.parse('https://appboss.wistia.com/medias/lpu6bgplle?wtime=1m30s');
|
747 | { mediaType: 'video',
|
748 | channel: 'appboss',
|
749 | id: 'lpu6bgplle',
|
750 | provider: 'wistia'
|
751 | params: {
|
752 | start: 90
|
753 | }
|
754 | }
|
755 |
|
756 | > urlParser.parse('https://fast.wistia.com/embed/iframe/lpu6bgplle?wtime=30');
|
757 | { mediaType: 'embedvideo',
|
758 | id: 'lpu6bgplle',
|
759 | provider: 'wistia'
|
760 | params: {
|
761 | start: 90
|
762 | }
|
763 | }
|
764 | ```
|
765 |
|
766 | #### Creation Examples:
|
767 | ```javascript
|
768 | > urlParser.create({
|
769 | videoInfo: {
|
770 | provider: 'wistia',
|
771 | channel: 'appboss',
|
772 | id: 'lpu6bgplle',
|
773 | mediaType: 'video'
|
774 | },
|
775 | format: <format>
|
776 | })
|
777 | 'long': 'https://appboss.wistia.com/medias/lpu6bgplle'
|
778 | 'embed': 'https://fast.wistia.com/embed/iframe/lpu6bgplle'
|
779 | 'embedjsonp': 'https://fast.wistia.com/embed/medias/lpu6bgplle.jsonp'
|
780 |
|
781 | > urlParser.create({
|
782 | videoInfo: {
|
783 | provider: 'wistia',
|
784 | channel: 'appboss',
|
785 | id: 'lpu6bgplle',
|
786 | mediaType: 'video'
|
787 | },
|
788 | params: {
|
789 | start: 90
|
790 | },
|
791 | format: <format>
|
792 | })
|
793 | 'long': 'https://appboss.wistia.com/medias/lpu6bgplle?wtime=90'
|
794 | 'embed': 'https://fast.wistia.com/embed/iframe/lpu6bgplle?wtime=90'
|
795 | 'embedjsonp': 'https://fast.wistia.com/embed/medias/lpu6bgplle.jsonp'
|
796 |
|
797 | > urlParser.create({
|
798 | videoInfo: {
|
799 | provider: 'wistia',
|
800 | id: 'lpu6bgplle',
|
801 | mediaType: 'embedvideo'
|
802 | },
|
803 | format: <format>
|
804 | })
|
805 | 'embed': 'https://fast.wistia.com/embed/iframe/lpu6bgplle'
|
806 | 'embedjsonp': 'https://fast.wistia.com/embed/medias/lpu6bgplle.jsonp'
|
807 |
|
808 | > urlParser.create({
|
809 | videoInfo: {
|
810 | provider: 'wistia',
|
811 | id: 'lpu6bgplle',
|
812 | mediaType: 'embedvideo'
|
813 | },
|
814 | params: {
|
815 | start: 90
|
816 | },
|
817 | format: <format>
|
818 | })
|
819 | 'embed': 'https://fast.wistia.com/embed/iframe/lpu6bgplle?wtime=90'
|
820 | 'embedjsonp': 'https://fast.wistia.com/embed/medias/lpu6bgplle.jsonp'
|
821 | ```
|
822 |
|
823 | ## SoundCloud
|
824 |
|
825 | #### Supported media types:
|
826 | * `'track'`: Regular tracks.
|
827 | * `'playlist'`: Lists of tracks, including albums, singles, EPs, playlists.
|
828 | * `'apitrack'`: SoundCloud uses integer based ids for their api. Track can be resolved to apitrack using their `/resolve` endpoint
|
829 | * `'apiplaylist'`: Same reason as apitrack.
|
830 |
|
831 | #### Supported url formats:
|
832 | * `'long'`(default): Regular urls.
|
833 | * `'embed'`: Embedded urls using iframe.
|
834 |
|
835 | #### Creating urls with different media types:
|
836 |
|
837 | | mediaType/formats| long | embed |
|
838 | | ------------- | :--: | :--: |
|
839 | | **track** | ✓ | X |
|
840 | | **playlist** | ✓ | X |
|
841 | | **apitrack** | ✓ | ✓ |
|
842 | | **apiplaylist** | ✓ | ✓ |
|
843 |
|
844 | #### Special parameters:
|
845 | * `'list'`: On playlist types the list property will be set with the list id.
|
846 | * `'channel'`: The channel containing the track or playlist. Will not be set with api types.
|
847 | * `'params.start'`: The number where the video should begin in seconds.
|
848 |
|
849 | #### Parsing Examples:
|
850 | ```javascript
|
851 | > urlParser.parse('https://soundcloud.com/julian-hangst-rfer/odsf0dif92w3j_adfw-edf-1-asdf-1');
|
852 | { mediaType: 'track',
|
853 | channel: 'julian-hangst-rfer',
|
854 | id: 'odsf0dif92w3j_adfw-edf-1-asdf-1',
|
855 | provider: 'soundcloud'
|
856 | }
|
857 |
|
858 | > urlParser.parse('https://soundcloud.com/julian-hangst-rfer/sets/dif92w-e_e');
|
859 | { mediaType: 'playlist',
|
860 | channel: 'julian-hangst-rfer',
|
861 | list: 'dif92w-e_e',
|
862 | provider: 'soundcloud'
|
863 | }
|
864 |
|
865 | > urlParser.parse('https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/388050272');
|
866 | > urlParser.parse('https://api.soundcloud.com/tracks/388050272');
|
867 | { mediaType: 'apitrack',
|
868 | id: '388050272',
|
869 | provider: 'soundcloud'
|
870 | }
|
871 |
|
872 | > urlParser.parse('https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/playlists/430366544');
|
873 | > urlParser.parse('https://api.soundcloud.com/playlists/430366544');
|
874 | { mediaType: 'apiplaylist',
|
875 | list: '430366544',
|
876 | provider: 'soundcloud'
|
877 | }
|
878 |
|
879 | > urlParser.parse('https://soundcloud.com/julian-hangst-rfer/odsf0dif92w3j_adfw-edf-1-asdf-1#t=0:30');
|
880 | { mediaType: 'track',
|
881 | channel: 'julian-hangst-rfer',
|
882 | id: 'odsf0dif92w3j_adfw-edf-1-asdf-1',
|
883 | provider: 'soundcloud',
|
884 | params: {
|
885 | start: 30
|
886 | }
|
887 | }
|
888 | ```
|
889 |
|
890 | #### Creation Examples:
|
891 | ```javascript
|
892 | > urlParser.create({
|
893 | videoInfo: {
|
894 | provider: 'soundcloud',
|
895 | channel: 'julian-hangst-rfer',
|
896 | id: 'odsf0dif92w3j_adfw-edf-1-asdf-1',
|
897 | mediaType: 'track'
|
898 | },
|
899 | format: <format>
|
900 | })
|
901 | 'long': 'https://soundcloud.com/julian-hangst-rfer/odsf0dif92w3j_adfw-edf-1-asdf-1'
|
902 |
|
903 | > urlParser.create({
|
904 | videoInfo: {
|
905 | provider: 'soundcloud',
|
906 | channel: 'julian-hangst-rfer',
|
907 | list: 'dif92w-e_e',
|
908 | mediaType: 'playlist'
|
909 | },
|
910 | format: <format>
|
911 | })
|
912 | 'long': 'https://soundcloud.com/julian-hangst-rfer/sets/dif92w-e_e'
|
913 |
|
914 | > urlParser.create({
|
915 | videoInfo: {
|
916 | provider: 'soundcloud',
|
917 | id: '388050272',
|
918 | mediaType: 'apitrack'
|
919 | },
|
920 | format: <format>
|
921 | })
|
922 | 'long': 'https://api.soundcloud.com/tracks/388050272'
|
923 | 'embed': 'https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/388050272'
|
924 |
|
925 | > urlParser.create({
|
926 | videoInfo: {
|
927 | provider: 'soundcloud',
|
928 | list: '430366544',
|
929 | mediaType: 'apiplaylist'
|
930 | },
|
931 | format: <format>
|
932 | })
|
933 | 'long': 'https://api.soundcloud.com/playlist/430366544'
|
934 | 'embed': 'https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/playlist/430366544'
|
935 | ```
|