add method and route to search across tracks, albums and artists.

+ break models into separate files
+ same for the utils and setup
This commit is contained in:
geoffrey45
2023-03-09 13:08:50 +03:00
parent d39c0ea2f8
commit e3ec9db989
55 changed files with 1113 additions and 1137 deletions
+1 -3
View File
@@ -1,11 +1,9 @@
from sqlite3 import Cursor
from app.db import AlbumMethods
from .utils import SQLiteManager, tuple_to_album, tuples_to_albums
class SQLiteAlbumMethods(AlbumMethods):
class SQLiteAlbumMethods:
@classmethod
def insert_one_album(cls, cur: Cursor, albumhash: str, colors: str):
"""
+2 -1
View File
@@ -4,7 +4,8 @@ from collections import OrderedDict
from app.db.sqlite.tracks import SQLiteTrackMethods
from app.db.sqlite.utils import SQLiteManager, tuple_to_playlist, tuples_to_playlists
from app.models import Artist
from app.utils import background, create_new_date
from app.utils.generators import create_new_date
from app.utils.threading import background
class SQLitePlaylistMethods:
+4 -4
View File
@@ -1,5 +1,5 @@
from app.db.sqlite.utils import SQLiteManager
from app.utils import win_replace_slash
from app.utils.wintools import win_replace_slash
class SettingsSQLMethods:
@@ -19,7 +19,7 @@ class SettingsSQLMethods:
cur.execute(sql)
dirs = cur.fetchall()
dirs = [dir[0] for dir in dirs]
dirs = [_dir[0] for _dir in dirs]
return [win_replace_slash(d) for d in dirs]
@staticmethod
@@ -31,7 +31,7 @@ class SettingsSQLMethods:
sql = "INSERT INTO settings (root_dirs) VALUES (?)"
existing_dirs = SettingsSQLMethods.get_root_dirs()
dirs = [dir for dir in dirs if dir not in existing_dirs]
dirs = [_dir for _dir in dirs if _dir not in existing_dirs]
if len(dirs) == 0:
return
@@ -85,4 +85,4 @@ class SettingsSQLMethods:
with SQLiteManager(userdata_db=True) as cur:
cur.execute(sql)
dirs = cur.fetchall()
return [dir[0] for dir in dirs]
return [_dir[0] for _dir in dirs]
+2 -2
View File
@@ -3,7 +3,6 @@ Contains the SQLiteTrackMethods class which contains methods for
interacting with the tracks table.
"""
from collections import OrderedDict
from sqlite3 import Cursor
@@ -38,7 +37,8 @@ class SQLiteTrackMethods:
title,
track,
trackhash
) VALUES(:album, :albumartist, :albumhash, :artist, :bitrate, :copyright, :date, :disc, :duration, :filepath, :folder, :genre, :title, :track, :trackhash)
) VALUES(:album, :albumartist, :albumhash, :artist, :bitrate, :copyright,
:date, :disc, :duration, :filepath, :folder, :genre, :title, :track, :trackhash)
"""
track = OrderedDict(sorted(track.items()))