Restyle New album page design (#77)

This commit is contained in:
restyled-io[bot]
2022-07-06 17:38:11 +03:00
committed by Mungai Geoffrey
parent 95ad7ceadc
commit 73891aa5cf
8 changed files with 29 additions and 28 deletions
+2 -6
View File
@@ -64,12 +64,8 @@ def get_album():
except AttributeError: except AttributeError:
album.duration = 0 album.duration = 0
if ( if (album.count == 1 and tracks[0].title == album.title
album.count == 1 and tracks[0].tracknumber == 1 and tracks[0].disknumber == 1):
and tracks[0].title == album.title
and tracks[0].tracknumber == 1
and tracks[0].disknumber == 1
):
album.is_single = True album.is_single = True
return {"tracks": tracks, "info": album} return {"tracks": tracks, "info": album}
+5 -3
View File
@@ -8,12 +8,13 @@ from app import exceptions
from app import instances from app import instances
from app import models from app import models
from app import serializer 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 app.lib import playlistlib
from flask import Blueprint from flask import Blueprint
from flask import request from flask import request
from app.helpers import Get, UseBisection, create_new_date
playlist_bp = Blueprint("playlist", __name__, url_prefix="/") playlist_bp = Blueprint("playlist", __name__, url_prefix="/")
PlaylistExists = exceptions.PlaylistExists PlaylistExists = exceptions.PlaylistExists
@@ -27,7 +28,8 @@ def get_all_playlists():
dbplaylists = [models.Playlist(p) for p in dbplaylists] dbplaylists = [models.Playlist(p) for p in dbplaylists]
playlists = [ 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( playlists.sort(
key=lambda p: datetime.strptime(p.lastUpdated, "%Y-%m-%d %H:%M:%S"), key=lambda p: datetime.strptime(p.lastUpdated, "%Y-%m-%d %H:%M:%S"),
+3 -5
View File
@@ -3,11 +3,10 @@ Contains all the track routes.
""" """
from app import api from app import api
from app import instances from app import instances
from app import models
from flask import Blueprint from flask import Blueprint
from flask import send_file from flask import send_file
from app import models
track_bp = Blueprint("track", __name__, url_prefix="/") track_bp = Blueprint("track", __name__, url_prefix="/")
@@ -37,6 +36,5 @@ def get_sample_track():
Returns a sample track object. Returns a sample track object.
""" """
return instances.tracks_instance.get_song_by_album( return instances.tracks_instance.get_song_by_album("Legends Never Die",
"Legends Never Die", "Juice WRLD" "Juice WRLD")
)
+7 -9
View File
@@ -79,6 +79,7 @@ class getArtistImage:
class useImageDownloader: class useImageDownloader:
def __init__(self, url: str, dest: str) -> None: def __init__(self, url: str, dest: str) -> None:
self.url = url self.url = url
self.dest = dest self.dest = dest
@@ -95,6 +96,7 @@ class useImageDownloader:
class CheckArtistImages: class CheckArtistImages:
def __init__(self): def __init__(self):
self.artists: list[str] = [] self.artists: list[str] = []
print("Checking for artist images") print("Checking for artist images")
@@ -119,12 +121,8 @@ class CheckArtistImages:
:param artistname: The artist name :param artistname: The artist name
""" """
img_path = ( img_path = (settings.APP_DIR + "/images/artists/" +
settings.APP_DIR helpers.create_safe_name(artistname) + ".webp")
+ "/images/artists/"
+ helpers.create_safe_name(artistname)
+ ".webp"
)
if cls.check_if_exists(img_path): if cls.check_if_exists(img_path):
return "exists" return "exists"
@@ -151,8 +149,7 @@ def fetch_album_bio(title: str, albumartist: str) -> str | None:
Returns the album bio for a given album. 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( 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: try:
response = requests.get(last_fm_url) response = requests.get(last_fm_url)
@@ -161,7 +158,8 @@ def fetch_album_bio(title: str, albumartist: str) -> str | None:
return None return None
try: 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: except KeyError:
bio = None bio = None
+7 -2
View File
@@ -6,7 +6,9 @@ import random
from dataclasses import dataclass from dataclasses import dataclass
from typing import List 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.lib import taglib
from app.logger import logg from app.logger import logg
from app.settings import THUMBS_PATH from app.settings import THUMBS_PATH
@@ -35,6 +37,7 @@ class RipAlbumImage:
class ValidateAlbumThumbs: class ValidateAlbumThumbs:
@staticmethod @staticmethod
def remove_obsolete(): def remove_obsolete():
""" """
@@ -58,7 +61,9 @@ class ValidateAlbumThumbs:
Re-rip lost album thumbnails Re-rip lost album thumbnails
""" """
entries = os.scandir(THUMBS_PATH) 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() albums = helpers.Get.get_all_albums()
thumbs = [(album.hash + ".webp") for album in albums] thumbs = [(album.hash + ".webp") for album in albums]
+1 -1
View File
@@ -4,10 +4,10 @@ This library contains the classes and functions related to the watchdog file wat
import os import os
import time import time
from app.logger import get_logger
from app import instances from app import instances
from app.helpers import create_album_hash from app.helpers import create_album_hash
from app.lib.taglib import get_tags from app.lib.taglib import get_tags
from app.logger import get_logger
from watchdog.events import PatternMatchingEventHandler from watchdog.events import PatternMatchingEventHandler
from watchdog.observers import Observer from watchdog.observers import Observer
+3 -1
View File
@@ -61,7 +61,9 @@ class Playlist:
count: int = 0 count: int = 0
duration: 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.playlistid = p.playlistid
self.name = p.name self.name = p.name
self.image = p.image self.image = p.image