Added Lyrics Support

This commit is contained in:
Shiny Nematoda 2022-05-16 00:02:55 +05:30
parent 0c1bb172b1
commit 592ac8c470
6 changed files with 155 additions and 20 deletions

View file

@ -1,3 +1,4 @@
node_modules node_modules
dist dist
public public
*.md

21
ISSUE_TEMPLATE.md Normal file
View file

@ -0,0 +1,21 @@
## Browser
- [ ] Chromium Based
- [ ] Firefox Based
- [ ] Other
<!-- Name and Version -->.
## Expected Behaviour
<!-- TODO -->
## Actual Behaviour
<!-- TODO -->
## Misc. ( optional )
<!-- Screen Shots / Console Logs / Network Requests / Anything else Relevent -->

View file

@ -1,4 +1,4 @@
# \[WIP\] Hyperpipe # [WIP] Hyperpipe
![On Codeberg](https://codeberg.org/Hyperpipe/static/raw/branch/master/on-codeberg.svg) ![On Codeberg](https://codeberg.org/Hyperpipe/static/raw/branch/master/on-codeberg.svg)
@ -13,9 +13,9 @@ A Privacy Respecting Frontend for YouTube Music inspired and built with the help
- Bugs - Bugs
- Messy Code - Messy Code
- Stuff the used to work to Break in the future. - Stuff that used to work to break in the future.
_But if you see any on the following, Please open an issue_ _But if you see any of the following, Please open an issue_
## Usage ## Usage
@ -49,15 +49,21 @@ npm run build
| :--------------------------: | :---------------: | | :--------------------------: | :---------------: |
| [hyperpipe.surge.sh][hypipe] | 🇩🇪 | | [hyperpipe.surge.sh][hypipe] | 🇩🇪 |
## LICENSE ## LICENSE
### GPL v3 Only ### GPL v3 Only
Please refer to [LICENSE][license]. Please refer to [LICENSE][license].
You can reach out to me on ## Help
Feel free to join in on [Matrix!](https://matrix.to/#/#hyperpipe:nitro.chat)
You can reach out to me personally on:
- snematoda [dot] 751k2 [at] aleeas [dot] com - snematoda [dot] 751k2 [at] aleeas [dot] com
- [Matrix - @snematoda:nitro.chat ](https://matrix.to/#/@snematoda:nitro.chat)
### Dependencies and Mentions ### Dependencies and Mentions

View file

@ -8,6 +8,7 @@ import NowPlaying from './components/NowPlaying.vue';
import Search from './components/Search.vue'; import Search from './components/Search.vue';
import NewPlaylist from './components/NewPlaylist.vue'; import NewPlaylist from './components/NewPlaylist.vue';
import Playlists from './components/Playlists.vue'; import Playlists from './components/Playlists.vue';
import Lyrics from './components/Lyrics.vue';
import Artist from './components/Artist.vue'; import Artist from './components/Artist.vue';
import Prefs from './components/Prefs.vue'; import Prefs from './components/Prefs.vue';
@ -31,7 +32,9 @@ const data = reactive({
duration: 0, duration: 0,
time: 0, time: 0,
showplaylist: false, showplaylist: false,
showlyrics: false,
loop: false, loop: false,
lyrics: '',
}); });
const artist = reactive({ const artist = reactive({
@ -210,13 +213,15 @@ async function getArtist(e) {
async function getNext(hash) { async function getNext(hash) {
if ( if (
!data.urls || !data.urls ||
data.urls.filter(s => s.url == data.url) || !data.urls.filter(s => s.url == data.url)[0] ||
data.urls.length == 1 data.urls.length == 1
) { ) {
const json = await getJson( const json = await getJson(
'https://hyperpipeapi.onrender.com/next/' + hash, 'https://hyperpipeapi.onrender.com/next/' + hash,
); );
data.lyrics = json.lyricsId;
data.url = '/watch?v=' + json.songs[0].id; data.url = '/watch?v=' + json.songs[0].id;
console.log(json); console.log(json);
@ -432,16 +437,24 @@ onMounted(() => {
:urls="data.urls" :urls="data.urls"
:show="data.showplaylist" /> :show="data.showplaylist" />
<Lyrics
v-if="data.showlyrics"
:id="data.lyrics"
:curl="data.url"
:iniurl="data.urls[0]?.url" />
<StatusBar <StatusBar
@play="playPause" @play="playPause"
@vol="setVolume" @vol="setVolume"
@list="Toggle" @list="Toggle"
@lyrics="Toggle"
@loop="Toggle" @loop="Toggle"
@save="SaveTrack" @save="SaveTrack"
@change-time="setTime" @change-time="setTime"
:state="data.state" :state="data.state"
:time="data.time" :time="data.time"
:show="data.showplaylist" :show="data.showplaylist"
:lyrics="data.showlyrics"
:loop="data.loop" /> :loop="data.loop" />
<audio <audio

86
src/components/Lyrics.vue Normal file
View file

@ -0,0 +1,86 @@
<script setup>
import { ref, watch } from 'vue';
import { getJson } from '../scripts/fetch.js';
const props = defineProps({
id: String,
curl: String,
iniurl: String,
}),
text = ref(''),
source = ref('');
console.log(props);
function get() {
if (props.id && props.curl === props.iniurl) {
console.log(props.id);
getJson('https://hyperpipeapi.onrender.com/browse/' + props.id).then(
res => {
text.value = res.text;
source.value = res.source;
},
);
} else if (props.curl) {
getJson(
'https://hyperpipeapi.onrender.com/next/' +
props.curl.replace('/watch?v=', ''),
).then(next => {
getJson('https://hyperpipeapi.onrender.com/browse/' + next.lyricsId).then(
res => {
text.value = res.text;
source.value = res.source;
},
);
});
}
}
get();
watch(
() => props.curl,
() => {
get();
},
);
</script>
<template>
<div class="ly-modal">
<pre>{{ text }}</pre>
<div>{{ source }}</div>
</div>
</template>
<style scoped>
.ly-modal {
display: flex;
flex-direction: column;
position: fixed;
top: 2rem;
bottom: 5rem;
right: 1rem;
width: 30rem;
max-width: calc(100% - 2rem);
background: var(--color-background-mute);
border-radius: 0.5rem;
z-index: 99999;
box-shadow: 0.1rem 0.1rem 1rem var(--color-shadow);
padding: 1rem;
overflow-y: auto;
}
pre {
font-family: inherit;
font-size: 1.25rem;
letter-spacing: 0.125rem;
white-space: pre-wrap;
}
div {
padding: 1rem;
letter-spacing: 0.1rem;
font-weight: 600;
}
</style>

View file

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, watch } from 'vue'; import { ref, reactive, watch } from 'vue';
import Modal from './Modal.vue'; import Modal from './Modal.vue';
import { useListPlaylists } from '../scripts/db.js'; import { useListPlaylists } from '../scripts/db.js';
@ -8,29 +8,33 @@ defineProps({
time: Number, time: Number,
show: Boolean, show: Boolean,
loop: Boolean, loop: Boolean,
lyrics: Boolean,
}); });
const emit = defineEmits([ const emit = defineEmits([
'vol', 'vol',
'play', 'play',
'list', 'list',
'lyrics',
'loop', 'loop',
'save', 'save',
'change-time', 'change-time',
]), ]),
showVol = ref(false),
vol = ref(1), vol = ref(1),
showmenu = ref(false), showme = reactive({
showpl = ref(false), menu: false,
pl: false,
vol: false,
}),
pl = ref(''), pl = ref(''),
list = ref([]); list = ref([]);
function Save() { function Save() {
showpl.value = true; showme.pl = true;
useListPlaylists(res => { useListPlaylists(res => {
console.log(res); console.log(res);
list.value = res; list.value = res;
showmenu.value = false; showme.menu = false;
}); });
} }
</script> </script>
@ -39,11 +43,11 @@ function Save() {
<Transition name="fade"> <Transition name="fade">
<Modal <Modal
n="2" n="2"
:display="showpl" :display="showme.pl"
title="Select Playlist to Add" title="Select Playlist to Add"
@show=" @show="
e => { e => {
showpl = e; showme.pl = e;
} }
"> ">
<template #content> <template #content>
@ -55,12 +59,12 @@ function Save() {
</template> </template>
</template> </template>
<template #buttons> <template #buttons>
<button aria-label="Cancel" @click="showpl = false">Cancel</button> <button aria-label="Cancel" @click="showme.pl = false">Cancel</button>
<button <button
aria-label="Add Song" aria-label="Add Song"
@click=" @click="
if (pl) $emit('save', pl); if (pl) $emit('save', pl);
showpl = false; showme.pl = false;
"> ">
Add Add
</button> </button>
@ -95,10 +99,10 @@ function Save() {
<button <button
id="vol-btn" id="vol-btn"
aria-label="Volume Buttons" aria-label="Volume Buttons"
@click="showVol = !showVol" @click="showme.vol = !showme.vol"
class="popup-wrap bi bi-volume-up"> class="popup-wrap bi bi-volume-up">
<Transition name="fade"> <Transition name="fade">
<div v-if="showVol" id="vol" class="popup"> <div v-if="showme.vol" id="vol" class="popup">
<input <input
id="vol-input" id="vol-input"
aria-label="Volume Input" aria-label="Volume Input"
@ -117,10 +121,10 @@ function Save() {
class="bi bi-three-dots" class="bi bi-three-dots"
aria-label="More Controls" aria-label="More Controls"
@click=" @click="
showmenu = !showmenu; showme.menu = !showme.menu;
if (show) $emit('list', 'showplaylist'); show ?? $emit('list', 'showplaylist');
"></button> "></button>
<div id="menu" v-if="showmenu" class="popup"> <div id="menu" v-if="showme.menu" class="popup">
<button <button
id="addToPlaylist" id="addToPlaylist"
title="Add Current Song to a Playlist" title="Add Current Song to a Playlist"
@ -133,6 +137,10 @@ function Save() {
aria-label="Current Playlist" aria-label="Current Playlist"
:class="'bi bi-music-note-list ' + show" :class="'bi bi-music-note-list ' + show"
@click="$emit('list', 'showplaylist')"></button> @click="$emit('list', 'showplaylist')"></button>
<button
id="btn-lyrics"
:class="'bi bi-file-music ' + lyrics"
@click="$emit('lyrics', 'showlyrics')"></button>
<button <button
id="loop-btn" id="loop-btn"
title="Loop" title="Loop"