mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-17 01:16:00 +00:00
Modules
This commit is contained in:
3
node_modules/video-thumbnail-url/.babelrc
generated
vendored
Normal file
3
node_modules/video-thumbnail-url/.babelrc
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"presets": ["es2015"]
|
||||
}
|
1
node_modules/video-thumbnail-url/.npmignore
generated
vendored
Normal file
1
node_modules/video-thumbnail-url/.npmignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
5
node_modules/video-thumbnail-url/.travis.yml
generated
vendored
Normal file
5
node_modules/video-thumbnail-url/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "4"
|
||||
- "5"
|
||||
- "6"
|
52
node_modules/video-thumbnail-url/README.md
generated
vendored
Normal file
52
node_modules/video-thumbnail-url/README.md
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
[](https://travis-ci.org/Producters/video-thumbnail-url)
|
||||
|
||||
video-thumbnail-url
|
||||
===========================
|
||||
|
||||
Get thumbnail URL for a given video URL. Supports youtube, vimeo and facebook.
|
||||
|
||||
|
||||
# Install
|
||||
|
||||
```sh
|
||||
npm install video-thumbnail-url
|
||||
```
|
||||
|
||||
# Usage
|
||||
|
||||
```javascript
|
||||
import getThumb from 'video-thumbnail-url';
|
||||
|
||||
getThumb('https://www.youtube.com/watch?v=dQw4w9WgXcQ').then(thumb_url => { // thumb_url is url or null
|
||||
console.log(thumb_url); // http://img.youtube.com/vi/dQw4w9WgXcQ/hqdefault.jpg
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
# Recognized video urls
|
||||
|
||||
```
|
||||
Youtube:
|
||||
|
||||
https://www.youtube.com/embed/[video-id]'
|
||||
https://youtu.be/[video-id]'
|
||||
https://www.youtube.com/watch?v=[video-id]'
|
||||
|
||||
Vimeo:
|
||||
|
||||
http://vimeo.com/[video-id]
|
||||
http://player.vimeo.com/video/[video-id]
|
||||
https://vimeo.com/channels/[channel]/[video-id]
|
||||
https://vimeo.com/groups/[group]/videos/[video-id]
|
||||
|
||||
Facebook:
|
||||
|
||||
https://www.facebook.com/[user]/videos/[video-id]/
|
||||
|
||||
```
|
||||
|
||||
# Test
|
||||
|
||||
```sh
|
||||
npm test
|
||||
```
|
84
node_modules/video-thumbnail-url/dist/index.js
generated
vendored
Normal file
84
node_modules/video-thumbnail-url/dist/index.js
generated
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = getThumbnailURL;
|
||||
|
||||
var _url = require('url');
|
||||
|
||||
var _bluebird = require('bluebird');
|
||||
|
||||
var _bluebird2 = _interopRequireDefault(_bluebird);
|
||||
|
||||
var _requestPromise = require('request-promise');
|
||||
|
||||
var _requestPromise2 = _interopRequireDefault(_requestPromise);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
//extract id from url path
|
||||
var RE_VIMEO = /^(?:\/video|\/channels\/[\w-]+|\/groups\/[\w-]+\/videos)?\/(\d+)$/;
|
||||
var RE_YOUTUBE = /^(?:\/embed)?\/([\w-]{10,12})$/;
|
||||
var RE_FACEBOOK = /^\/[\w-]+\/videos\/(\d+)(\/)?$/;
|
||||
|
||||
function getThumbnailURL(url) {
|
||||
return _bluebird2.default.try(function () {
|
||||
url = url || '';
|
||||
|
||||
var urlobj = (0, _url.parse)(url, true);
|
||||
|
||||
//youtube
|
||||
if (['www.youtube.com', 'youtube.com', 'youtu.be'].indexOf(urlobj.host) !== -1) {
|
||||
var video_id = null;
|
||||
if ('v' in urlobj.query) {
|
||||
if (urlobj.query.v && urlobj.query.v.match(/^[\w-]{10,12}$/)) {
|
||||
video_id = urlobj.query.v;
|
||||
}
|
||||
} else {
|
||||
var match = RE_YOUTUBE.exec(urlobj.pathname);
|
||||
if (match) {
|
||||
video_id = match[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (video_id) {
|
||||
return 'http://img.youtube.com/vi/' + video_id + '/hqdefault.jpg';
|
||||
}
|
||||
}
|
||||
|
||||
//vimeo
|
||||
if (['www.vimeo.com', 'vimeo.com', 'player.vimeo.com'].indexOf(urlobj.host) !== -1) {
|
||||
var _match = RE_VIMEO.exec(urlobj.pathname);
|
||||
if (_match) {
|
||||
var _video_id = _match[1];
|
||||
return (0, _requestPromise2.default)({
|
||||
uri: 'https://vimeo.com/api/v2/video/' + _video_id + '.json',
|
||||
json: true
|
||||
}).then(function (data) {
|
||||
if (data) {
|
||||
return data[0].thumbnail_large;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//facebook
|
||||
if (['facebook.com', 'www.facebook.com'].indexOf(urlobj.host) !== -1) {
|
||||
var _match2 = RE_FACEBOOK.exec(urlobj.pathname);
|
||||
|
||||
if (_match2) {
|
||||
var _video_id2 = _match2[1];
|
||||
return (0, _requestPromise2.default)({
|
||||
uri: 'https://graph.facebook.com/' + _video_id2,
|
||||
json: true
|
||||
}).then(function (data) {
|
||||
if (data) {
|
||||
return data.picture;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
1
node_modules/video-thumbnail-url/index.js
generated
vendored
Normal file
1
node_modules/video-thumbnail-url/index.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('./dist').default;
|
67
node_modules/video-thumbnail-url/package.json
generated
vendored
Normal file
67
node_modules/video-thumbnail-url/package.json
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
{
|
||||
"_from": "video-thumbnail-url@^1.0.1",
|
||||
"_id": "video-thumbnail-url@1.0.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-QLvt5ArCS49gkYFpCAJtFRkFayQ=",
|
||||
"_location": "/video-thumbnail-url",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "video-thumbnail-url@^1.0.1",
|
||||
"name": "video-thumbnail-url",
|
||||
"escapedName": "video-thumbnail-url",
|
||||
"rawSpec": "^1.0.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/video-thumbnail-url/-/video-thumbnail-url-1.0.1.tgz",
|
||||
"_shasum": "40bbede40ac24b8f6091816908026d1519056b24",
|
||||
"_spec": "video-thumbnail-url@^1.0.1",
|
||||
"_where": "C:\\Users\\matia\\Documents\\GitHub\\Musix-V3",
|
||||
"author": {
|
||||
"name": "Domas Lapinskas",
|
||||
"email": "domas@producters.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Producters/video-thumbnail-url/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"bluebird": "^3.4.0",
|
||||
"request-promise": "^3.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "get thumbnail url from video url",
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.9.0",
|
||||
"babel-preset-es2015": "^6.9.0",
|
||||
"babel-register": "^6.9.0",
|
||||
"mocha": "^2.5.3",
|
||||
"should": "^9.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/Producters/video-thumbnail-url",
|
||||
"keywords": [
|
||||
"youtube",
|
||||
"video",
|
||||
"thumbnail",
|
||||
"url"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "video-thumbnail-url",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/Producters/video-thumbnail-url.git"
|
||||
},
|
||||
"scripts": {
|
||||
"compile": "babel src -d dist",
|
||||
"prepublish": "npm run compile",
|
||||
"test": "npm run compile && mocha --compilers js:babel-register tests/*.test.js"
|
||||
},
|
||||
"version": "1.0.1"
|
||||
}
|
71
node_modules/video-thumbnail-url/src/index.js
generated
vendored
Normal file
71
node_modules/video-thumbnail-url/src/index.js
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
import {parse} from 'url';
|
||||
import bluebird from 'bluebird';
|
||||
import rp from 'request-promise';
|
||||
|
||||
//extract id from url path
|
||||
const RE_VIMEO = /^(?:\/video|\/channels\/[\w-]+|\/groups\/[\w-]+\/videos)?\/(\d+)$/;
|
||||
const RE_YOUTUBE = /^(?:\/embed)?\/([\w-]{10,12})$/;
|
||||
const RE_FACEBOOK = /^\/[\w-]+\/videos\/(\d+)(\/)?$/;
|
||||
|
||||
export default function getThumbnailURL(url) {
|
||||
return bluebird.try(() => {
|
||||
url = url || '';
|
||||
|
||||
const urlobj = parse(url, true);
|
||||
|
||||
//youtube
|
||||
if (['www.youtube.com', 'youtube.com', 'youtu.be'].indexOf(urlobj.host) !== -1) {
|
||||
let video_id = null;
|
||||
if ('v' in urlobj.query) {
|
||||
if (urlobj.query.v && urlobj.query.v.match(/^[\w-]{10,12}$/)) {
|
||||
video_id = urlobj.query.v;
|
||||
}
|
||||
} else {
|
||||
const match = RE_YOUTUBE.exec(urlobj.pathname);
|
||||
if (match) {
|
||||
video_id = match[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (video_id) {
|
||||
return `http://img.youtube.com/vi/${video_id}/hqdefault.jpg`;
|
||||
}
|
||||
}
|
||||
|
||||
//vimeo
|
||||
if (['www.vimeo.com', 'vimeo.com', 'player.vimeo.com'].indexOf(urlobj.host) !== -1) {
|
||||
const match = RE_VIMEO.exec(urlobj.pathname);
|
||||
if (match) {
|
||||
const video_id = match[1];
|
||||
return rp({
|
||||
uri: `https://vimeo.com/api/v2/video/${video_id}.json`,
|
||||
json: true
|
||||
})
|
||||
.then(data => {
|
||||
if (data) {
|
||||
return data[0].thumbnail_large;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//facebook
|
||||
if (['facebook.com', 'www.facebook.com'].indexOf(urlobj.host) !== -1) {
|
||||
const match = RE_FACEBOOK.exec(urlobj.pathname);
|
||||
|
||||
if (match) {
|
||||
const video_id = match[1];
|
||||
return rp({
|
||||
uri: `https://graph.facebook.com/${video_id}`,
|
||||
json: true
|
||||
})
|
||||
.then(data => {
|
||||
if (data) {
|
||||
return data.picture
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
16
node_modules/video-thumbnail-url/tests/facebook.test.js
generated
vendored
Normal file
16
node_modules/video-thumbnail-url/tests/facebook.test.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
import {testService} from './util';
|
||||
|
||||
const VALID = [
|
||||
'https://www.facebook.com/oculusvr/videos/814277555340427/'
|
||||
];
|
||||
|
||||
const INVALID = [
|
||||
'https://www.facebook.com/',
|
||||
'https://www.facebook.com/photo.php?v=426337427566302&type=2&theater'
|
||||
];
|
||||
|
||||
|
||||
testService('facebook', VALID, INVALID, /^https\:\/\/scontent\.xx\.fbcdn\.net\/v\//);
|
||||
|
||||
//https://graph.facebook.com/814277555340427
|
||||
//https://scontent.xx.fbcdn.net/v/
|
23
node_modules/video-thumbnail-url/tests/util.js
generated
vendored
Normal file
23
node_modules/video-thumbnail-url/tests/util.js
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
import should from 'should';
|
||||
import getThumbnailURL from '../index';
|
||||
|
||||
export function testService(service, valid_urls, invalid_urls, thumb_url) {
|
||||
describe(service, function() {
|
||||
|
||||
valid_urls.forEach(url => {
|
||||
it(`should get thumb url for ${url}`, () => {
|
||||
return getThumbnailURL(url).then(result => {
|
||||
should.exist(result);
|
||||
result.should.match(thumb_url);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
invalid_urls.forEach(url => {
|
||||
it(`should not get thumb url for ${url}`, () => {
|
||||
return getThumbnailURL(url).then(should.not.exist);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
22
node_modules/video-thumbnail-url/tests/vimeo.test.js
generated
vendored
Normal file
22
node_modules/video-thumbnail-url/tests/vimeo.test.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
import { testService } from './util';
|
||||
|
||||
const VALID = [
|
||||
'http://vimeo.com/167195274',
|
||||
'http://vimeo.com/167195274?foo=bar',
|
||||
'http://player.vimeo.com/video/167195274',
|
||||
'http://player.vimeo.com/video/167195274?title=0&byline=0&portrait=0',
|
||||
'https://vimeo.com/channels/staffpicks/167195274',
|
||||
'https://vimeo.com/groups/motion/videos/169674362'
|
||||
];
|
||||
|
||||
const INVALID = [
|
||||
'http://www.delfi.lt/news/ringas/lit/a-tapinas-viena-ministres-diena.d?id=71476806',
|
||||
'http://video.com/6701902',
|
||||
'http://vimeo.com',
|
||||
'http://vimeo.com/videoschool',
|
||||
'http://vimeo.com/videoschool/archive/behind_the_scenes',
|
||||
'http://vimeo.com/forums/screening_room',
|
||||
'http://vimeo.com/forums/screening_room/topic:42708'
|
||||
];
|
||||
|
||||
testService('vimeo', VALID, INVALID, /^http(s)?\:\/\/i\.vimeocdn\.com\/video\/(\d)+\_640\.jpg$/);
|
19
node_modules/video-thumbnail-url/tests/youtube.test.js
generated
vendored
Normal file
19
node_modules/video-thumbnail-url/tests/youtube.test.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
import { testService } from './util';
|
||||
|
||||
const VALID = [
|
||||
'https://www.youtube.com/embed/dQw4w9WgXcQ',
|
||||
'https://youtu.be/dQw4w9WgXcQ',
|
||||
'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
|
||||
'https://www.youtube.com/watch?v=dQw4w9WgXcQ&feature=youtu.be',
|
||||
'https://www.youtube.com/watch?feature=related&v=dQw4w9WgXcQ'
|
||||
];
|
||||
|
||||
const INVALID = [
|
||||
'http://www.delfi.lt/news/ringas/lit/a-tapinas-viena-ministres-diena.d?id=71476806',
|
||||
'https://www.youture.com/watch?v=dQw4w9WgXcQ',
|
||||
'https://www.youtube.com/watch?v=',
|
||||
'https://www.youtube.com/watch?v=dQw4w9',
|
||||
'https://www.youtube.com'
|
||||
];
|
||||
|
||||
testService('youtube', VALID, INVALID, /^http(s)?\:\/\/img\.youtube\.com\/vi\/([\w-]{10,12})\/hqdefault\.jpg$/);
|
Reference in New Issue
Block a user