mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 13:48:02 +00:00
chore: format codes
This commit is contained in:
parent
6922c716e2
commit
9351f6bc89
73 changed files with 2321 additions and 2321 deletions
|
|
@ -1,20 +1,20 @@
|
|||
// Last.fm API documents 👉 https://www.last.fm/api
|
||||
|
||||
import axios from "axios";
|
||||
import md5 from "crypto-js/md5";
|
||||
import axios from 'axios';
|
||||
import md5 from 'crypto-js/md5';
|
||||
|
||||
const apiKey = process.env.VUE_APP_LASTFM_API_KEY;
|
||||
const apiSharedSecret = process.env.VUE_APP_LASTFM_API_SHARED_SECRET;
|
||||
const baseUrl = window.location.origin;
|
||||
const url = "https://ws.audioscrobbler.com/2.0/";
|
||||
const url = 'https://ws.audioscrobbler.com/2.0/';
|
||||
|
||||
const sign = (params) => {
|
||||
const sign = params => {
|
||||
const sortParamsKeys = Object.keys(params).sort();
|
||||
const sortedParams = sortParamsKeys.reduce((acc, key) => {
|
||||
acc[key] = params[key];
|
||||
return acc;
|
||||
}, {});
|
||||
let signature = "";
|
||||
let signature = '';
|
||||
for (const [key, value] of Object.entries(sortedParams)) {
|
||||
signature += `${key}${value}`;
|
||||
}
|
||||
|
|
@ -33,10 +33,10 @@ export function authGetSession(token) {
|
|||
).toString();
|
||||
return axios({
|
||||
url,
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
params: {
|
||||
method: "auth.getSession",
|
||||
format: "json",
|
||||
method: 'auth.getSession',
|
||||
format: 'json',
|
||||
api_key: apiKey,
|
||||
api_sig: signature,
|
||||
token,
|
||||
|
|
@ -46,34 +46,34 @@ export function authGetSession(token) {
|
|||
|
||||
export function trackUpdateNowPlaying(params) {
|
||||
params.api_key = apiKey;
|
||||
params.method = "track.updateNowPlaying";
|
||||
params.sk = JSON.parse(localStorage.getItem("lastfm"))["key"];
|
||||
params.method = 'track.updateNowPlaying';
|
||||
params.sk = JSON.parse(localStorage.getItem('lastfm'))['key'];
|
||||
const signature = sign(params);
|
||||
|
||||
return axios({
|
||||
url,
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
params: {
|
||||
...params,
|
||||
api_sig: signature,
|
||||
format: "json",
|
||||
format: 'json',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function trackScrobble(params) {
|
||||
params.api_key = apiKey;
|
||||
params.method = "track.scrobble";
|
||||
params.sk = JSON.parse(localStorage.getItem("lastfm"))["key"];
|
||||
params.method = 'track.scrobble';
|
||||
params.sk = JSON.parse(localStorage.getItem('lastfm'))['key'];
|
||||
const signature = sign(params);
|
||||
|
||||
return axios({
|
||||
url,
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
params: {
|
||||
...params,
|
||||
api_sig: signature,
|
||||
format: "json",
|
||||
format: 'json',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue