mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
improve nowPlaying alignment
This commit is contained in:
@@ -145,6 +145,9 @@ def get_albumartists(album, artist):
|
||||
|
||||
@bp.route("/populate/images")
|
||||
def populate_images():
|
||||
"""
|
||||
Populates the artist images.
|
||||
"""
|
||||
functions.populate_images()
|
||||
return "Done"
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ def populate():
|
||||
|
||||
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:
|
||||
@@ -66,7 +66,7 @@ def fetch_image_path(artist: str) -> str or None:
|
||||
except requests.exceptions.ConnectionError:
|
||||
time.sleep(5)
|
||||
return None
|
||||
except IndexError:
|
||||
except (IndexError, KeyError):
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@@ -20,12 +20,14 @@ LAST_FM_API_KEY = "762db7a44a9e6fb5585661f5f2bdf23a"
|
||||
|
||||
|
||||
def background(f):
|
||||
'''
|
||||
"""
|
||||
a threading decorator
|
||||
use @background above the function you want to run in the background
|
||||
'''
|
||||
"""
|
||||
|
||||
def background_func(*a, **kw):
|
||||
threading.Thread(target=f, args=a, kwargs=kw).start()
|
||||
|
||||
return background_func
|
||||
|
||||
|
||||
@@ -40,10 +42,9 @@ def check_for_new_songs():
|
||||
functions.populate()
|
||||
functions.populate_images()
|
||||
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.
|
||||
"""
|
||||
@@ -96,7 +97,7 @@ def save_image(url: str, path: str) -> None:
|
||||
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.
|
||||
"""
|
||||
@@ -120,7 +121,7 @@ def create_config_dir() -> None:
|
||||
|
||||
for _dir in dirs:
|
||||
path = os.path.join(config_folder, _dir)
|
||||
|
||||
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except FileExistsError:
|
||||
@@ -128,6 +129,7 @@ def create_config_dir() -> None:
|
||||
|
||||
os.chmod(path, 0o755)
|
||||
|
||||
|
||||
def get_all_songs() -> List:
|
||||
"""
|
||||
Gets all songs under the ~/ directory.
|
||||
|
||||
+2
-6
@@ -69,10 +69,8 @@ export default {
|
||||
position: absolute;
|
||||
width: 3rem;
|
||||
height: 100%;
|
||||
background: url(./assets/icons/menu.svg);
|
||||
background-size: 2rem;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background: url(./assets/icons/menu.svg) no-repeat center;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
@@ -80,10 +78,8 @@ export default {
|
||||
height: 2rem;
|
||||
width: 9rem;
|
||||
margin-left: 3rem;
|
||||
background: url(./assets/logo.svg);
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background: url(./assets/logo.svg) no-repeat center;
|
||||
}
|
||||
|
||||
.r-sidebar {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
width: 3rem;
|
||||
height: 3rem;
|
||||
border-radius: $smaller;
|
||||
background-image: url("../../images/eggs.jpg");
|
||||
background-image: url("../../images/null.webp");
|
||||
}
|
||||
|
||||
.separator {
|
||||
|
||||
@@ -154,6 +154,18 @@ button {
|
||||
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 */
|
||||
|
||||
/* width */
|
||||
|
||||
@@ -66,7 +66,7 @@ export default {
|
||||
gap: $small;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
height: 15rem;
|
||||
height: 14rem;
|
||||
|
||||
.right {
|
||||
@include tablet-landscape {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="artists" v-else>
|
||||
<span>{{ track.album_artist }}</span>
|
||||
<span>{{ track.albumartist }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -40,7 +40,6 @@ export default {
|
||||
}
|
||||
|
||||
watch(query, () => {
|
||||
console.log(query.value);
|
||||
emit("search", query.value);
|
||||
});
|
||||
|
||||
|
||||
@@ -74,8 +74,8 @@ function updateQueue(song) {
|
||||
perks.updateQueue(song, type);
|
||||
}
|
||||
|
||||
function loadAlbum(title, album_artist) {
|
||||
routeLoader.toAlbum(title, album_artist);
|
||||
function loadAlbum(title, albumartist) {
|
||||
routeLoader.toAlbum(title, albumartist);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
.p-header {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
height: 15rem;
|
||||
height: 14rem;
|
||||
background-image: url("../../assets/images/eggs.jpg");
|
||||
position: relative;
|
||||
|
||||
|
||||
@@ -1,23 +1,29 @@
|
||||
<template>
|
||||
<div class="now-playing border">
|
||||
<div class="now-playing border shadow-lg">
|
||||
<div class="art-tags">
|
||||
<div class="duration">{{ current.length }}</div>
|
||||
<div
|
||||
class="album-art image border"
|
||||
:style="{
|
||||
backgroundImage: `url("${current.image}")`,
|
||||
}"
|
||||
class="album-art image border"
|
||||
></div>
|
||||
<div>
|
||||
<div class="t-a">
|
||||
<p id="title" class="ellipsis">{{ current.title }}</p>
|
||||
<hr />
|
||||
<div id="artist" class="ellip" v-if="current.artists[0] != ''">
|
||||
<div class="separator no-border"></div>
|
||||
<div v-if="current.artists[0] != ''" id="artist" class="ellip">
|
||||
<span v-for="artist in putCommas(current.artists)" :key="artist">{{
|
||||
artist
|
||||
}}</span>
|
||||
</div>
|
||||
<div id="artist" v-else>
|
||||
<span>{{ current.album_artist }}</span>
|
||||
<div v-else id="artist">
|
||||
<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>
|
||||
@@ -26,37 +32,35 @@
|
||||
<Progress />
|
||||
</div>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="shuffle">
|
||||
<div class="image"></div>
|
||||
<div class="image"></div>
|
||||
</div>
|
||||
<HotKeys />
|
||||
<div class="fav">
|
||||
<div class="image"></div>
|
||||
<div class="image"></div>
|
||||
<div class="c-wrapper border rounded">
|
||||
<div class="controls">
|
||||
<div class="shuffle">
|
||||
<div class="image"></div>
|
||||
<div class="image"></div>
|
||||
</div>
|
||||
<HotKeys />
|
||||
<div class="fav">
|
||||
<div class="image"></div>
|
||||
<div class="image"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref } from "@vue/reactivity";
|
||||
|
||||
import perks from "../../composables/perks.js";
|
||||
import playAudio from "@/composables/playAudio.js";
|
||||
|
||||
import Progress from "../shared/Progress.vue";
|
||||
import { ref } from "@vue/reactivity";
|
||||
import perks from "../../composables/perks.js";
|
||||
import HotKeys from "../shared/HotKeys.vue";
|
||||
import Progress from "../shared/Progress.vue";
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const current = ref(perks.current);
|
||||
const putCommas = perks.putCommas;
|
||||
const pos = playAudio.pos;
|
||||
function fmtMSS(s) {
|
||||
return (s - (s %= 60)) / 60 + (9 < s ? ":" : ":0") + s;
|
||||
}
|
||||
|
||||
const { playNext } = playAudio;
|
||||
const { playPrev } = playAudio;
|
||||
const { playPause } = playAudio;
|
||||
@@ -73,7 +77,6 @@ export default {
|
||||
pos,
|
||||
seek,
|
||||
isPlaying,
|
||||
fmtMSS,
|
||||
};
|
||||
},
|
||||
components: { Progress, HotKeys },
|
||||
@@ -83,39 +86,56 @@ export default {
|
||||
<style lang="scss">
|
||||
.now-playing {
|
||||
border-radius: 0.5rem;
|
||||
height: 15rem;
|
||||
height: 13.5rem;
|
||||
padding: 0.5rem;
|
||||
background: $card-dark;
|
||||
display: grid;
|
||||
grid-template-rows: 3fr 1fr;
|
||||
|
||||
.progress {
|
||||
display: flex;
|
||||
|
||||
.prog {
|
||||
width: 100%;
|
||||
display: grid;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.art-tags {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
|
||||
.t-a {
|
||||
#title {
|
||||
margin: 0;
|
||||
width: 20rem;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#artist {
|
||||
font-size: 0.8rem;
|
||||
width: 20rem;
|
||||
color: $highlight-blue;
|
||||
}
|
||||
}
|
||||
|
||||
.duration {
|
||||
position: absolute;
|
||||
bottom: $small;
|
||||
right: 0;
|
||||
font-size: .9rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
hr {
|
||||
border: none;
|
||||
margin: 0.3rem;
|
||||
}
|
||||
|
||||
#title {
|
||||
margin: 0;
|
||||
width: 20rem;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#artist {
|
||||
font-size: small;
|
||||
width: 20rem;
|
||||
color: $highlight-blue;
|
||||
#type {
|
||||
font-size: $medium;
|
||||
color: $red;
|
||||
padding: $smaller;
|
||||
border-radius: $smaller;
|
||||
position: absolute;
|
||||
bottom: 0.1rem;
|
||||
border: solid 1px $red;
|
||||
}
|
||||
|
||||
.album-art {
|
||||
@@ -123,9 +143,16 @@ export default {
|
||||
height: 7rem;
|
||||
border-radius: 0.5rem;
|
||||
margin-right: 0.5rem;
|
||||
margin-left: $small;
|
||||
background-image: url("../../assets/images/null.webp");
|
||||
}
|
||||
}
|
||||
|
||||
.c-wrapper {
|
||||
background-color: $bbb;
|
||||
height: 3.5rem;
|
||||
padding: 0 $small;
|
||||
display: grid;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -31,11 +31,11 @@
|
||||
>
|
||||
</div>
|
||||
<div class="ellip" v-else>
|
||||
<span class="artist">{{ song.album_artist }}</span>
|
||||
<span class="artist">{{ song.albumartist }}</span>
|
||||
</div>
|
||||
</td>
|
||||
<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 }}
|
||||
</div>
|
||||
</td>
|
||||
@@ -94,6 +94,7 @@ export default {
|
||||
}
|
||||
|
||||
.song-duration {
|
||||
font-size: .8rem;
|
||||
width: 5rem !important;
|
||||
}
|
||||
|
||||
@@ -143,6 +144,9 @@ export default {
|
||||
}
|
||||
|
||||
&:hover {
|
||||
* {
|
||||
color: #fff;
|
||||
}
|
||||
& {
|
||||
& td {
|
||||
background-color: rgb(5, 80, 150);
|
||||
@@ -173,7 +177,6 @@ export default {
|
||||
& > td:nth-child(4) {
|
||||
@include tablet-landscape {
|
||||
border-radius: 0 $small $small 0 !important;
|
||||
// border: solid red !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ const putCommas = (artists) => {
|
||||
};
|
||||
|
||||
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) {
|
||||
next.value = queue.value[0];
|
||||
@@ -50,7 +50,7 @@ function updateNext(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) {
|
||||
prev.value = queue.value[queue.value.length - 1];
|
||||
@@ -131,6 +131,7 @@ function focusSearchBox() {
|
||||
|
||||
setTimeout(() => {
|
||||
watch(current, (new_current) => {
|
||||
|
||||
media.showMediaNotif();
|
||||
|
||||
updateNext(new_current);
|
||||
|
||||
@@ -11,7 +11,6 @@ const playing = ref(state.is_playing);
|
||||
const url = "http://0.0.0.0:8901/";
|
||||
|
||||
const playAudio = (path) => {
|
||||
console.log(path)
|
||||
const elem = document.getElementById('progress')
|
||||
const full_path = url + encodeURIComponent(path);
|
||||
|
||||
@@ -42,7 +41,7 @@ function playNext() {
|
||||
}
|
||||
|
||||
function playPrev() {
|
||||
playAudio(perks.prev.value.filepath);
|
||||
playAudio(state.prev.value.filepath);
|
||||
perks.current.value = perks.prev.value;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user