mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 04:23:01 +00:00
Restyle New album page design (#77)
This commit is contained in:
committed by
Mungai Geoffrey
parent
95ad7ceadc
commit
73891aa5cf
@@ -64,12 +64,8 @@ def get_album():
|
||||
except AttributeError:
|
||||
album.duration = 0
|
||||
|
||||
if (
|
||||
album.count == 1
|
||||
and tracks[0].title == album.title
|
||||
and tracks[0].tracknumber == 1
|
||||
and tracks[0].disknumber == 1
|
||||
):
|
||||
if (album.count == 1 and tracks[0].title == album.title
|
||||
and tracks[0].tracknumber == 1 and tracks[0].disknumber == 1):
|
||||
album.is_single = True
|
||||
|
||||
return {"tracks": tracks, "info": album}
|
||||
|
||||
@@ -8,12 +8,13 @@ from app import exceptions
|
||||
from app import instances
|
||||
from app import models
|
||||
from app import serializer
|
||||
from app.helpers import create_new_date
|
||||
from app.helpers import Get
|
||||
from app.helpers import UseBisection
|
||||
from app.lib import playlistlib
|
||||
from flask import Blueprint
|
||||
from flask import request
|
||||
|
||||
from app.helpers import Get, UseBisection, create_new_date
|
||||
|
||||
playlist_bp = Blueprint("playlist", __name__, url_prefix="/")
|
||||
|
||||
PlaylistExists = exceptions.PlaylistExists
|
||||
@@ -27,7 +28,8 @@ def get_all_playlists():
|
||||
dbplaylists = [models.Playlist(p) for p in dbplaylists]
|
||||
|
||||
playlists = [
|
||||
serializer.Playlist(p, construct_last_updated=False) for p in dbplaylists
|
||||
serializer.Playlist(p, construct_last_updated=False)
|
||||
for p in dbplaylists
|
||||
]
|
||||
playlists.sort(
|
||||
key=lambda p: datetime.strptime(p.lastUpdated, "%Y-%m-%d %H:%M:%S"),
|
||||
|
||||
@@ -3,11 +3,10 @@ Contains all the track routes.
|
||||
"""
|
||||
from app import api
|
||||
from app import instances
|
||||
from app import models
|
||||
from flask import Blueprint
|
||||
from flask import send_file
|
||||
|
||||
from app import models
|
||||
|
||||
track_bp = Blueprint("track", __name__, url_prefix="/")
|
||||
|
||||
|
||||
@@ -37,6 +36,5 @@ def get_sample_track():
|
||||
Returns a sample track object.
|
||||
"""
|
||||
|
||||
return instances.tracks_instance.get_song_by_album(
|
||||
"Legends Never Die", "Juice WRLD"
|
||||
)
|
||||
return instances.tracks_instance.get_song_by_album("Legends Never Die",
|
||||
"Juice WRLD")
|
||||
|
||||
@@ -79,6 +79,7 @@ class getArtistImage:
|
||||
|
||||
|
||||
class useImageDownloader:
|
||||
|
||||
def __init__(self, url: str, dest: str) -> None:
|
||||
self.url = url
|
||||
self.dest = dest
|
||||
@@ -95,6 +96,7 @@ class useImageDownloader:
|
||||
|
||||
|
||||
class CheckArtistImages:
|
||||
|
||||
def __init__(self):
|
||||
self.artists: list[str] = []
|
||||
print("Checking for artist images")
|
||||
@@ -119,12 +121,8 @@ class CheckArtistImages:
|
||||
:param artistname: The artist name
|
||||
"""
|
||||
|
||||
img_path = (
|
||||
settings.APP_DIR
|
||||
+ "/images/artists/"
|
||||
+ helpers.create_safe_name(artistname)
|
||||
+ ".webp"
|
||||
)
|
||||
img_path = (settings.APP_DIR + "/images/artists/" +
|
||||
helpers.create_safe_name(artistname) + ".webp")
|
||||
|
||||
if cls.check_if_exists(img_path):
|
||||
return "exists"
|
||||
@@ -151,8 +149,7 @@ def fetch_album_bio(title: str, albumartist: str) -> str | None:
|
||||
Returns the album bio for a given album.
|
||||
"""
|
||||
last_fm_url = "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key={}&artist={}&album={}&format=json".format(
|
||||
settings.LAST_FM_API_KEY, albumartist, title
|
||||
)
|
||||
settings.LAST_FM_API_KEY, albumartist, title)
|
||||
|
||||
try:
|
||||
response = requests.get(last_fm_url)
|
||||
@@ -161,7 +158,8 @@ def fetch_album_bio(title: str, albumartist: str) -> str | None:
|
||||
return None
|
||||
|
||||
try:
|
||||
bio = data["album"]["wiki"]["summary"].split('<a href="https://www.last.fm/')[0]
|
||||
bio = data["album"]["wiki"]["summary"].split(
|
||||
'<a href="https://www.last.fm/')[0]
|
||||
except KeyError:
|
||||
bio = None
|
||||
|
||||
|
||||
@@ -6,7 +6,9 @@ import random
|
||||
from dataclasses import dataclass
|
||||
from typing import List
|
||||
|
||||
from app import helpers, instances, models
|
||||
from app import helpers
|
||||
from app import instances
|
||||
from app import models
|
||||
from app.lib import taglib
|
||||
from app.logger import logg
|
||||
from app.settings import THUMBS_PATH
|
||||
@@ -35,6 +37,7 @@ class RipAlbumImage:
|
||||
|
||||
|
||||
class ValidateAlbumThumbs:
|
||||
|
||||
@staticmethod
|
||||
def remove_obsolete():
|
||||
"""
|
||||
@@ -58,7 +61,9 @@ class ValidateAlbumThumbs:
|
||||
Re-rip lost album thumbnails
|
||||
"""
|
||||
entries = os.scandir(THUMBS_PATH)
|
||||
entries = [Thumbnail(entry.name) for entry in entries if entry.is_file()]
|
||||
entries = [
|
||||
Thumbnail(entry.name) for entry in entries if entry.is_file()
|
||||
]
|
||||
|
||||
albums = helpers.Get.get_all_albums()
|
||||
thumbs = [(album.hash + ".webp") for album in albums]
|
||||
|
||||
@@ -4,10 +4,10 @@ This library contains the classes and functions related to the watchdog file wat
|
||||
import os
|
||||
import time
|
||||
|
||||
from app.logger import get_logger
|
||||
from app import instances
|
||||
from app.helpers import create_album_hash
|
||||
from app.lib.taglib import get_tags
|
||||
from app.logger import get_logger
|
||||
from watchdog.events import PatternMatchingEventHandler
|
||||
from watchdog.observers import Observer
|
||||
|
||||
|
||||
@@ -61,7 +61,9 @@ class Playlist:
|
||||
count: int = 0
|
||||
duration: int = 0
|
||||
|
||||
def __init__(self, p: models.Playlist, construct_last_updated: bool = True) -> None:
|
||||
def __init__(self,
|
||||
p: models.Playlist,
|
||||
construct_last_updated: bool = True) -> None:
|
||||
self.playlistid = p.playlistid
|
||||
self.name = p.name
|
||||
self.image = p.image
|
||||
|
||||
@@ -83,4 +83,4 @@ export {
|
||||
};
|
||||
|
||||
// TODO:
|
||||
// Rewrite this module using `useAxios` hook
|
||||
// Rewrite this module using `useAxios` hook
|
||||
|
||||
Reference in New Issue
Block a user