feat: support custom endpoint for stream extraction

This commit is contained in:
Shiny Nematoda 2024-11-25 14:19:49 +00:00
parent e263bd4cea
commit 28c9f7686a
5 changed files with 21 additions and 12 deletions

View file

@ -82,16 +82,10 @@ function parseUrl() {
if (loc[2].startsWith('MPRE')) results.getAlbum('?list=' + loc[2]);
break;
case 'charts':
nav.state.page = 'charts';
break;
case 'library':
nav.state.page = 'library';
break;
case 'prefs':
nav.state.page = 'prefs';
break;
case 'restore':
nav.state.page = 'restore';
nav.state.page = base;
break;
default:
console.log(loc);

View file

@ -1,3 +1,3 @@
{
"date": "2024-07-22"
"date": "2024-11-25"
}

View file

@ -118,6 +118,11 @@ async function setAuth(e) {
setCustom('authapi', e);
}
function setStreamApi(e) {
if (e.target.value) store.setItem('streamapi', e.target.value)
else store.removeItem('streamapi');
}
const verifyApi = computed(() =>
hypInstances.value
.map(i => i.api_url.replace('https://', '').replace('http://', ''))
@ -407,6 +412,15 @@ onMounted(() => {
<option value="x">Custom</option>
</select>
<h3>{{ t('instances.streamapi') }}</h3>
<input
class="input text-center"
type="text"
@change="setStreamApi"
:value="getStore('streamapi') || ''"
placeholder="Default (Piped API)"
/>
<div class="table-wrap">
<table>
<thead>
@ -470,7 +484,8 @@ h2,
h3,
label,
footer,
.restore {
.restore,
.input {
text-align: center;
word-break: break-word;
}

View file

@ -38,8 +38,8 @@ export async function getJson(url, opts) {
return res;
}
export async function getJsonPiped(path, opts) {
const root =
export async function getJsonPiped(path, opts, root) {
root ??=
new URLSearchParams(location.search).get('pipedapi') ||
useStore().getItem('pipedapi') ||
PIPED_INSTANCE;

View file

@ -22,7 +22,7 @@ export const useData = defineStore('data', () => {
async function getSong(e) {
const hash = new URLSearchParams(e.substring(e.indexOf('?'))).get('v'),
json = await getJsonPiped('/streams/' + hash),
json = await getJsonPiped('/streams/' + hash, {}, store.getItem('streamapi')),
unamp = txt => txt?.replace(AMP, '&');
state.art = unamp(json.thumbnailUrl);