diff --git a/server/app/api/playlist.py b/server/app/api/playlist.py index 3dd9cd16..0846262c 100644 --- a/server/app/api/playlist.py +++ b/server/app/api/playlist.py @@ -30,7 +30,14 @@ def get_all_playlists(): @playlist_bp.route("/playlist/new", methods=["POST"]) def create_playlist(): data = request.get_json() - playlist = {"name": data["name"], "description": [], "tracks": []} + + playlist = { + "name": data["name"], + "description": [], + "tracks": [], + "count": 0, + "lastUpdated": 0, + } try: p_in_db = instances.playlist_instance.get_playlist_by_name(playlist["name"]) diff --git a/server/app/db/tracks.py b/server/app/db/tracks.py index 0f9f5093..8b70b561 100644 --- a/server/app/db/tracks.py +++ b/server/app/db/tracks.py @@ -21,7 +21,7 @@ class AllSongs(db.Mongo): # def drop_db(self): # self.collection.drop() - def insert_song(self, song_obj: dict) -> None: + def insert_song(self, song_obj: dict) -> str: """ Inserts a new track object into the database. """ diff --git a/server/app/functions.py b/server/app/functions.py index ddecae4a..2759da51 100644 --- a/server/app/functions.py +++ b/server/app/functions.py @@ -69,11 +69,12 @@ def populate(): for file in files: tags = get_tags(file) - if tags not in api.PRE_TRACKS: - api.PRE_TRACKS.append(tags) - if tags is not None: - instances.songs_instance.insert_song(tags) + upsert_id = instances.songs_instance.insert_song(tags) + + if upsert_id is not None: + tags["_id"] = {"$oid": upsert_id} + api.PRE_TRACKS.append(tags) _bar.next() _bar.finish() diff --git a/server/app/lib/albumslib.py b/server/app/lib/albumslib.py index cd01e545..38875c70 100644 --- a/server/app/lib/albumslib.py +++ b/server/app/lib/albumslib.py @@ -2,6 +2,7 @@ This library contains all the functions related to albums. """ +from pprint import pprint import urllib from typing import List from app import models, functions, helpers @@ -52,9 +53,12 @@ def get_album_tracks(album: str, artist: str) -> List: tracks = [] for track in api.PRE_TRACKS: - if track["album"] == album and track["albumartist"] == artist: - tracks.append(track) - + try: + if track["album"] == album and track["albumartist"] == artist: + tracks.append(track) + except TypeError: + pprint(track, indent=4) + print(album, artist) return tracks diff --git a/server/app/models.py b/server/app/models.py index 3c77bc8b..22e639de 100644 --- a/server/app/models.py +++ b/server/app/models.py @@ -3,6 +3,7 @@ Contains all the models for objects generation and typing. """ from dataclasses import dataclass +from datetime import date from typing import List from app import api from app import settings @@ -95,6 +96,8 @@ class Playlist: description: str image: str tracks: List[Track] + count: int + lastUpdated: int """A list of track objects in the playlist""" def __init__(self, data): @@ -103,6 +106,9 @@ class Playlist: self.description = data["description"] self.image = "" self.tracks = create_playlist_tracks(data["tracks"]) + self.count = len(data["tracks"]) + self.lastUpdated = data["lastUpdated"] + @dataclass diff --git a/src/App.vue b/src/App.vue index 9be2d5f8..1720a31b 100644 --- a/src/App.vue +++ b/src/App.vue @@ -39,11 +39,15 @@ import useContextStore from "./stores/context"; import ContextMenu from "./components/contextMenu.vue"; import Modal from "./components/modal.vue"; import Notification from "./components/Notification.vue"; +import useQStore from "./stores/queue"; const context_store = useContextStore(); +const queue = useQStore(); + +queue.readQueueFromLocalStorage(); const RightSideBar = Main; -perks.readQueue(); + const collapsed = ref(false); const app_dom = document.getElementById("app"); diff --git a/src/components/LeftSidebar/NP/HotKeys.vue b/src/components/LeftSidebar/NP/HotKeys.vue index 5f3fdf77..7527e176 100644 --- a/src/components/LeftSidebar/NP/HotKeys.vue +++ b/src/components/LeftSidebar/NP/HotKeys.vue @@ -1,23 +1,22 @@ -