diff --git a/src/assets/version.json b/src/assets/version.json index 4f0ab71..e3d5f40 100644 --- a/src/assets/version.json +++ b/src/assets/version.json @@ -1,3 +1,3 @@ { - "date": "2023-02-25" + "date": "2023-03-05" } diff --git a/src/scripts/fetch.js b/src/scripts/fetch.js index bac75c6..244fb57 100644 --- a/src/scripts/fetch.js +++ b/src/scripts/fetch.js @@ -49,7 +49,7 @@ export async function getJsonHyp(path) { return await getJson('https://' + root + path); } -export async function getJsonAuth(path, opts = opts) { +export async function getJsonAuth(path, opts = {}) { const root = useStore().getItem('authapi') || PIPED_INSTANCE; return await fetch('https://' + root + path, opts) diff --git a/src/stores/results.js b/src/stores/results.js index 8ca0aff..4353a70 100644 --- a/src/stores/results.js +++ b/src/stores/results.js @@ -3,7 +3,7 @@ import { defineStore } from 'pinia'; import { useNav } from '@/stores/misc.js'; -import { getJsonPiped, getJsonHyp } from '@/scripts/fetch.js'; +import { getJsonPiped, getJsonHyp, getJsonAuth } from '@/scripts/fetch.js'; import { useRoute } from '@/scripts/util.js'; export const useResults = defineStore('results', () => { @@ -46,7 +46,12 @@ export const useResults = defineStore('results', () => { console.log('Album: ', e); const hash = new URLSearchParams(e.substring(e.indexOf('?'))).get('list'), - json = await getJsonPiped('/playlists/' + hash); + isAuth = + /[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}/.test( + hash, + ), + path = '/playlists/' + hash, + json = isAuth ? await getJsonAuth(path) : await getJsonPiped(path); console.log(json, json.relatedStreams); @@ -54,16 +59,11 @@ export const useResults = defineStore('results', () => { album.value = e; - if ( - /[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}/.test( - hash, - ) - ) { + if (isAuth) json.relatedStreams = json.relatedStreams.map(i => { i.playlistId = hash; return i; }); - } setItem('songs', { items: json.relatedStreams,