Skip to content

Commit

Permalink
v0.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Zod- committed Feb 21, 2016
1 parent ff9777c commit ecd4e7d
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 19 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsVideoUrlParser",
"version": "0.1.5",
"version": "0.1.6",
"homepage": "https://github.com/Zod-/jsVideoUrlParser",
"authors": [{
"name": "Julian Hangstörfer",
Expand Down
58 changes: 43 additions & 15 deletions dist/jsVideoUrlParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,29 +272,57 @@ urlParser.bind({
urlParser.bind({
provider: 'vimeo',
alternatives: ['vimeopro'],
parse: function (url) {
parse: function (url, params) {
"use strict";
var match,
id;
match = url.match(/(?:\/(?:channels\/[\w]+|(?:album\/\d+\/)?videos?))?\/(\d+)/i);
id = match ? match[1] : undefined;
if (!id) {
var match;
var result = {
mediaType: 'video',
params: params
};

match = url.match(
/(?:\/(?:channels\/[\w]+|(?:(?:album\/\d+|groups\/[\w]+)\/)?videos?))?\/(\d+)/i
);
result.id = match ? match[1] : undefined;

if (!result.id) {
return undefined;
}
return {
'mediaType': 'video',
'id': id
};

if (params.hasOwnProperty('t')) {
params.start = getTime(params.t);
delete params.t;
}

return result;
},
defaultFormat: 'long',
formats:{
long: function(vi, params){
formats: {
long: function (vi, params) {
"use strict";
return 'https://vimeo.com/' + vi.id + combineParams({params: params});
var url = 'https://vimeo.com/' + vi.id;
var startTime = params.start;
delete params.start;
url += combineParams({
params: params
});
if (startTime) {
url += '#t=' + startTime;
}
return url;
},
embed: function(vi, params){
embed: function (vi, params) {
"use strict";
return '//player.vimeo.com/video/' + vi.id + combineParams({params: params});
var url = '//player.vimeo.com/video/' + vi.id;
var startTime = params.start;
delete params.start;
url += combineParams({
params: params
});
if (startTime) {
url += '#t=' + startTime;
}
return url;
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion dist/jsVideoUrlParser.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-video-url-parser",
"version": "0.1.5",
"version": "0.1.6",
"description": "A parser to extract provider, video id, starttime and others from YouTube, Vimeo, ... urls",
"main": "dist/jsVideoUrlParser.js",
"repository": {
Expand Down
16 changes: 15 additions & 1 deletion tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ QUnit.test("Vimeo URLs", function (assert) {
embed: '//player.vimeo.com/video/97688625'
},
urls: ['https://vimeo.com/groups/shortfilms/videos/97688625',
'//player.vimeo.com/video/97688625'
'//player.vimeo.com/video/97688625',
'https://vimeo.com/groups/1minute/videos/97688625'
]
}, {
videoInfo: cloneObject(vi),
Expand All @@ -322,11 +323,24 @@ QUnit.test("Vimeo URLs", function (assert) {
urls: ['http://vimeopro.com/staff/frame/video/24069938',
'//player.vimeo.com/video/24069938'
]
}, {
videoInfo: cloneObject(vi),
formats: {
long: 'https://vimeo.com/36881035#t=208',
embed: '//player.vimeo.com/video/36881035#t=208'
},
urls: ['https://vimeo.com/36881035#t=3m28s',
'//player.vimeo.com/video/36881035#t=3m28s'
]
}];

tests[1].videoInfo.id = '96186586';
tests[2].videoInfo.id = '97688625';
tests[3].videoInfo.id = '24069938';
tests[4].videoInfo.id = '36881035';
tests[4].videoInfo.params = {
start: 208
};
assertUrlTest(assert, tests);
});

Expand Down

0 comments on commit ecd4e7d

Please sign in to comment.