improve nowPlaying alignment

This commit is contained in:
geoffrey45
2022-02-08 00:39:08 +03:00
parent f93fa79fc5
commit 214ae82344
15 changed files with 113 additions and 71 deletions
+3
View File
@@ -145,6 +145,9 @@ def get_albumartists(album, artist):
@bp.route("/populate/images") @bp.route("/populate/images")
def populate_images(): def populate_images():
"""
Populates the artist images.
"""
functions.populate_images() functions.populate_images()
return "Done" return "Done"
+2 -2
View File
@@ -54,7 +54,7 @@ def populate():
def fetch_image_path(artist: str) -> str or None: def fetch_image_path(artist: str) -> str or None:
""" """
Returns a direct link to an artist artist Returns a direct link to an artist image.
""" """
try: try:
@@ -66,7 +66,7 @@ def fetch_image_path(artist: str) -> str or None:
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError:
time.sleep(5) time.sleep(5)
return None return None
except IndexError: except (IndexError, KeyError):
return None return None
+8 -6
View File
@@ -20,12 +20,14 @@ LAST_FM_API_KEY = "762db7a44a9e6fb5585661f5f2bdf23a"
def background(f): def background(f):
''' """
a threading decorator a threading decorator
use @background above the function you want to run in the background use @background above the function you want to run in the background
''' """
def background_func(*a, **kw): def background_func(*a, **kw):
threading.Thread(target=f, args=a, kwargs=kw).start() threading.Thread(target=f, args=a, kwargs=kw).start()
return background_func return background_func
@@ -40,10 +42,9 @@ def check_for_new_songs():
functions.populate() functions.populate()
functions.populate_images() functions.populate_images()
time.sleep(300) time.sleep(300)
def run_fast_scandir(_dir:str, ext: list): def run_fast_scandir(_dir: str, ext: list):
""" """
Scans a directory for files with a specific extension. Returns a list of files and folders in the directory. Scans a directory for files with a specific extension. Returns a list of files and folders in the directory.
""" """
@@ -96,7 +97,7 @@ def save_image(url: str, path: str) -> None:
img.save(path, 'JPEG') img.save(path, 'JPEG')
def isValidFile(filename: str) -> bool: def is_valid_file(filename: str) -> bool:
""" """
Checks if a file is valid. Returns True if it is, False if it isn't. Checks if a file is valid. Returns True if it is, False if it isn't.
""" """
@@ -120,7 +121,7 @@ def create_config_dir() -> None:
for _dir in dirs: for _dir in dirs:
path = os.path.join(config_folder, _dir) path = os.path.join(config_folder, _dir)
try: try:
os.makedirs(path) os.makedirs(path)
except FileExistsError: except FileExistsError:
@@ -128,6 +129,7 @@ def create_config_dir() -> None:
os.chmod(path, 0o755) os.chmod(path, 0o755)
def get_all_songs() -> List: def get_all_songs() -> List:
""" """
Gets all songs under the ~/ directory. Gets all songs under the ~/ directory.
+2 -6
View File
@@ -69,10 +69,8 @@ export default {
position: absolute; position: absolute;
width: 3rem; width: 3rem;
height: 100%; height: 100%;
background: url(./assets/icons/menu.svg);
background-size: 2rem; background-size: 2rem;
background-repeat: no-repeat; background: url(./assets/icons/menu.svg) no-repeat center;
background-position: center;
cursor: pointer; cursor: pointer;
} }
} }
@@ -80,10 +78,8 @@ export default {
height: 2rem; height: 2rem;
width: 9rem; width: 9rem;
margin-left: 3rem; margin-left: 3rem;
background: url(./assets/logo.svg);
background-size: contain; background-size: contain;
background-repeat: no-repeat; background: url(./assets/logo.svg) no-repeat center;
background-position: center;
} }
.r-sidebar { .r-sidebar {
+1 -1
View File
@@ -19,7 +19,7 @@
width: 3rem; width: 3rem;
height: 3rem; height: 3rem;
border-radius: $smaller; border-radius: $smaller;
background-image: url("../../images/eggs.jpg"); background-image: url("../../images/null.webp");
} }
.separator { .separator {
+12
View File
@@ -154,6 +154,18 @@ button {
white-space: nowrap; white-space: nowrap;
} }
.shadow-sm {
box-shadow: 0rem 0rem .5rem rgb(0, 0, 0);
}
.shadow-md {
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.075);
}
.shadow-lg {
box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.175);
}
/* scrollbars */ /* scrollbars */
/* width */ /* width */
+1 -1
View File
@@ -66,7 +66,7 @@ export default {
gap: $small; gap: $small;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
height: 15rem; height: 14rem;
.right { .right {
@include tablet-landscape { @include tablet-landscape {
+1 -1
View File
@@ -16,7 +16,7 @@
}}</span> }}</span>
</div> </div>
<div class="artists" v-else> <div class="artists" v-else>
<span>{{ track.album_artist }}</span> <span>{{ track.albumartist }}</span>
</div> </div>
</div> </div>
</div> </div>
-1
View File
@@ -40,7 +40,6 @@ export default {
} }
watch(query, () => { watch(query, () => {
console.log(query.value);
emit("search", query.value); emit("search", query.value);
}); });
+2 -2
View File
@@ -74,8 +74,8 @@ function updateQueue(song) {
perks.updateQueue(song, type); perks.updateQueue(song, type);
} }
function loadAlbum(title, album_artist) { function loadAlbum(title, albumartist) {
routeLoader.toAlbum(title, album_artist); routeLoader.toAlbum(title, albumartist);
} }
</script> </script>
+1 -1
View File
@@ -26,7 +26,7 @@
.p-header { .p-header {
display: grid; display: grid;
grid-template-columns: 1fr; grid-template-columns: 1fr;
height: 15rem; height: 14rem;
background-image: url("../../assets/images/eggs.jpg"); background-image: url("../../assets/images/eggs.jpg");
position: relative; position: relative;
+70 -43
View File
@@ -1,23 +1,29 @@
<template> <template>
<div class="now-playing border"> <div class="now-playing border shadow-lg">
<div class="art-tags"> <div class="art-tags">
<div class="duration">{{ current.length }}</div> <div class="duration">{{ current.length }}</div>
<div <div
class="album-art image border"
:style="{ :style="{
backgroundImage: `url(&quot;${current.image}&quot;)`, backgroundImage: `url(&quot;${current.image}&quot;)`,
}" }"
class="album-art image border"
></div> ></div>
<div> <div class="t-a">
<p id="title" class="ellipsis">{{ current.title }}</p> <p id="title" class="ellipsis">{{ current.title }}</p>
<hr /> <div class="separator no-border"></div>
<div id="artist" class="ellip" v-if="current.artists[0] != ''"> <div v-if="current.artists[0] != ''" id="artist" class="ellip">
<span v-for="artist in putCommas(current.artists)" :key="artist">{{ <span v-for="artist in putCommas(current.artists)" :key="artist">{{
artist artist
}}</span> }}</span>
</div> </div>
<div id="artist" v-else> <div v-else id="artist">
<span>{{ current.album_artist }}</span> <span>{{ current.albumartist }}</span>
</div>
<div id="type">
<span v-if="current.bitrate > 330"
>FLAC {{ current.bitrate }} Kbps</span
>
<span v-else>MP3 | {{ current.bitrate }} Kbps</span>
</div> </div>
</div> </div>
</div> </div>
@@ -26,37 +32,35 @@
<Progress /> <Progress />
</div> </div>
</div> </div>
<div class="controls"> <div class="c-wrapper border rounded">
<div class="shuffle"> <div class="controls">
<div class="image"></div> <div class="shuffle">
<div class="image"></div> <div class="image"></div>
</div> <div class="image"></div>
<HotKeys /> </div>
<div class="fav"> <HotKeys />
<div class="image"></div> <div class="fav">
<div class="image"></div> <div class="image"></div>
<div class="image"></div>
</div>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { ref } from "@vue/reactivity";
import perks from "../../composables/perks.js";
import playAudio from "@/composables/playAudio.js"; import playAudio from "@/composables/playAudio.js";
import { ref } from "@vue/reactivity";
import Progress from "../shared/Progress.vue"; import perks from "../../composables/perks.js";
import HotKeys from "../shared/HotKeys.vue"; import HotKeys from "../shared/HotKeys.vue";
import Progress from "../shared/Progress.vue";
export default { export default {
setup() { setup() {
const current = ref(perks.current); const current = ref(perks.current);
const putCommas = perks.putCommas; const putCommas = perks.putCommas;
const pos = playAudio.pos; const pos = playAudio.pos;
function fmtMSS(s) {
return (s - (s %= 60)) / 60 + (9 < s ? ":" : ":0") + s;
}
const { playNext } = playAudio; const { playNext } = playAudio;
const { playPrev } = playAudio; const { playPrev } = playAudio;
const { playPause } = playAudio; const { playPause } = playAudio;
@@ -73,7 +77,6 @@ export default {
pos, pos,
seek, seek,
isPlaying, isPlaying,
fmtMSS,
}; };
}, },
components: { Progress, HotKeys }, components: { Progress, HotKeys },
@@ -83,39 +86,56 @@ export default {
<style lang="scss"> <style lang="scss">
.now-playing { .now-playing {
border-radius: 0.5rem; border-radius: 0.5rem;
height: 15rem; height: 13.5rem;
padding: 0.5rem; padding: 0.5rem;
background: $card-dark; background: $card-dark;
display: grid; display: grid;
grid-template-rows: 3fr 1fr; grid-template-rows: 3fr 1fr;
.progress {
display: flex;
.prog {
width: 100%;
display: grid;
align-items: center;
}
}
.art-tags { .art-tags {
display: flex; display: flex;
align-items: center; align-items: center;
position: relative; position: relative;
.t-a {
#title {
margin: 0;
width: 20rem;
color: #fff;
}
#artist {
font-size: 0.8rem;
width: 20rem;
color: $highlight-blue;
}
}
.duration { .duration {
position: absolute; position: absolute;
bottom: $small; bottom: $small;
right: 0; right: 0;
font-size: .9rem; font-size: 0.9rem;
} }
hr { #type {
border: none; font-size: $medium;
margin: 0.3rem; color: $red;
} padding: $smaller;
border-radius: $smaller;
#title { position: absolute;
margin: 0; bottom: 0.1rem;
width: 20rem; border: solid 1px $red;
color: #fff;
}
#artist {
font-size: small;
width: 20rem;
color: $highlight-blue;
} }
.album-art { .album-art {
@@ -123,9 +143,16 @@ export default {
height: 7rem; height: 7rem;
border-radius: 0.5rem; border-radius: 0.5rem;
margin-right: 0.5rem; margin-right: 0.5rem;
margin-left: $small;
background-image: url("../../assets/images/null.webp"); background-image: url("../../assets/images/null.webp");
} }
} }
.c-wrapper {
background-color: $bbb;
height: 3.5rem;
padding: 0 $small;
display: grid;
align-items: center;
}
} }
</style> </style>
+6 -3
View File
@@ -31,11 +31,11 @@
> >
</div> </div>
<div class="ellip" v-else> <div class="ellip" v-else>
<span class="artist">{{ song.album_artist }}</span> <span class="artist">{{ song.albumartist }}</span>
</div> </div>
</td> </td>
<td class="song-album"> <td class="song-album">
<div class="ellip" @click="emitLoadAlbum(song.album, song.album_artist)"> <div class="ellip" @click="emitLoadAlbum(song.album, song.albumartist)">
{{ song.album }} {{ song.album }}
</div> </div>
</td> </td>
@@ -94,6 +94,7 @@ export default {
} }
.song-duration { .song-duration {
font-size: .8rem;
width: 5rem !important; width: 5rem !important;
} }
@@ -143,6 +144,9 @@ export default {
} }
&:hover { &:hover {
* {
color: #fff;
}
& { & {
& td { & td {
background-color: rgb(5, 80, 150); background-color: rgb(5, 80, 150);
@@ -173,7 +177,6 @@ export default {
& > td:nth-child(4) { & > td:nth-child(4) {
@include tablet-landscape { @include tablet-landscape {
border-radius: 0 $small $small 0 !important; border-radius: 0 $small $small 0 !important;
// border: solid red !important;
} }
} }
+3 -2
View File
@@ -37,7 +37,7 @@ const putCommas = (artists) => {
}; };
function updateNext(song_) { function updateNext(song_) {
const index = state.queue.value.findIndex((item) => item.id === song_.id); const index = state.queue.value.findIndex((item) => item.track_id === song_.track_id);
if (index == queue.value.length - 1) { if (index == queue.value.length - 1) {
next.value = queue.value[0]; next.value = queue.value[0];
@@ -50,7 +50,7 @@ function updateNext(song_) {
} }
function updatePrev(song) { function updatePrev(song) {
const index = state.queue.value.findIndex((item) => item.id === song.track_id); const index = state.queue.value.findIndex((item) => item.track_id === song.track_id);
if (index == 0) { if (index == 0) {
prev.value = queue.value[queue.value.length - 1]; prev.value = queue.value[queue.value.length - 1];
@@ -131,6 +131,7 @@ function focusSearchBox() {
setTimeout(() => { setTimeout(() => {
watch(current, (new_current) => { watch(current, (new_current) => {
media.showMediaNotif(); media.showMediaNotif();
updateNext(new_current); updateNext(new_current);
+1 -2
View File
@@ -11,7 +11,6 @@ const playing = ref(state.is_playing);
const url = "http://0.0.0.0:8901/"; const url = "http://0.0.0.0:8901/";
const playAudio = (path) => { const playAudio = (path) => {
console.log(path)
const elem = document.getElementById('progress') const elem = document.getElementById('progress')
const full_path = url + encodeURIComponent(path); const full_path = url + encodeURIComponent(path);
@@ -42,7 +41,7 @@ function playNext() {
} }
function playPrev() { function playPrev() {
playAudio(perks.prev.value.filepath); playAudio(state.prev.value.filepath);
perks.current.value = perks.prev.value; perks.current.value = perks.prev.value;
} }