diff --git a/server/app/helpers.py b/server/app/helpers.py
index d0ebfdc..cb63975 100644
--- a/server/app/helpers.py
+++ b/server/app/helpers.py
@@ -1,9 +1,7 @@
"""
This module contains mini functions for the server.
"""
-from dataclasses import dataclass
import os
-from pprint import pprint
import threading
from datetime import datetime
from typing import Dict, Set
@@ -13,7 +11,6 @@ import requests
from app import models
from app import instances
-from app.lib.albumslib import Thumbnail
def background(func):
@@ -53,8 +50,6 @@ def run_fast_scandir(__dir: str, full=False) -> Dict[List[str], List[str]]:
return subfolders, files
-
-
class RemoveDuplicates:
def __init__(self, tracklist: List[models.Track]) -> None:
self.tracklist = tracklist
@@ -77,15 +72,12 @@ def is_valid_file(filename: str) -> bool:
return False
-ill_chars = '/\\:*?"<>|#&'
-
-
def create_album_hash(title: str, artist: str) -> str:
"""
Creates a simple hash for an album
"""
lower = (title + artist).replace(" ", "").lower()
- hash = "".join([i for i in lower if i not in ill_chars])
+ hash = "".join([i for i in lower if i.isalnum()])
return hash
@@ -99,7 +91,7 @@ def create_safe_name(name: str) -> str:
"""
Creates a url-safe name from a name.
"""
- return "".join([i for i in name if i not in ill_chars])
+ return "".join([i for i in name if i.isalnum()])
class UseBisection:
diff --git a/server/app/models.py b/server/app/models.py
index fc24ed1..4f406ee 100644
--- a/server/app/models.py
+++ b/server/app/models.py
@@ -54,10 +54,8 @@ class Track:
@staticmethod
def create_unique_hash(*args):
- ill_chars = '/\\:*?"<>|#&'
-
string = "".join(str(a) for a in args).replace(" ", "")
- return "".join(string).strip(ill_chars).lower()
+ return "".join([i for i in string if i.isalnum()]).lower()
@dataclass(slots=True)
diff --git a/src/components/AlbumView/Header.vue b/src/components/AlbumView/Header.vue
index c5b7ea5..270a489 100644
--- a/src/components/AlbumView/Header.vue
+++ b/src/components/AlbumView/Header.vue
@@ -35,7 +35,11 @@
{{ formatSeconds(album.duration, true) }} • {{ album.date }} •
{{ album.artist }}
-
+
@@ -73,10 +77,57 @@ function isLight(rgb: string = props.album.colors[0]) {
const [r, g, b] = rgb.match(/\d+/g)!.map(Number);
const brightness = (r * 299 + g * 587 + b * 114) / 1000;
- console.log(brightness);
- return brightness > 150;
+ return brightness > 170;
}
+
+function getButtonColor(colors: string[] = props.album.colors) {
+ const base_color = colors[0];
+ console.log(colors.length);
+ if (colors.length === 0) return { color: "#000" };
+
+ for (let i = 0; i < colors.length; i++) {
+ // if (isLight(colors[i])) break;
+ if (theyContrast(base_color, colors[i])) {
+ return {
+ color: colors[i],
+ isDark: isLight(colors[i]),
+ };
+ }
+ }
+
+ return {
+ color: "#000",
+ };
+}
+
+function luminance(r: any, g: any, b: any) {
+ let a = [r, g, b].map(function (v) {
+ v /= 255;
+ return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
+ });
+ return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
+}
+
+function contrast(rgb1: number[], rgb2: number[]) {
+ let lum1 = luminance(rgb1[0], rgb1[1], rgb1[2]);
+ let lum2 = luminance(rgb2[0], rgb2[1], rgb2[2]);
+ let brightest = Math.max(lum1, lum2);
+ let darkest = Math.min(lum1, lum2);
+ return (brightest + 0.05) / (darkest + 0.05);
+}
+
+function rgbToArray(rgb: string) {
+ return rgb.match(/\d+/g)!.map(Number);
+}
+
+function theyContrast(color1: string, color2: string) {
+ return contrast(rgbToArray(color1), rgbToArray(color2)) > 3;
+}
+
+console.log(
+ contrast(rgbToArray(props.album.colors[0]), rgbToArray(props.album.colors[3]))
+);
diff --git a/src/components/shared/SongItem.vue b/src/components/shared/SongItem.vue
index d7b8bc3..d904db8 100644
--- a/src/components/shared/SongItem.vue
+++ b/src/components/shared/SongItem.vue
@@ -157,6 +157,10 @@ function emitUpdate(track: Track) {
max-width: max-content;
cursor: pointer;
+ &:hover {
+ text-decoration: underline;
+ }
+
@include tablet-portrait {
display: none;
}