Restyle Integrate topbar and refactor playlists page (#31)

This commit is contained in:
restyled-io[bot]
2022-04-14 11:39:26 +03:00
committed by GitHub
parent 85c59b4cba
commit a6e46dcde2
8 changed files with 66 additions and 35 deletions
+28 -10
View File
@@ -1,7 +1,6 @@
"""
This file contains the AllSongs class for interacting with track documents in MongoDB.
"""
from app import db
from bson import ObjectId
@@ -25,9 +24,12 @@ class AllSongs(db.Mongo):
"""
Inserts a new track object into the database.
"""
return self.collection.update_one(
{"filepath": song_obj["filepath"]}, {"$set": song_obj}, upsert=True
).upserted_id
return self.collection.update_one({
"filepath": song_obj["filepath"]
}, {
"$set": song_obj
},
upsert=True).upserted_id
def get_all_songs(self) -> list:
"""
@@ -53,21 +55,33 @@ class AllSongs(db.Mongo):
"""
Returns all the songs matching the albums in the query params (using regex).
"""
songs = self.collection.find({"album": {"$regex": query, "$options": "i"}})
songs = self.collection.find(
{"album": {
"$regex": query,
"$options": "i"
}})
return convert_many(songs)
def search_songs_by_artist(self, query: str) -> list:
"""
Returns all the songs matching the artists in the query params.
"""
songs = self.collection.find({"artists": {"$regex": query, "$options": "i"}})
songs = self.collection.find(
{"artists": {
"$regex": query,
"$options": "i"
}})
return convert_many(songs)
def find_song_by_title(self, query: str) -> list:
"""
Finds all the tracks matching the title in the query params.
"""
song = self.collection.find({"title": {"$regex": query, "$options": "i"}})
song = self.collection.find(
{"title": {
"$regex": query,
"$options": "i"
}})
return convert_many(song)
def find_songs_by_album(self, name: str, artist: str) -> list:
@@ -81,7 +95,9 @@ class AllSongs(db.Mongo):
"""
Returns a sorted list of all the tracks exactly matching the folder in the query params
"""
songs = self.collection.find({"folder": query}).sort("title", db.pymongo.ASCENDING)
songs = self.collection.find({
"folder": query
}).sort("title", db.pymongo.ASCENDING)
return convert_many(songs)
def find_songs_by_folder_og(self, query: str) -> list:
@@ -103,8 +119,10 @@ class AllSongs(db.Mongo):
Returns a list of all the tracks containing the albumartist in the query params.
"""
songs = self.collection.find(
{"albumartist": {"$regex": query, "$options": "i"}}
)
{"albumartist": {
"$regex": query,
"$options": "i"
}})
return convert_many(songs)
def get_song_by_path(self, path: str) -> dict: