Genius to use external provider
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -77,7 +77,7 @@
|
||||
|
||||
// Release details
|
||||
// These are automatically injected to built HTML
|
||||
var build = "1530004469";
|
||||
var build = "1530044847";
|
||||
var version = "3.21.4";
|
||||
|
||||
// Construct the script tag
|
||||
|
||||
2
src/js/bootstrap.js
vendored
2
src/js/bootstrap.js
vendored
@ -80,7 +80,7 @@ var initialState = {
|
||||
me: false,
|
||||
authorization_url: 'https://jamesbarnsley.co.nz/iris/auth_lastfm.php'
|
||||
},
|
||||
genius: {,
|
||||
genius: {
|
||||
provider_url: 'https://jamesbarnsley.co.nz/iris/provider_genius.php'
|
||||
},
|
||||
spotify: {
|
||||
|
||||
@ -8,7 +8,8 @@ var helpers = require('../../helpers')
|
||||
*
|
||||
* @param dispatch obj
|
||||
* @param getState obj
|
||||
* @param endpoint params = the url params to send
|
||||
* @param endpoint = the action
|
||||
* @param params = string for any URL prarams to pass on
|
||||
**/
|
||||
const sendRequest = (dispatch, getState, endpoint) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -16,22 +17,11 @@ const sendRequest = (dispatch, getState, endpoint) => {
|
||||
var loader_key = helpers.generateGuid();
|
||||
dispatch(uiActions.startLoading(loader_key, 'genius_'+endpoint));
|
||||
|
||||
var url = endpoint;
|
||||
if (!url.startsWith('http')){
|
||||
url = 'https://api.genius.com/'+url;
|
||||
}
|
||||
|
||||
var config = {
|
||||
method: 'POST',
|
||||
cache: false,
|
||||
timeout: 30000,
|
||||
headers: {
|
||||
Authorization: 'Bearer nBNNEFekix8BOsfPyfK7LtX-CaUz7L7ak92qC3GfMAIQi8eWjuwb4P8SUxK1K-iY'
|
||||
},
|
||||
data: JSON.stringify({
|
||||
url: url
|
||||
}),
|
||||
url: '//'+getState().mopidy.host+':'+getState().mopidy.port+'/iris/http/proxy_request'
|
||||
method: 'GET',
|
||||
url: getState().genius.provider_url+endpoint,
|
||||
dataType: "json",
|
||||
timeout: 10000
|
||||
};
|
||||
|
||||
$.ajax(config).then(
|
||||
@ -71,7 +61,7 @@ export function getTrackLyrics(uri, url){
|
||||
}
|
||||
});
|
||||
|
||||
sendRequest(dispatch, getState, url)
|
||||
sendRequest(dispatch, getState, "?action=lyrics&url="+url)
|
||||
.then(
|
||||
response => {
|
||||
var html = $(response);
|
||||
@ -117,7 +107,7 @@ export function findTrackLyrics(track){
|
||||
query = query.replace(/\([^)]*\) */g, ''); // anything in circle-braces
|
||||
query = query.replace(/\([^[]*\] */g, ''); // anything in square-braces
|
||||
|
||||
sendRequest(dispatch, getState, 'search?q='+encodeURIComponent(query))
|
||||
sendRequest(dispatch, getState, '?action=search&query='+encodeURIComponent(query))
|
||||
.then(
|
||||
response => {
|
||||
if (response.response.hits && response.response.hits.length > 0){
|
||||
|
||||
Reference in New Issue
Block a user