UNPKG

last-draft-js-plugins

Version:
32 lines (28 loc) 1.03 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.audioUrlValid = audioUrlValid; exports.resolveAudioUrl = resolveAudioUrl; /* eslint no-useless-escape: 0 */ /* eslint no-undef: 0 */ function audioUrlValid(str) { var regexp = /^https?:\/\/(soundcloud\.com|snd\.sc)\/(.*)$/; var isSoundCloudUrl = str.match(regexp) && str.match(regexp)[2]; if (isSoundCloudUrl !== null) { return true; } return false; } function resolveAudioUrl(url, cb) { var clientId = 'fba382dd16fff276623c38d3e3b0a709'; var resolveUrl = 'http://api.soundcloud.com/resolve.json?url=' + url + '/tracks&client_id=' + clientId; fetch(resolveUrl, { method: 'get' }).then(function (response) { return response.json(); }).then(function (track) { var src = 'https://w.soundcloud.com/player/?url=https://api.soundcloud.com/tracks/' + track.id + '&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true'; cb(src); }); }