2021-10-05 05:11:42 +02:00
|
|
|
export const state = () => ({
|
2022-01-09 00:03:33 +01:00
|
|
|
providers: [
|
|
|
|
{
|
|
|
|
text: 'Google Books',
|
|
|
|
value: 'google'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'Open Library',
|
|
|
|
value: 'openlibrary'
|
|
|
|
},
|
|
|
|
{
|
2022-10-08 00:18:28 +02:00
|
|
|
text: 'iTunes',
|
|
|
|
value: 'itunes'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'Audible.com',
|
2022-01-09 00:03:33 +01:00
|
|
|
value: 'audible'
|
2022-03-07 00:26:35 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-08 00:18:28 +02:00
|
|
|
text: 'Audible.ca',
|
|
|
|
value: 'audible.ca'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'Audible.co.uk',
|
|
|
|
value: 'audible.uk'
|
|
|
|
},
|
|
|
|
{
|
2022-11-21 00:17:25 +01:00
|
|
|
text: 'Audible.com.au',
|
2022-10-08 00:18:28 +02:00
|
|
|
value: 'audible.au'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'Audible.fr',
|
|
|
|
value: 'audible.fr'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'Audible.de',
|
|
|
|
value: 'audible.de'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'Audible.co.jp',
|
|
|
|
value: 'audible.jp'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'Audible.it',
|
|
|
|
value: 'audible.it'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'Audible.co.in',
|
|
|
|
value: 'audible.in'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'Audible.es',
|
|
|
|
value: 'audible.es'
|
2023-02-06 22:25:18 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'FantLab.ru',
|
|
|
|
value: 'fantlab'
|
2022-01-09 00:03:33 +01:00
|
|
|
}
|
2022-03-18 23:09:17 +01:00
|
|
|
],
|
|
|
|
podcastProviders: [
|
|
|
|
{
|
|
|
|
text: 'iTunes',
|
|
|
|
value: 'itunes'
|
|
|
|
}
|
2023-04-20 07:13:52 +02:00
|
|
|
],
|
|
|
|
coverOnlyProviders: [
|
|
|
|
{
|
|
|
|
text: 'AudiobookCovers.com',
|
|
|
|
value: 'audiobookcovers'
|
|
|
|
}
|
2022-01-09 00:03:33 +01:00
|
|
|
]
|
2021-10-05 05:11:42 +02:00
|
|
|
})
|
|
|
|
|
2024-02-11 23:48:16 +01:00
|
|
|
export const getters = {
|
|
|
|
checkBookProviderExists: state => (providerValue) => {
|
|
|
|
return state.providers.some(p => p.value === providerValue)
|
2024-01-03 01:36:56 +01:00
|
|
|
},
|
2024-02-11 23:48:16 +01:00
|
|
|
checkPodcastProviderExists: state => (providerValue) => {
|
|
|
|
return state.podcastProviders.some(p => p.value === providerValue)
|
|
|
|
}
|
2024-01-03 01:36:56 +01:00
|
|
|
}
|
|
|
|
|
2024-02-11 23:48:16 +01:00
|
|
|
export const actions = {}
|
|
|
|
|
2024-01-03 01:36:56 +01:00
|
|
|
export const mutations = {
|
2024-02-11 23:48:16 +01:00
|
|
|
addCustomMetadataProvider(state, provider) {
|
|
|
|
if (provider.mediaType === 'book') {
|
|
|
|
if (state.providers.some(p => p.value === provider.slug)) return
|
|
|
|
state.providers.push({
|
|
|
|
text: provider.name,
|
|
|
|
value: provider.slug
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
if (state.podcastProviders.some(p => p.value === provider.slug)) return
|
|
|
|
state.podcastProviders.push({
|
|
|
|
text: provider.name,
|
|
|
|
value: provider.slug
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
removeCustomMetadataProvider(state, provider) {
|
|
|
|
if (provider.mediaType === 'book') {
|
|
|
|
state.providers = state.providers.filter(p => p.value !== provider.slug)
|
|
|
|
} else {
|
|
|
|
state.podcastProviders = state.podcastProviders.filter(p => p.value !== provider.slug)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setCustomMetadataProviders(state, providers) {
|
|
|
|
if (!providers?.length) return
|
|
|
|
|
|
|
|
const mediaType = providers[0].mediaType
|
|
|
|
if (mediaType === 'book') {
|
|
|
|
// clear previous values, and add new values to the end
|
|
|
|
state.providers = state.providers.filter((p) => !p.value.startsWith('custom-'))
|
|
|
|
state.providers = [
|
2024-01-03 01:36:56 +01:00
|
|
|
...state.providers,
|
2024-02-11 23:48:16 +01:00
|
|
|
...providers.map((p) => ({
|
2024-01-03 01:36:56 +01:00
|
|
|
text: p.name,
|
2024-02-11 23:48:16 +01:00
|
|
|
value: p.slug
|
|
|
|
}))
|
|
|
|
]
|
|
|
|
} else {
|
|
|
|
// Podcast providers not supported yet
|
|
|
|
}
|
|
|
|
}
|
2024-01-03 01:36:56 +01:00
|
|
|
}
|