1
0
mirror of https://github.com/musix-org/musix-oss synced 2025-07-07 01:20:48 +00:00
This commit is contained in:
MatteZ02
2019-05-30 12:06:47 +03:00
parent cbdffcf19c
commit 5eb0264906
2502 changed files with 360854 additions and 0 deletions

23
node_modules/simple-youtube-api/src/util/Constants.js generated vendored Normal file
View File

@ -0,0 +1,23 @@
exports.PARTS = {
Search: 'snippet',
Videos: 'snippet,contentDetails',
Playlists: 'snippet',
PlaylistItems: 'snippet,status',
Channels: 'snippet'
};
exports.KINDS = {
Video: 'youtube#video',
PlaylistItem: 'youtube#playlistItem',
Playlist: 'youtube#playlist',
SearchResult: 'youtube#searchResult',
Channel: 'youtube#channel'
};
exports.ENDPOINTS = {
PlaylistItems: 'playlistItems',
Channels: 'channels',
Videos: 'videos',
Playlists: 'playlists',
Search: 'search'
};

36
node_modules/simple-youtube-api/src/util/index.js generated vendored Normal file
View File

@ -0,0 +1,36 @@
const { parse } = require('url');
/**
* Parse a string as a potential YouTube resource URL.
* @param {string} url
* @returns {{video: ?string, channel: ?string, playlist: ?string}}
*/
exports.parseURL = (url) => {
const parsed = parse(url, true);
switch (parsed.hostname) {
case 'www.youtube.com':
case 'youtube.com':
case 'm.youtube.com': {
const idRegex = /^[a-zA-Z0-9-_]+$/;
if (parsed.pathname === '/watch') {
if (!idRegex.test(parsed.query.v)) return {};
const response = { video: parsed.query.v };
if (parsed.query.list) response.playlist = parsed.query.list;
return response;
} else if (parsed.pathname === '/playlist') {
if(!idRegex.test(parsed.query.list)) return {};
return { playlist: parsed.query.list };
} else if (parsed.pathname.startsWith('/channel/')) {
const id = parsed.pathname.replace('/channel/', '');
if (!idRegex.test(id)) return {};
return { channel: id };
}
return {};
}
case 'youtu.be':
return { video: /^\/[a-zA-Z0-9-_]+$/.test(parsed.pathname) ? parsed.pathname.slice(1) : null };
default:
return {};
}
};