major refactors

- add album page store
- show loaders in beforeEnter guards
- show bitrate on now playing card
- etc
This commit is contained in:
geoffrey45
2022-04-03 01:03:32 +03:00
parent 0c1e792839
commit dbb27734fe
26 changed files with 300 additions and 245 deletions
+12 -5
View File
@@ -7,6 +7,7 @@ from app import api
from app import helpers, cache
from app import functions
from app.lib import albumslib, trackslib
album_bp = Blueprint("album", __name__, url_prefix="")
@@ -44,12 +45,18 @@ def get_album_tracks():
return {"songs": songs, "info": album}
@album_bp.route("/album/<title>/<artist>/bio")
@cache.cached()
def get_album_bio(title, artist):
@album_bp.route("/album/bio", methods=["POST"])
def get_album_bio():
"""Returns the album bio for the given album."""
bio = functions.get_album_bio(title, artist)
return {"bio": bio}, 200
data = request.get_json()
print(data)
bio = functions.get_album_bio(data["album"], data["albumartist"])
if bio is not None:
return {"bio": bio}
else:
return {"bio": "No bio found."}, 404
@album_bp.route("/album/artists", methods=["POST"])
+3 -1
View File
@@ -21,6 +21,7 @@ def get_all_playlists():
playlists = []
for pl in ppp:
pl.count = len(pl.tracks)
pl.tracks = []
playlists.append(pl)
@@ -33,7 +34,7 @@ def create_playlist():
playlist = {
"name": data["name"],
"description": [],
"description": "",
"tracks": [],
"count": 0,
"lastUpdated": 0,
@@ -74,6 +75,7 @@ def add_track_to_playlist(playlist_id: str):
def get_single_p_info(playlist_id: str):
for p in api.PLAYLISTS:
if p.playlistid == playlist_id:
p.count = len(p.tracks)
return {"data": p}
+6 -2
View File
@@ -4,7 +4,7 @@ Contains all the track routes.
from flask import Blueprint, send_file
from app import instances
from app import instances, api
track_bp = Blueprint("track", __name__, url_prefix="/")
@@ -15,7 +15,11 @@ def send_track_file(trackid):
Returns an audio file that matches the passed id to the client.
"""
try:
filepath = instances.songs_instance.get_song_by_id(trackid)["filepath"]
filepath = [
file["filepath"]
for file in api.PRE_TRACKS
if file["_id"]["$oid"] == trackid
][0]
return send_file(filepath, mimetype="audio/mp3")
except FileNotFoundError:
return "File not found", 404