🔷 redesign playlist header

This commit is contained in:
geoffrey45
2022-04-03 13:38:42 +03:00
committed by Mungai Geoffrey
parent d0e2980dfe
commit 9c808aa817
44 changed files with 95 additions and 51 deletions
-1
View File
@@ -12,7 +12,6 @@ from app.lib import folderslib
folder_bp = Blueprint("folder", __name__, url_prefix="/")
from app import helpers
import time
@folder_bp.route("/folder", methods=["POST"])
+3 -2
View File
@@ -20,10 +20,11 @@ def send_track_file(trackid):
for file in api.PRE_TRACKS
if file["_id"]["$oid"] == trackid
][0]
return send_file(filepath, mimetype="audio/mp3")
except FileNotFoundError:
except (FileNotFoundError, IndexError):
return "File not found", 404
return send_file(filepath, mimetype="audio/mp3")
@track_bp.route("/sample")
def get_sample_track():
+6 -8
View File
@@ -8,7 +8,6 @@ from io import BytesIO
import random
import datetime
from typing import List
from flask import request
import mutagen
import urllib
@@ -24,10 +23,8 @@ from PIL import Image
from app import helpers
from app import instances
from app import settings, models
from app.lib import albumslib
from app import api
from app.lib import watchdoge
from app.lib import folderslib
from app.lib import watchdoge, folderslib, playlistlib, albumslib
@helpers.background
@@ -73,7 +70,7 @@ def populate():
upsert_id = instances.songs_instance.insert_song(tags)
if upsert_id is not None:
tags["_id"] = {"$oid": upsert_id}
tags["_id"] = {"$oid": str(upsert_id)}
api.PRE_TRACKS.append(tags)
_bar.next()
@@ -81,6 +78,7 @@ def populate():
albumslib.create_everything()
folderslib.run_scandir()
playlistlib.create_all_playlists()
end = time.time()
@@ -199,11 +197,10 @@ def save_t_colors():
_bar.finish()
def extract_thumb(audio_file_path: str) -> str:
def extract_thumb(audio_file_path: str, webp_path: str) -> str:
"""
Extracts the thumbnail from an audio file. Returns the path to the thumbnail.
"""
webp_path = audio_file_path.split("/")[-1] + ".webp"
img_path = os.path.join(settings.THUMBS_PATH, webp_path)
if os.path.exists(img_path):
@@ -221,7 +218,7 @@ def extract_thumb(audio_file_path: str) -> str:
try:
png = img.convert("RGB")
small_img = png.resize((250, 250), Image.ANTIALIAS)
small_img.save(img_path, format="webp")
small_img.save(webp_path, format="webp")
except:
return None
@@ -379,6 +376,7 @@ def get_all_albums() -> List[models.Album]:
"""
Returns a list of album objects for all albums in the database.
"""
albums: List[models.Album] = []
_bar = Bar("Creating albums", max=len(api.PRE_TRACKS))
+8 -3
View File
@@ -5,7 +5,7 @@ This library contains all the functions related to albums.
from pprint import pprint
import urllib
from typing import List
from app import models, functions, helpers
from app import models, functions
from app.lib import trackslib
from app import api
@@ -19,7 +19,11 @@ def create_everything() -> List[models.Track]:
api.ALBUMS.clear()
api.ALBUMS.extend(albums)
trackslib.create_all_tracks()
tracks = trackslib.create_all_tracks()
api.TRACKS.clear()
api.TRACKS.extend(tracks)
def get_album_duration(album: list) -> int:
@@ -41,7 +45,8 @@ def get_album_image(album: list) -> str:
"""
for track in album:
img = functions.extract_thumb(track["filepath"])
img_p = track["album"] + track["albumartist"] + ".webp"
img = functions.extract_thumb(track["filepath"], webp_path=img_p)
if img is not None:
return img
+3 -4
View File
@@ -18,12 +18,13 @@ def create_all_tracks() -> List[models.Track]:
tracks: list[models.Track] = []
_bar = Bar("Creating tracks", max=len(api.PRE_TRACKS))
for track in api.PRE_TRACKS:
try:
os.chmod(track["filepath"], 0o755)
except FileNotFoundError:
instances.songs_instance.remove_song_by_filepath(track["filepath"])
api.PRE_TRACKS.remove(track)
album = albumslib.find_album(track["album"], track["albumartist"])
@@ -34,8 +35,7 @@ def create_all_tracks() -> List[models.Track]:
_bar.finish()
api.TRACKS.clear()
api.TRACKS.extend(tracks)
return tracks
def get_album_tracks(albumname, artist):
@@ -54,4 +54,3 @@ def get_track_by_id(trackid: str) -> models.Track:
for track in api.TRACKS:
if track.trackid == trackid:
return track
+10 -3
View File
@@ -26,8 +26,15 @@ def create_config_dir() -> None:
path = os.path.join(config_folder, _dir)
try:
os.path.exists(path)
except FileNotFoundError:
os.makedirs(path)
except FileExistsError:
pass
os.chmod(path, 0o755)
os.chmod(path, 0o755)
if _dir == dirs[3]:
default_thumbnails_path = "../setup/default-images/thumbnails"
try:
os.path.exists(os.path.join(path, "defaults"))
except FileNotFoundError:
pass
+13
View File
@@ -19,3 +19,16 @@ IMG_THUMB_URI = IMG_BASE_URI + "thumbnails/"
DEFAULT_ARTIST_IMG = IMG_ARTIST_URI + "0.webp"
LAST_FM_API_KEY = "762db7a44a9e6fb5585661f5f2bdf23a"
P_COLORS = [
"rgb(4, 40, 196)",
"rgb(196, 4, 68)",
"rgb(4, 99, 59)",
"rgb(161, 87, 1)",
"rgb(1, 161, 22)",
"rgb(116, 1, 161)",
"rgb(0, 0, 0)",
"rgb(95, 95, 95)",
"rgb(141, 132, 2)",
"rgb(141, 11, 2)",
]
Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB