2018-08-11 07:47:10 +02:00
|
|
|
import axios from 'axios'
|
|
|
|
import store from '@/store'
|
2022-06-19 16:32:46 +02:00
|
|
|
import i18n from '@/i18n'
|
|
|
|
|
|
|
|
const { t } = i18n.global
|
2018-08-11 07:47:10 +02:00
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
axios.interceptors.response.use(
|
|
|
|
function (response) {
|
|
|
|
return response
|
|
|
|
},
|
|
|
|
function (error) {
|
|
|
|
if (error.request.status && error.request.responseURL) {
|
|
|
|
store.dispatch('add_notification', {
|
2022-06-19 16:32:46 +02:00
|
|
|
text: t('server.request-failed', {
|
2022-05-29 18:49:00 +02:00
|
|
|
status: error.request.status,
|
|
|
|
cause: error.request.statusText,
|
|
|
|
url: error.request.responseURL
|
|
|
|
}),
|
2022-02-19 06:39:14 +01:00
|
|
|
type: 'danger'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return Promise.reject(error)
|
2020-04-24 05:50:50 +02:00
|
|
|
}
|
2022-02-19 06:39:14 +01:00
|
|
|
)
|
2018-08-11 07:47:10 +02:00
|
|
|
|
|
|
|
export default {
|
2022-02-19 06:39:14 +01:00
|
|
|
config() {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/config')
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
settings() {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/settings')
|
2019-07-07 08:22:56 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
settings_update(categoryName, option) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.put(`./api/settings/${categoryName}/${option.name}`, option)
|
2019-07-07 08:22:56 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_stats() {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/library')
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_update(scanKind) {
|
2022-01-09 18:29:24 +01:00
|
|
|
const params = {}
|
|
|
|
if (scanKind) {
|
|
|
|
params.scan_kind = scanKind
|
|
|
|
}
|
|
|
|
return axios.put('./api/update', undefined, { params: params })
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_rescan(scanKind) {
|
2022-01-09 18:29:24 +01:00
|
|
|
const params = {}
|
|
|
|
if (scanKind) {
|
|
|
|
params.scan_kind = scanKind
|
|
|
|
}
|
|
|
|
return axios.put('./api/rescan', undefined, { params: params })
|
2019-06-09 15:19:52 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_count(expression) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.get(`./api/library/count?expression=${expression}`)
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
queue() {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/queue')
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
queue_clear() {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.put('./api/queue/clear')
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
queue_remove(itemId) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.delete(`./api/queue/items/${itemId}`)
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
queue_move(itemId, newPosition) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.put(`./api/queue/items/${itemId}?new_position=${newPosition}`)
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
queue_add(uri) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.post(`./api/queue/items/add?uris=${uri}`).then((response) => {
|
2022-02-19 06:39:14 +01:00
|
|
|
store.dispatch('add_notification', {
|
2022-06-19 16:32:46 +02:00
|
|
|
text: t('server.appended-tracks', { count: response.data.count }),
|
2022-02-19 06:39:14 +01:00
|
|
|
type: 'info',
|
|
|
|
timeout: 2000
|
|
|
|
})
|
2018-12-23 09:54:02 +01:00
|
|
|
return Promise.resolve(response)
|
|
|
|
})
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
queue_add_next(uri) {
|
2021-01-10 07:51:50 +01:00
|
|
|
let position = 0
|
2018-10-13 08:32:25 +02:00
|
|
|
if (store.getters.now_playing && store.getters.now_playing.id) {
|
|
|
|
position = store.getters.now_playing.position + 1
|
|
|
|
}
|
2022-02-19 06:39:14 +01:00
|
|
|
return axios
|
2023-11-23 20:23:40 +01:00
|
|
|
.post(`./api/queue/items/add?uris=${uri}&position=${position}`)
|
2022-02-19 06:39:14 +01:00
|
|
|
.then((response) => {
|
|
|
|
store.dispatch('add_notification', {
|
2022-06-19 16:32:46 +02:00
|
|
|
text: t('server.appended-tracks', {
|
2022-05-29 18:49:00 +02:00
|
|
|
count: response.data.count
|
|
|
|
}),
|
2022-02-19 06:39:14 +01:00
|
|
|
type: 'info',
|
|
|
|
timeout: 2000
|
|
|
|
})
|
|
|
|
return Promise.resolve(response)
|
|
|
|
})
|
2018-10-13 08:32:25 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
queue_expression_add(expression) {
|
2021-01-10 07:51:50 +01:00
|
|
|
const options = {}
|
2019-02-22 13:20:04 +01:00
|
|
|
options.expression = expression
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
return axios
|
|
|
|
.post('./api/queue/items/add', undefined, { params: options })
|
|
|
|
.then((response) => {
|
|
|
|
store.dispatch('add_notification', {
|
2022-06-19 16:32:46 +02:00
|
|
|
text: t('server.appended-tracks', {
|
2022-05-29 18:49:00 +02:00
|
|
|
count: response.data.count
|
|
|
|
}),
|
2022-02-19 06:39:14 +01:00
|
|
|
type: 'info',
|
|
|
|
timeout: 2000
|
|
|
|
})
|
|
|
|
return Promise.resolve(response)
|
|
|
|
})
|
2019-02-22 13:20:04 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
queue_expression_add_next(expression) {
|
2021-01-10 07:51:50 +01:00
|
|
|
const options = {}
|
2019-02-22 13:20:04 +01:00
|
|
|
options.expression = expression
|
|
|
|
options.position = 0
|
|
|
|
if (store.getters.now_playing && store.getters.now_playing.id) {
|
|
|
|
options.position = store.getters.now_playing.position + 1
|
|
|
|
}
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
return axios
|
|
|
|
.post('./api/queue/items/add', undefined, { params: options })
|
|
|
|
.then((response) => {
|
|
|
|
store.dispatch('add_notification', {
|
2022-06-19 16:32:46 +02:00
|
|
|
text: t('server.appended-tracks', {
|
2022-05-29 18:49:00 +02:00
|
|
|
count: response.data.count
|
|
|
|
}),
|
2022-02-19 06:39:14 +01:00
|
|
|
type: 'info',
|
|
|
|
timeout: 2000
|
|
|
|
})
|
|
|
|
return Promise.resolve(response)
|
|
|
|
})
|
2019-02-22 13:20:04 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
queue_save_playlist(name) {
|
|
|
|
return axios
|
|
|
|
.post('./api/queue/save', undefined, { params: { name: name } })
|
|
|
|
.then((response) => {
|
|
|
|
store.dispatch('add_notification', {
|
2022-06-19 16:32:46 +02:00
|
|
|
text: t('server.queue-saved', { name: name }),
|
2022-02-19 06:39:14 +01:00
|
|
|
type: 'info',
|
|
|
|
timeout: 2000
|
|
|
|
})
|
|
|
|
return Promise.resolve(response)
|
|
|
|
})
|
2019-04-11 20:25:05 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
player_status() {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/player')
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
player_play_uri(uris, shuffle, position = undefined) {
|
2021-01-10 07:51:50 +01:00
|
|
|
const options = {}
|
2019-02-22 13:20:04 +01:00
|
|
|
options.uris = uris
|
|
|
|
options.shuffle = shuffle ? 'true' : 'false'
|
|
|
|
options.clear = 'true'
|
|
|
|
options.playback = 'start'
|
|
|
|
options.playback_from_position = position
|
|
|
|
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.post('./api/queue/items/add', undefined, { params: options })
|
2019-02-22 13:20:04 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
player_play_expression(expression, shuffle, position = undefined) {
|
2021-01-10 07:51:50 +01:00
|
|
|
const options = {}
|
2019-02-22 13:20:04 +01:00
|
|
|
options.expression = expression
|
|
|
|
options.shuffle = shuffle ? 'true' : 'false'
|
|
|
|
options.clear = 'true'
|
|
|
|
options.playback = 'start'
|
|
|
|
options.playback_from_position = position
|
|
|
|
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.post('./api/queue/items/add', undefined, { params: options })
|
2018-11-06 21:44:01 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
player_play(options = {}) {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.put('./api/player/play', undefined, { params: options })
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
player_playpos(position) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.put(`./api/player/play?position=${position}`)
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
player_playid(itemId) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.put(`./api/player/play?item_id=${itemId}`)
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
player_pause() {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.put('./api/player/pause')
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
player_stop() {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.put('./api/player/stop')
|
2018-12-30 08:53:40 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
player_next() {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.put('./api/player/next')
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
player_previous() {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.put('./api/player/previous')
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
player_shuffle(newState) {
|
2021-01-10 07:51:50 +01:00
|
|
|
const shuffle = newState ? 'true' : 'false'
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.put(`./api/player/shuffle?state=${shuffle}`)
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
player_consume(newState) {
|
2021-01-10 07:51:50 +01:00
|
|
|
const consume = newState ? 'true' : 'false'
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.put(`./api/player/consume?state=${consume}`)
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
player_repeat(newRepeatMode) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.put(`./api/player/repeat?state=${newRepeatMode}`)
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
player_volume(volume) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.put(`./api/player/volume?volume=${volume}`)
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
player_output_volume(outputId, outputVolume) {
|
|
|
|
return axios.put(
|
2023-11-23 20:23:40 +01:00
|
|
|
`./api/player/volume?volume=${outputVolume}&output_id=${outputId}`
|
2022-02-19 06:39:14 +01:00
|
|
|
)
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
player_seek_to_pos(newPosition) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.put(`./api/player/seek?position_ms=${newPosition}`)
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
player_seek(seekMs) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.put(`./api/player/seek?seek_ms=${seekMs}`)
|
2020-04-17 06:23:28 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
outputs() {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/outputs')
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
output_update(outputId, output) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.put(`./api/outputs/${outputId}`, output)
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
output_toggle(outputId) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.put(`./api/outputs/${outputId}/toggle`)
|
2020-01-04 18:53:27 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_artists(media_kind = undefined) {
|
|
|
|
return axios.get('./api/library/artists', {
|
|
|
|
params: { media_kind: media_kind }
|
|
|
|
})
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_artist(artistId) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.get(`./api/library/artists/${artistId}`)
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_artist_albums(artistId) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.get(`./api/library/artists/${artistId}/albums`)
|
2020-06-30 10:24:11 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_albums(media_kind = undefined) {
|
|
|
|
return axios.get('./api/library/albums', {
|
|
|
|
params: { media_kind: media_kind }
|
|
|
|
})
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_album(albumId) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.get(`./api/library/albums/${albumId}`)
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_album_tracks(albumId, filter = { limit: -1, offset: 0 }) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.get(`./api/library/albums/${albumId}/tracks`, {
|
2020-04-18 13:29:10 +02:00
|
|
|
params: filter
|
|
|
|
})
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_album_track_update(albumId, attributes) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.put(`./api/library/albums/${albumId}/tracks`, undefined, {
|
2022-02-19 06:39:14 +01:00
|
|
|
params: attributes
|
|
|
|
})
|
2020-02-21 20:21:08 +00:00
|
|
|
},
|
|
|
|
|
2022-03-26 22:01:47 +01:00
|
|
|
library_genres(media_kind = undefined) {
|
|
|
|
return axios.get('./api/library/genres', {
|
|
|
|
params: { media_kind: media_kind }
|
|
|
|
})
|
2018-10-26 16:17:18 +01:00
|
|
|
},
|
|
|
|
|
2023-07-24 19:51:00 +02:00
|
|
|
library_genre(genre, media_kind = undefined) {
|
|
|
|
return axios.get(`./api/library/genres/${encodeURIComponent(genre)}`, {
|
|
|
|
params: { media_kind: media_kind }
|
|
|
|
})
|
2022-03-26 21:43:23 +01:00
|
|
|
},
|
|
|
|
|
2023-07-24 19:51:00 +02:00
|
|
|
library_genre_albums(genre, media_kind) {
|
2021-01-10 07:51:50 +01:00
|
|
|
const genreParams = {
|
2023-07-24 19:51:00 +02:00
|
|
|
expression: `genre is "${genre}" and media_kind is ${media_kind}`,
|
|
|
|
type: 'albums'
|
2018-11-24 16:22:23 +00:00
|
|
|
}
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/search', {
|
2018-11-24 16:22:23 +00:00
|
|
|
params: genreParams
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2023-07-24 19:51:00 +02:00
|
|
|
library_genre_tracks(genre, media_kind) {
|
2021-01-10 07:51:50 +01:00
|
|
|
const genreParams = {
|
2023-07-24 19:51:00 +02:00
|
|
|
expression: `genre is "${genre}" and media_kind is ${media_kind}`,
|
|
|
|
type: 'tracks'
|
2018-10-26 16:17:18 +01:00
|
|
|
}
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/search', {
|
2018-10-26 16:17:18 +01:00
|
|
|
params: genreParams
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_radio_streams() {
|
2021-01-10 07:51:50 +01:00
|
|
|
const params = {
|
2020-06-30 09:53:54 +02:00
|
|
|
type: 'tracks',
|
|
|
|
media_kind: 'music',
|
|
|
|
expression: 'data_kind is url and song_length = 0'
|
|
|
|
}
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/search', {
|
2020-06-30 09:53:54 +02:00
|
|
|
params: params
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2022-03-26 22:01:47 +01:00
|
|
|
library_composers(media_kind = undefined) {
|
|
|
|
return axios.get('./api/library/composers', {
|
|
|
|
params: { media_kind: media_kind }
|
|
|
|
})
|
2021-10-23 10:48:11 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_composer(composer) {
|
2022-03-26 21:53:04 +01:00
|
|
|
return axios.get(`./api/library/composers/${encodeURIComponent(composer)}`)
|
|
|
|
},
|
|
|
|
|
|
|
|
library_composer_albums(composer) {
|
2021-12-30 11:15:14 +00:00
|
|
|
const params = {
|
|
|
|
type: 'albums',
|
2022-03-26 22:01:47 +01:00
|
|
|
expression: `composer is "${composer}" and media_kind is music`
|
2021-12-30 11:15:14 +00:00
|
|
|
}
|
2022-01-02 15:39:25 +00:00
|
|
|
return axios.get('./api/search', {
|
2021-12-30 11:15:14 +00:00
|
|
|
params: params
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_composer_tracks(composer) {
|
2021-12-30 11:15:14 +00:00
|
|
|
const params = {
|
|
|
|
type: 'tracks',
|
2022-03-26 22:01:47 +01:00
|
|
|
expression: `composer is "${composer}" and media_kind is music`
|
2021-10-23 10:48:11 +01:00
|
|
|
}
|
2022-01-02 15:39:25 +00:00
|
|
|
return axios.get('./api/search', {
|
2021-10-23 10:48:11 +01:00
|
|
|
params: params
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_artist_tracks(artist) {
|
2018-10-26 16:36:30 +01:00
|
|
|
if (artist) {
|
2021-01-10 07:51:50 +01:00
|
|
|
const artistParams = {
|
2020-04-11 19:43:53 +02:00
|
|
|
type: 'tracks',
|
2023-11-23 20:23:40 +01:00
|
|
|
expression: `songartistid is "${artist}"`
|
2018-10-26 16:36:30 +01:00
|
|
|
}
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/search', {
|
2018-10-26 16:36:30 +01:00
|
|
|
params: artistParams
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_podcasts_new_episodes() {
|
2021-01-10 07:51:50 +01:00
|
|
|
const episodesParams = {
|
2020-04-11 19:43:53 +02:00
|
|
|
type: 'tracks',
|
2022-02-19 06:39:14 +01:00
|
|
|
expression:
|
|
|
|
'media_kind is podcast and play_count = 0 ORDER BY time_added DESC'
|
2019-01-27 06:36:19 +01:00
|
|
|
}
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/search', {
|
2019-01-27 06:36:19 +01:00
|
|
|
params: episodesParams
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_podcast_episodes(albumId) {
|
2021-01-10 07:51:50 +01:00
|
|
|
const episodesParams = {
|
2020-04-11 19:43:53 +02:00
|
|
|
type: 'tracks',
|
2023-11-23 20:23:40 +01:00
|
|
|
expression: `media_kind is podcast and songalbumid is "${albumId}" ORDER BY date_released DESC`
|
2019-01-27 06:36:19 +01:00
|
|
|
}
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/search', {
|
2019-01-27 06:36:19 +01:00
|
|
|
params: episodesParams
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_add(url) {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.post('./api/library/add', undefined, { params: { url: url } })
|
2020-02-21 20:21:08 +00:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_playlist_delete(playlistId) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.delete(`./api/library/playlists/${playlistId}`, undefined)
|
2020-02-21 20:21:08 +00:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_playlists() {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/library/playlists')
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_playlist_folder(playlistId = 0) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.get(`./api/library/playlists/${playlistId}/playlists`)
|
2020-03-08 11:56:19 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_playlist(playlistId) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.get(`./api/library/playlists/${playlistId}`)
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_playlist_tracks(playlistId) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.get(`./api/library/playlists/${playlistId}/tracks`)
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_track(trackId) {
|
2023-11-23 21:27:05 +01:00
|
|
|
if (trackId) { // Temporary fix
|
|
|
|
return axios.get(`./api/library/tracks/${trackId}`)
|
|
|
|
}
|
2019-01-29 17:50:47 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_track_playlists(trackId) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.get(`./api/library/tracks/${trackId}/playlists`)
|
2020-04-18 13:29:10 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_track_update(trackId, attributes = {}) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return axios.put(`./api/library/tracks/${trackId}`, undefined, {
|
2022-02-19 06:39:14 +01:00
|
|
|
params: attributes
|
|
|
|
})
|
2019-01-29 17:50:47 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
library_files(directory = undefined) {
|
2021-01-10 07:51:50 +01:00
|
|
|
const filesParams = { directory: directory }
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/library/files', {
|
2018-12-23 10:34:46 +01:00
|
|
|
params: filesParams
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
search(searchParams) {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/search', {
|
2018-08-11 07:47:10 +02:00
|
|
|
params: searchParams
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
spotify() {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/spotify')
|
2019-07-06 09:21:47 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
spotify_login(credentials) {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.post('./api/spotify-login', credentials)
|
2020-01-04 18:53:27 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
spotify_logout() {
|
2021-12-26 20:19:51 +01:00
|
|
|
return axios.get('./api/spotify-logout')
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
lastfm() {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/lastfm')
|
2020-01-04 18:53:27 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
lastfm_login(credentials) {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.post('./api/lastfm-login', credentials)
|
2020-01-04 18:53:27 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
lastfm_logout(credentials) {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/lastfm-logout')
|
2020-01-04 18:53:27 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
pairing() {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.get('./api/pairing')
|
2020-01-04 18:53:27 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
pairing_kickoff(pairingReq) {
|
2020-04-28 11:01:25 -06:00
|
|
|
return axios.post('./api/pairing', pairingReq)
|
2020-01-04 18:53:27 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
artwork_url_append_size_params(artworkUrl, maxwidth = 600, maxheight = 600) {
|
2019-07-06 09:21:47 +02:00
|
|
|
if (artworkUrl && artworkUrl.startsWith('/')) {
|
|
|
|
if (artworkUrl.includes('?')) {
|
2023-11-23 20:23:40 +01:00
|
|
|
return `${artworkUrl}&maxwidth=${maxwidth}&maxheight=${maxheight}`
|
2019-07-06 09:21:47 +02:00
|
|
|
}
|
2023-11-23 20:23:40 +01:00
|
|
|
return `${artworkUrl}?maxwidth=${maxwidth}&maxheight=${maxheight}`
|
2019-07-06 09:21:47 +02:00
|
|
|
}
|
|
|
|
return artworkUrl
|
2018-08-11 07:47:10 +02:00
|
|
|
}
|
|
|
|
}
|