mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 04:23:01 +00:00
replace background image with svg
- add symlink svg - fix validate playlist thumbnails
This commit is contained in:
@@ -11,9 +11,10 @@ from PIL import Image
|
||||
|
||||
from app import helpers, settings
|
||||
from app.lib import watchdoge
|
||||
from app.lib.albumslib import ValidateThumbs
|
||||
from app.lib.albumslib import ValidateAlbumThumbs
|
||||
from app.lib import trackslib
|
||||
from app.lib.populate import CreateAlbums, Populate
|
||||
from app.lib.playlistlib import ValidatePlaylistThumbs
|
||||
|
||||
|
||||
@helpers.background
|
||||
@@ -31,7 +32,8 @@ def run_checks():
|
||||
if helpers.Ping()():
|
||||
CheckArtistImages()()
|
||||
|
||||
ValidateThumbs()
|
||||
ValidateAlbumThumbs()
|
||||
ValidatePlaylistThumbs()
|
||||
|
||||
|
||||
@helpers.background
|
||||
|
||||
@@ -1,36 +1,16 @@
|
||||
"""
|
||||
This library contains all the functions related to albums.
|
||||
"""
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from multiprocessing import Manager
|
||||
from dataclasses import dataclass
|
||||
import os
|
||||
import random
|
||||
from dataclasses import dataclass
|
||||
from typing import List
|
||||
|
||||
from app import helpers, models
|
||||
from app import helpers, instances, models
|
||||
from app.lib import taglib
|
||||
from tqdm import tqdm
|
||||
|
||||
from app.settings import THUMBS_PATH
|
||||
from app import instances
|
||||
from app.logger import logg
|
||||
|
||||
# def get_all_albums() -> List[models.Album]:
|
||||
# """
|
||||
# Returns a list of album objects for all albums in the database.
|
||||
# """
|
||||
# print("Getting all albums...")
|
||||
|
||||
# albums: List[models.Album] = []
|
||||
|
||||
# db_albums = instances.album_instance.get_all_albums()
|
||||
|
||||
# for album in tqdm(db_albums, desc="Creating albums"):
|
||||
# aa = models.Album(album)
|
||||
# albums.append(aa)
|
||||
|
||||
# return albums
|
||||
from app.settings import THUMBS_PATH
|
||||
from tqdm import tqdm
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -54,7 +34,7 @@ class RipAlbumImage:
|
||||
break
|
||||
|
||||
|
||||
class ValidateThumbs:
|
||||
class ValidateAlbumThumbs:
|
||||
@staticmethod
|
||||
def remove_obsolete():
|
||||
"""
|
||||
@@ -90,7 +70,7 @@ class ValidateThumbs:
|
||||
hash = t_hash.replace(".webp", "")
|
||||
RipAlbumImage(hash)
|
||||
|
||||
logg.info("Ripping lost album thumbnails...")
|
||||
logg.info("Ripping lost album thumbnails")
|
||||
# with ThreadPoolExecutor() as pool:
|
||||
# i = pool.map(rip_image, thumbs)
|
||||
# [a for a in i]
|
||||
@@ -98,7 +78,7 @@ class ValidateThumbs:
|
||||
for thumb in thumbs:
|
||||
rip_image(thumb)
|
||||
|
||||
logg.info("Ripping lost album thumbnails...done")
|
||||
logg.info("Ripping lost album thumbnails ... ✅")
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.remove_obsolete()
|
||||
|
||||
@@ -7,9 +7,6 @@ import string
|
||||
from datetime import datetime
|
||||
from typing import List
|
||||
|
||||
from tqdm import tqdm
|
||||
|
||||
from app import api
|
||||
from app import exceptions
|
||||
from app import instances
|
||||
from app import models
|
||||
@@ -19,9 +16,13 @@ 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()
|
||||
|
||||
|
||||
def add_track(playlistid: str, trackid: str):
|
||||
"""
|
||||
@@ -93,27 +94,31 @@ def save_p_image(file: datastructures.FileStorage, pid: str):
|
||||
return img_path, thumb_path
|
||||
|
||||
|
||||
def validate_images():
|
||||
class ValidatePlaylistThumbs:
|
||||
"""
|
||||
Removes all unused images in the images/playlists folder.
|
||||
"""
|
||||
images = []
|
||||
p = instances.playlist_instance.get_all_playlists()
|
||||
playlists = [models.Playlist(p) for p in p]
|
||||
|
||||
for playlist in playlists:
|
||||
if playlist.image:
|
||||
img_path = playlist.image.split("/")[-1]
|
||||
thumb_path = playlist.thumb.split("/")[-1]
|
||||
def __init__(self) -> None:
|
||||
images = []
|
||||
playlists = Get.get_all_playlists()
|
||||
|
||||
images.append(img_path)
|
||||
images.append(thumb_path)
|
||||
logg.info("Validating playlist thumbnails")
|
||||
for playlist in playlists:
|
||||
if playlist.image:
|
||||
img_path = playlist.image.split("/")[-1]
|
||||
thumb_path = playlist.thumb.split("/")[-1]
|
||||
|
||||
p_path = os.path.join(settings.APP_DIR, "images", "playlists")
|
||||
images.append(img_path)
|
||||
images.append(thumb_path)
|
||||
|
||||
for image in os.listdir(p_path):
|
||||
if image not in images:
|
||||
os.remove(os.path.join(p_path, image))
|
||||
p_path = os.path.join(settings.APP_DIR, "images", "playlists")
|
||||
|
||||
for image in os.listdir(p_path):
|
||||
if image not in images:
|
||||
os.remove(os.path.join(p_path, image))
|
||||
|
||||
logg.info("Validating playlist thumbnails ... ✅")
|
||||
|
||||
|
||||
def create_new_date():
|
||||
|
||||
@@ -13,7 +13,7 @@ class CustomFormatter(logging.Formatter):
|
||||
# format = (
|
||||
# "%(asctime)s - %(name)s - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)"
|
||||
# )
|
||||
format = "[%(asctime)s] [%(levelname)s] [@%(name)s] >>> %(message)s [%(filename)s:%(lineno)d]"
|
||||
format = "[%(asctime)s] [%(levelname)s] [@%(name)s]ℹ️ %(message)s"
|
||||
|
||||
FORMATS = {
|
||||
logging.DEBUG: grey + format + reset,
|
||||
@@ -42,10 +42,7 @@ logg.addHandler(ch)
|
||||
|
||||
|
||||
def get_logger():
|
||||
if logger.enable:
|
||||
return logg
|
||||
|
||||
return None
|
||||
return logg
|
||||
|
||||
|
||||
logg = get_logger()
|
||||
|
||||
Reference in New Issue
Block a user