Added getJsonHyp method

This commit is contained in:
Shiny Nematoda 2022-08-02 07:13:42 +00:00
parent dc969e44ee
commit 4f5887aca0
No known key found for this signature in database
GPG key ID: 6506D50F5613A42D
4 changed files with 20 additions and 16 deletions

View file

@ -17,7 +17,7 @@ import Artist from '@/components/Artist.vue';
import Prefs from '@/components/Prefs.vue';
/* Composables */
import { getJson, getJsonPiped } from '@/scripts/fetch.js';
import { getJsonHyp, getJsonPiped } from '@/scripts/fetch.js';
import { useLazyLoad, useStore, useRoute } from '@/scripts/util.js';
import { useSetupDB, useUpdatePlaylist } from '@/scripts/db.js';
@ -121,7 +121,7 @@ function playNext(u) {
}
async function getExplore() {
const json = await getJson('https://hyperpipeapi.onrender.com/explore');
const json = await getJsonHyp('/explore');
console.log(json);
@ -178,7 +178,7 @@ async function getArtist(e) {
e = e.replace('/channel/', '');
const json = await getJson('https://hyperpipeapi.onrender.com/channel/' + e);
const json = await getJsonHyp('/channel/' + e);
console.log(json);
@ -203,9 +203,7 @@ async function getNext(hash) {
!data.state.urls.filter(s => s.url == data.state.url)[0] ||
data.state.urls.length == 1)
) {
const json = await getJson(
'https://hyperpipeapi.onrender.com/next/' + hash,
);
const json = await getJsonHyp('/next/' + hash);
data.state.lyrics = json.lyricsId;

View file

@ -1,7 +1,7 @@
<script setup>
import { ref, watch } from 'vue';
import { getJson } from '@/scripts/fetch.js';
import { getJsonHyp } from '@/scripts/fetch.js';
import { useData } from '@/stores/player.js';
import TextModal from './TextModal.vue';
@ -15,22 +15,17 @@ function get() {
status.value = false;
if (data.state.lyrics && data.state.urls === data.state.urls[0]?.url) {
getJson(
'https://hyperpipeapi.onrender.com/browse/' + data.state.lyrics,
).then(res => {
getJsonHyp('/browse/' + data.state.lyrics).then(res => {
text.value = res.text;
source.value = res.source;
status.value = true;
});
} else if (data.state.urls[0]?.url) {
getJson(
'https://hyperpipeapi.onrender.com/next/' +
data.state.urls[0]?.url.replace('/watch?v=', ''),
getJsonHyp(
'/next/' + data.state.urls[0]?.url.replace('/watch?v=', ''),
).then(next => {
if (next.lyricsId) {
getJson(
'https://hyperpipeapi.onrender.com/browse/' + next.lyricsId,
).then(res => {
getJsonHyp('/browse/' + next.lyricsId).then(res => {
text.value = res.text;
source.value = res.source;
status.value = true;

View file

@ -39,3 +39,9 @@ export async function getJsonPiped(path) {
return await getJson('https://' + root + path);
}
export async function getJsonHyp(path) {
const root = useStore().getItem('api') || 'hyperpipeapi.onrender.com';
return await getJson('https://' + root + path);
}