mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
Restyle Integrate topbar and refactor playlists page (#31)
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
"""
|
||||
This file contains the Album class for interacting with
|
||||
This file contains the Album class for interacting with
|
||||
album documents in MongoDB.
|
||||
"""
|
||||
|
||||
from app import db
|
||||
from bson import ObjectId
|
||||
|
||||
@@ -24,8 +23,13 @@ class Albums(db.Mongo):
|
||||
Inserts a new album object into the database.
|
||||
"""
|
||||
return self.collection.update_one(
|
||||
{"album": album["album"], "artist": album["artist"]},
|
||||
{"$set": album},
|
||||
{
|
||||
"album": album["album"],
|
||||
"artist": album["artist"]
|
||||
},
|
||||
{
|
||||
"$set": album
|
||||
},
|
||||
upsert=True,
|
||||
).upserted_id
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"""
|
||||
This file contains the Artists class for interacting with artist documents in MongoDB.
|
||||
"""
|
||||
|
||||
from app import db
|
||||
from bson import ObjectId
|
||||
|
||||
@@ -19,9 +18,10 @@ class Artists(db.Mongo):
|
||||
"""
|
||||
Inserts an artist into the database.
|
||||
"""
|
||||
self.collection.update_one(
|
||||
artist_obj, {"$set": artist_obj}, upsert=True
|
||||
).upserted_id
|
||||
self.collection.update_one(artist_obj, {
|
||||
"$set": artist_obj
|
||||
},
|
||||
upsert=True).upserted_id
|
||||
|
||||
def get_all_artists(self) -> list:
|
||||
"""
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"""
|
||||
This file contains the TrackColors class for interacting with Track colors documents in MongoDB.
|
||||
"""
|
||||
|
||||
from app import db
|
||||
|
||||
|
||||
@@ -19,8 +18,12 @@ class TrackColors(db.Mongo):
|
||||
Inserts a new track object into the database.
|
||||
"""
|
||||
return self.collection.update_one(
|
||||
{"filepath": track_color["filepath"]},
|
||||
{"$set": track_color},
|
||||
{
|
||||
"filepath": track_color["filepath"]
|
||||
},
|
||||
{
|
||||
"$set": track_color
|
||||
},
|
||||
upsert=True,
|
||||
).upserted_id
|
||||
|
||||
|
||||
+28
-10
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user