mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-15 11:40:36 +03:00
31 lines
881 B
JavaScript
31 lines
881 B
JavaScript
import { fetchUtils } from 'react-admin'
|
|
import baseUrl from "../utils/baseUrl"
|
|
|
|
const url = (command, id, options) => {
|
|
const params = new URLSearchParams()
|
|
params.append('u', localStorage.getItem('username'))
|
|
params.append('t', localStorage.getItem('subsonic-token'))
|
|
params.append('s', localStorage.getItem('subsonic-salt'))
|
|
params.append('f', 'json')
|
|
params.append('v', '1.8.0')
|
|
params.append('c', 'NavidromeUI')
|
|
params.append('id', id)
|
|
if (options) {
|
|
if (options.ts) {
|
|
options['_'] = new Date().getTime()
|
|
delete options.ts
|
|
}
|
|
Object.keys(options).forEach((k) => {
|
|
params.append(k, options[k])
|
|
})
|
|
}
|
|
const url = `/rest/${command}?${params.toString()}`
|
|
return baseUrl(url)
|
|
}
|
|
|
|
const scrobble = (id, submit) => {
|
|
return fetchUtils.fetchJson(url('scrobble', id, { submission: submit }))
|
|
}
|
|
|
|
export default { url, scrobble }
|