From ecd4e7d440514ebf0901778a70174ea911f5e092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Hangst=C3=B6rfer?= Date: Sun, 21 Feb 2016 16:53:29 +0100 Subject: [PATCH] v0.1.6 --- bower.json | 2 +- dist/jsVideoUrlParser.js | 58 ++++++++++++++++++++++++++---------- dist/jsVideoUrlParser.min.js | 2 +- package.json | 2 +- tests/test.js | 16 +++++++++- 5 files changed, 61 insertions(+), 19 deletions(-) diff --git a/bower.json b/bower.json index 9456c15..21c44a9 100644 --- a/bower.json +++ b/bower.json @@ -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", diff --git a/dist/jsVideoUrlParser.js b/dist/jsVideoUrlParser.js index dec39af..1871db5 100644 --- a/dist/jsVideoUrlParser.js +++ b/dist/jsVideoUrlParser.js @@ -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; } } }); diff --git a/dist/jsVideoUrlParser.min.js b/dist/jsVideoUrlParser.min.js index 7491d25..2f1bf0d 100644 --- a/dist/jsVideoUrlParser.min.js +++ b/dist/jsVideoUrlParser.min.js @@ -1 +1 @@ -function URLParser(){"use strict";this.plugins={}}function cloneObject(a){"use strict";if(null===a||"object"!=typeof a)return a;var b=a.constructor();for(var c in a)b[c]=cloneObject(a[c]);return b}function getQueryParams(a){"use strict";if("string"!=typeof a)return{};a=a.split("+").join(" ");var b,c={},d=a.match(/(?:[\?](?:[^=]+)=(?:[^&#]*)(?:[&](?:[^=]+)=(?:[^&#]*))*(?:[#].*)?)|(?:[#].*)/);if(null===d)return{};b=d[0].substr(1).split(/[&#=]/);for(var e=0;e