mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 13:03:02 +00:00
add featured artists to playlist page
+ fetch album bio on raising bottom container
This commit is contained in:
@@ -18,7 +18,8 @@ from PIL import Image
|
||||
from PIL import ImageSequence
|
||||
from werkzeug import datastructures
|
||||
|
||||
TrackExistsInPlaylist = exceptions.TrackExistsInPlaylist
|
||||
|
||||
TrackExistsInPlaylist = exceptions.TrackExistsInPlaylistError
|
||||
|
||||
logg = get_logger()
|
||||
|
||||
@@ -52,8 +53,7 @@ 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,13 +71,11 @@ 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 = []
|
||||
@@ -140,3 +138,23 @@ def create_playlist_tracks(playlist_tracks: List) -> List[models.Track]:
|
||||
tracks.append(models.Track(track))
|
||||
|
||||
return tracks
|
||||
|
||||
|
||||
class GetPlaylistArtists:
|
||||
"""
|
||||
Returns a list of artists from a list of playlist tracks.
|
||||
"""
|
||||
|
||||
def __init__(self, pid: str) -> None:
|
||||
self.pid = pid
|
||||
p = instances.playlist_instance.get_playlist_by_id(self.pid)
|
||||
self.tracks = create_playlist_tracks(p["pre_tracks"])
|
||||
|
||||
def __call__(self):
|
||||
artists = set()
|
||||
|
||||
for t in self.tracks:
|
||||
for a in t.artists:
|
||||
artists.add(a)
|
||||
|
||||
return [models.Artist(a) for a in artists]
|
||||
|
||||
@@ -5,7 +5,7 @@ from typing import List
|
||||
|
||||
from app import instances
|
||||
from app import settings
|
||||
from app.helpers import create_album_hash
|
||||
from app.helpers import create_hash
|
||||
from app.helpers import Get
|
||||
from app.helpers import run_fast_scandir
|
||||
from app.helpers import UseBisection
|
||||
@@ -51,7 +51,7 @@ class Populate:
|
||||
tags = get_tags(file)
|
||||
|
||||
if tags is not None:
|
||||
hash = create_album_hash(tags["album"], tags["albumartist"])
|
||||
hash = create_hash(tags["album"], tags["albumartist"])
|
||||
tags["albumhash"] = hash
|
||||
self.tagged_tracks.append(tags)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import os
|
||||
import time
|
||||
|
||||
from app import instances
|
||||
from app.helpers import create_album_hash
|
||||
from app.helpers import create_hash
|
||||
from app.lib.taglib import get_tags
|
||||
from app.logger import get_logger
|
||||
from watchdog.events import PatternMatchingEventHandler
|
||||
@@ -53,7 +53,7 @@ def add_track(filepath: str) -> None:
|
||||
tags = get_tags(filepath)
|
||||
|
||||
if tags is not None:
|
||||
hash = create_album_hash(tags["album"], tags["albumartist"])
|
||||
hash = create_hash(tags["album"], tags["albumartist"])
|
||||
tags["albumhash"] = hash
|
||||
instances.tracks_instance.insert_song(tags)
|
||||
|
||||
@@ -82,21 +82,19 @@ class Handler(PatternMatchingEventHandler):
|
||||
"""
|
||||
Fired when a supported file is created.
|
||||
"""
|
||||
print("🔵 created +++")
|
||||
self.files_to_process.append(event.src_path)
|
||||
|
||||
def on_deleted(self, event):
|
||||
"""
|
||||
Fired when a delete event occurs on a supported file.
|
||||
"""
|
||||
print("🔴 deleted ---")
|
||||
|
||||
remove_track(event.src_path)
|
||||
|
||||
def on_moved(self, event):
|
||||
"""
|
||||
Fired when a move event occurs on a supported file.
|
||||
"""
|
||||
print("🔘 moved -->")
|
||||
tr = "share/Trash"
|
||||
|
||||
if tr in event.dest_path:
|
||||
@@ -114,7 +112,6 @@ class Handler(PatternMatchingEventHandler):
|
||||
"""
|
||||
Fired when a created file is closed.
|
||||
"""
|
||||
print("⚫ closed ~~~")
|
||||
try:
|
||||
self.files_to_process.remove(event.src_path)
|
||||
add_track(event.src_path)
|
||||
|
||||
Reference in New Issue
Block a user