forked from nukeop/nuclear
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Last.fm scrobbling framework and connecting
- Loading branch information
Showing
15 changed files
with
97 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { lastfmLoginConnect } from '../rest/Lastfm'; | ||
import globals from '../globals'; | ||
const electron = window.require('electron'); | ||
|
||
export const LASTFM_CONNECT = 'LASTFM_CONNECT'; | ||
|
||
export function lastFmConnect() { | ||
return dispatch => { | ||
lastfmLoginConnect() | ||
.then(response => response.json()) | ||
.then(response => { | ||
let authToken = response.token; | ||
electron.shell.openExternal( | ||
'http://www.last.fm/api/auth/?api_key=' + globals.lastfmApiKey + '&token=' + authToken | ||
); | ||
console.log(authToken); | ||
}); | ||
|
||
dispatch({ | ||
type: LASTFM_CONNECT, | ||
payload: null | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
module.exports = { | ||
ytApiKey: "AIzaSyCIM4EzNqi1in22f4Z3Ru3iYvLaY8tc3bo" | ||
ytApiKey: "AIzaSyCIM4EzNqi1in22f4Z3Ru3iYvLaY8tc3bo", | ||
lastfmApiKey: "2b75dcb291e2b0c9a2c994aca522ac14", | ||
lastfmApiSecret: "2ee49e35f08b837d43b2824198171fc8" | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { | ||
LASTFM_CONNECT | ||
} from '../actions/scrobbling'; | ||
|
||
const initialState = { | ||
lastFmName: null, | ||
lastFmSessionKey: null | ||
}; | ||
|
||
export default function ScrobblingReducer(state=initialState, action) { | ||
switch(action.type) { | ||
default: | ||
return state; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import globals from '../globals'; | ||
|
||
const apiUrl = 'http://www.last.fm/api/'; | ||
const scrobblingApiUrl = 'http://ws.audioscrobbler.com/2.0/'; | ||
|
||
function sign(url) { | ||
var tokens = decodeURIComponent((url.split('?')[1].split('&').sort().join()).replace(/,/g, '').replace(/=/g,'')); | ||
|
||
return require('md5')(tokens+globals.lastfmApiSecret); | ||
} | ||
|
||
function prepareUrl(url) { | ||
var withApiKey = `${url}&api_key=${globals.lastfmApiKey}`; | ||
return `${withApiKey}&api_sig=${sign(withApiKey)}` ; | ||
} | ||
|
||
function addApiKey(url) { | ||
return `${url}&api_key=${globals.lastfmApiKey}`; | ||
} | ||
|
||
function lastfmLoginConnect() { | ||
return fetch(prepareUrl(scrobblingApiUrl + '?method=auth.getToken&format=json')); | ||
} | ||
|
||
module.exports = { | ||
lastfmLoginConnect | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.