|
|
|
@ -192,7 +192,7 @@ class PysonicDatabase(object):
|
|
|
|
|
return libs |
|
|
|
|
|
|
|
|
|
@readcursor |
|
|
|
|
def get_artists(self, cursor, id=None, dirid=None, sortby="name", order=None): |
|
|
|
|
def get_artists(self, cursor, id=None, dirid=None, sortby="name", order=None, name_contains=None): |
|
|
|
|
assert order in ["asc", "desc", None] |
|
|
|
|
artists = [] |
|
|
|
|
q = "SELECT * FROM artists" |
|
|
|
@ -204,6 +204,9 @@ class PysonicDatabase(object):
|
|
|
|
|
if dirid: |
|
|
|
|
conditions.append("dir = ?") |
|
|
|
|
params.append(dirid) |
|
|
|
|
if name_contains: |
|
|
|
|
conditions.append("name LIKE ?") |
|
|
|
|
params.append("%{}%".format(name_contains)) |
|
|
|
|
if conditions: |
|
|
|
|
q += " WHERE " + " AND ".join(conditions) |
|
|
|
|
if sortby: |
|
|
|
@ -214,7 +217,7 @@ class PysonicDatabase(object):
|
|
|
|
|
return artists |
|
|
|
|
|
|
|
|
|
@readcursor |
|
|
|
|
def get_albums(self, cursor, id=None, artist=None, sortby="name", order=None, limit=None): |
|
|
|
|
def get_albums(self, cursor, id=None, artist=None, sortby="name", order=None, limit=None, name_contains=None): |
|
|
|
|
""" |
|
|
|
|
:param limit: int or tuple of int, int. translates directly to sql logic. |
|
|
|
|
""" |
|
|
|
@ -246,6 +249,9 @@ class PysonicDatabase(object):
|
|
|
|
|
if artist: |
|
|
|
|
conditions.append("artistid = ?") |
|
|
|
|
params.append(artist) |
|
|
|
|
if name_contains: |
|
|
|
|
conditions.append("alb.name LIKE ?") |
|
|
|
|
params.append("%{}%".format(name_contains)) |
|
|
|
|
if conditions: |
|
|
|
|
q += " WHERE " + " AND ".join(conditions) |
|
|
|
|
|
|
|
|
@ -264,7 +270,7 @@ class PysonicDatabase(object):
|
|
|
|
|
return albums |
|
|
|
|
|
|
|
|
|
@readcursor |
|
|
|
|
def get_songs(self, cursor, id=None, genre=None, sortby="title", order=None, limit=None): |
|
|
|
|
def get_songs(self, cursor, id=None, genre=None, sortby="title", order=None, limit=None, title_contains=None): |
|
|
|
|
# TODO make this query massively uglier by joining albums and artists so that artistid etc can be a filter |
|
|
|
|
# or maybe lookup those IDs in the library layer? |
|
|
|
|
if order: |
|
|
|
@ -306,6 +312,9 @@ class PysonicDatabase(object):
|
|
|
|
|
if genre: |
|
|
|
|
conditions.append("g.name = ?") |
|
|
|
|
params.append(genre) |
|
|
|
|
if title_contains: |
|
|
|
|
conditions.append("s.title LIKE ?") |
|
|
|
|
params.append("%{}%".format(title_contains)) |
|
|
|
|
if conditions: |
|
|
|
|
q += " WHERE " + " AND ".join(conditions) |
|
|
|
|
|
|
|
|
|