mirror of
https://codeberg.org/Hyperpipe/Hyperpipe
synced 2025-06-28 05:08:00 +02:00
"See more" for albums and singles in artist page
This commit is contained in:
parent
9dd4534f83
commit
3f5abe967b
7 changed files with 81 additions and 85 deletions
|
@ -53,8 +53,6 @@ function parseUrl() {
|
|||
const loc = location.pathname.split('/'),
|
||||
base = loc[1].replace(location.search, '');
|
||||
|
||||
console.log(loc, base);
|
||||
|
||||
path.value = location.pathname;
|
||||
|
||||
switch (base) {
|
||||
|
@ -67,15 +65,12 @@ function parseUrl() {
|
|||
case 'watch':
|
||||
player.state.status = 'circle';
|
||||
data.getSong(loc[1] + location.search);
|
||||
console.log(loc[1]);
|
||||
break;
|
||||
case 'playlist':
|
||||
results.getAlbum(loc[1] + location.search);
|
||||
console.log(loc[1]);
|
||||
break;
|
||||
case 'channel':
|
||||
artist.getArtist(loc[2]);
|
||||
console.log(loc[2]);
|
||||
break;
|
||||
case 'explore':
|
||||
genreid.value = loc[2];
|
||||
|
|
|
@ -13,23 +13,23 @@ const { t } = useI18n(),
|
|||
source = ref(''),
|
||||
status = ref(false);
|
||||
|
||||
function set(id) {
|
||||
getJsonHyp('/lyrics/' + id).then(res => {
|
||||
text.value = res.text;
|
||||
source.value = res.source;
|
||||
status.value = true;
|
||||
});
|
||||
}
|
||||
|
||||
function get() {
|
||||
status.value = false;
|
||||
|
||||
const set = id => {
|
||||
getJsonHyp('/browse/' + id).then(res => {
|
||||
text.value = res.text;
|
||||
source.value = res.source;
|
||||
status.value = true;
|
||||
});
|
||||
};
|
||||
|
||||
if (data.state.lyrics && data.state.urls === data.state.url) {
|
||||
set(data.state.lyrics);
|
||||
} else if (data.state.url) {
|
||||
getJsonHyp('/next/' + data.state.url.replace('/watch?v=', '')).then(
|
||||
next => {
|
||||
if (next.lyricsId) set(next.lyricsId);
|
||||
({ lyricsId }) => {
|
||||
if (lyricsId) set(lyricsId);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
@ -44,8 +44,6 @@ const shuffleAdd = () => {
|
|||
delete songs[nos];
|
||||
}
|
||||
|
||||
console.log(songs, copy);
|
||||
|
||||
emit('play-urls', copy);
|
||||
},
|
||||
openSong = (song, nxt = false) => {
|
||||
|
@ -75,8 +73,6 @@ const shuffleAdd = () => {
|
|||
}
|
||||
},
|
||||
removeSong = i => {
|
||||
console.log(i);
|
||||
|
||||
results.items.songs.items.splice(i, 1);
|
||||
},
|
||||
shareAlbum = () => {
|
||||
|
@ -158,7 +154,6 @@ const shuffleAdd = () => {
|
|||
|
||||
items = json.items;
|
||||
} else {
|
||||
console.log(results.next);
|
||||
const json = await getJsonPiped(`/nextpage/playlists/${results.next}`);
|
||||
key = 'songs';
|
||||
|
||||
|
@ -168,8 +163,6 @@ const shuffleAdd = () => {
|
|||
results.items[key].items.push(...items);
|
||||
|
||||
loading.value = false;
|
||||
|
||||
console.log(items, results.items);
|
||||
}
|
||||
},
|
||||
getResults = async q => {
|
||||
|
@ -182,7 +175,6 @@ const shuffleAdd = () => {
|
|||
results.next = json.nextpage;
|
||||
|
||||
results.setItem(key, json);
|
||||
console.log(json, key);
|
||||
};
|
||||
|
||||
watch(
|
||||
|
@ -191,8 +183,6 @@ watch(
|
|||
if (n) {
|
||||
n = n.replace(location.search || '', '');
|
||||
|
||||
console.log(n);
|
||||
|
||||
artist.reset();
|
||||
getSearch(n);
|
||||
}
|
||||
|
@ -341,6 +331,12 @@ onDeactivated(() => {
|
|||
results.getAlbum(album.url || '/playlist?list=' + album.id)
|
||||
" />
|
||||
</div>
|
||||
<a
|
||||
v-if="results.items.albums.more?.params"
|
||||
@click.prevent="artist.getArtistNext('albums', results.items.albums.more)"
|
||||
class="more"
|
||||
>{{ t('info.see_all') }}</a
|
||||
>
|
||||
</div>
|
||||
|
||||
<div
|
||||
|
@ -371,6 +367,14 @@ onDeactivated(() => {
|
|||
:art="single.thumbnails[0].url"
|
||||
@open-album="results.getAlbum('/playlist?list=' + single.id)" />
|
||||
</div>
|
||||
<a
|
||||
v-if="results.items.singles.more?.params"
|
||||
@click.prevent="
|
||||
artist.getArtistNext('singles', results.items.singles.more)
|
||||
"
|
||||
class="more"
|
||||
>{{ t('info.see_all') }}</a
|
||||
>
|
||||
</div>
|
||||
|
||||
<div
|
||||
|
|
|
@ -15,7 +15,6 @@ export const useResults = defineStore('results', () => {
|
|||
|
||||
function setItem(key, val) {
|
||||
items.value[key] = val;
|
||||
console.log(items.value);
|
||||
}
|
||||
|
||||
function resetItems() {
|
||||
|
@ -23,28 +22,22 @@ export const useResults = defineStore('results', () => {
|
|||
album.value = undefined;
|
||||
|
||||
useArtist().reset();
|
||||
for (let i in items.value) {
|
||||
items.value[i] = undefined;
|
||||
}
|
||||
|
||||
for (let i in items.value) items.value[i] = undefined;
|
||||
}
|
||||
|
||||
async function getExplore() {
|
||||
const json = await getJsonHyp('/explore');
|
||||
|
||||
console.log(json);
|
||||
resetItems();
|
||||
|
||||
chartsId.value = json.chartsId;
|
||||
|
||||
console.log(chartsId.value, json.chartsId);
|
||||
|
||||
setItem('songs', { items: json.trending });
|
||||
setItem('albums', { items: json.albums_and_singles });
|
||||
}
|
||||
|
||||
async function getAlbum(e) {
|
||||
console.log('Album: ', e);
|
||||
|
||||
const hash = new URLSearchParams(e.substring(e.indexOf('?'))).get('list'),
|
||||
isAuth =
|
||||
/[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}/.test(
|
||||
|
@ -53,8 +46,6 @@ export const useResults = defineStore('results', () => {
|
|||
path = '/playlists/' + hash,
|
||||
json = isAuth ? await getJsonAuth(path) : await getJsonPiped(path);
|
||||
|
||||
console.log(json, json.relatedStreams);
|
||||
|
||||
resetItems();
|
||||
|
||||
album.value = e;
|
||||
|
@ -102,10 +93,10 @@ export const useArtist = defineStore('artist', () => {
|
|||
thumbnails: [],
|
||||
});
|
||||
|
||||
const results = useResults();
|
||||
|
||||
function reset() {
|
||||
for (let i in state) {
|
||||
state[i] = undefined;
|
||||
}
|
||||
for (let i in state) state[i] = undefined;
|
||||
}
|
||||
|
||||
function set(obj) {
|
||||
|
@ -115,22 +106,17 @@ export const useArtist = defineStore('artist', () => {
|
|||
}
|
||||
|
||||
async function getArtist(e) {
|
||||
console.log(e);
|
||||
|
||||
e = e.replace('/channel/', '');
|
||||
|
||||
const json = await getJsonHyp('/channel/' + e),
|
||||
results = useResults();
|
||||
|
||||
console.log(json);
|
||||
const json = await getJsonHyp('/channel/' + e);
|
||||
|
||||
results.resetItems();
|
||||
|
||||
for (let i in json.items) {
|
||||
results.setItem(i, { items: json.items[i] });
|
||||
}
|
||||
|
||||
console.log(results.items);
|
||||
for (let i in json.items)
|
||||
results.setItem(i, {
|
||||
items: json.items[i],
|
||||
more: json.more[i] ? { ...json.more[i], ...{ id: e } } : null,
|
||||
});
|
||||
|
||||
json.items = undefined;
|
||||
json.hash = e;
|
||||
|
@ -142,5 +128,20 @@ export const useArtist = defineStore('artist', () => {
|
|||
useNav().state.page = 'home';
|
||||
}
|
||||
|
||||
return { state, set, reset, getArtist };
|
||||
async function getArtistNext(i, { id, params, click, visit }) {
|
||||
if (!id || !params || !click || !visit) return;
|
||||
|
||||
const json = await getJsonHyp(
|
||||
`/next/channel/${id}/${params}?ct=${click}&v=${visit}`,
|
||||
);
|
||||
|
||||
results.resetItems();
|
||||
reset();
|
||||
|
||||
results.setItem(i, {
|
||||
items: json.items,
|
||||
});
|
||||
}
|
||||
|
||||
return { state, set, reset, getArtist, getArtistNext };
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue