mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 12:33:03 +00:00
Restyle Remove global lists and read everything from the database. (#71)
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
import time
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from dataclasses import dataclass
|
||||
from os import scandir
|
||||
import time
|
||||
from typing import Tuple
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
from app.models import Folder
|
||||
from app.models import Track
|
||||
|
||||
from app import instances
|
||||
from app.models import Folder
|
||||
from app.models import Track
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -27,10 +26,14 @@ def get_folder_track_count(path: str) -> int:
|
||||
def create_folder(dir: Dir) -> Folder:
|
||||
"""Create a single Folder object"""
|
||||
folder = {
|
||||
"name": dir.path.split("/")[-1],
|
||||
"path": dir.path,
|
||||
"is_sym": dir.is_sym,
|
||||
"trackcount": instances.tracks_instance.find_tracks_inside_path_regex(dir.path),
|
||||
"name":
|
||||
dir.path.split("/")[-1],
|
||||
"path":
|
||||
dir.path,
|
||||
"is_sym":
|
||||
dir.is_sym,
|
||||
"trackcount":
|
||||
instances.tracks_instance.find_tracks_inside_path_regex(dir.path),
|
||||
}
|
||||
|
||||
return Folder(folder)
|
||||
|
||||
@@ -11,14 +11,13 @@ from app import exceptions
|
||||
from app import instances
|
||||
from app import models
|
||||
from app import settings
|
||||
from app.helpers import Get
|
||||
from app.lib import trackslib
|
||||
from app.logger import get_logger
|
||||
from PIL import Image
|
||||
from PIL import ImageSequence
|
||||
from werkzeug import datastructures
|
||||
|
||||
from app.lib import trackslib
|
||||
from app.helpers import Get
|
||||
from app.logger import get_logger
|
||||
|
||||
TrackExistsInPlaylist = exceptions.TrackExistsInPlaylist
|
||||
|
||||
logg = get_logger()
|
||||
@@ -53,7 +52,8 @@ def create_thumbnail(image: any, img_path: str) -> str:
|
||||
Creates a 250 x 250 thumbnail from a playlist image
|
||||
"""
|
||||
thumb_path = "thumb_" + img_path
|
||||
full_thumb_path = os.path.join(settings.APP_DIR, "images", "playlists", thumb_path)
|
||||
full_thumb_path = os.path.join(settings.APP_DIR, "images", "playlists",
|
||||
thumb_path)
|
||||
|
||||
aspect_ratio = image.width / image.height
|
||||
|
||||
@@ -71,11 +71,13 @@ def save_p_image(file: datastructures.FileStorage, pid: str):
|
||||
"""
|
||||
img = Image.open(file)
|
||||
|
||||
random_str = "".join(random.choices(string.ascii_letters + string.digits, k=5))
|
||||
random_str = "".join(
|
||||
random.choices(string.ascii_letters + string.digits, k=5))
|
||||
|
||||
img_path = pid + str(random_str) + ".webp"
|
||||
|
||||
full_img_path = os.path.join(settings.APP_DIR, "images", "playlists", img_path)
|
||||
full_img_path = os.path.join(settings.APP_DIR, "images", "playlists",
|
||||
img_path)
|
||||
|
||||
if file.content_type == "image/gif":
|
||||
frames = []
|
||||
|
||||
@@ -22,5 +22,4 @@ def validate_tracks() -> None:
|
||||
|
||||
def get_p_track(ptrack):
|
||||
return instances.tracks_instance.find_track_by_title_artists_album(
|
||||
ptrack["title"], ptrack["artists"], ptrack["album"]
|
||||
)
|
||||
ptrack["title"], ptrack["artists"], ptrack["album"])
|
||||
|
||||
Reference in New Issue
Block a user