fix album search

- convert strings to lowercase before search
This commit is contained in:
geoffrey45
2022-03-08 09:25:07 +03:00
parent 25f79d8a20
commit c3059d502c
7 changed files with 30 additions and 14 deletions
+10 -5
View File
@@ -51,14 +51,19 @@ def find_album(albumtitle, artist):
return album
def search_albums_by_name(query):
def search_albums_by_name(query: str) -> List[models.Album]:
"""
Searches albums by album name.
"""
albums: List[models.Album] = []
title_albums: List[models.Album] = []
artist_albums: List[models.Album] = []
for album in ALBUMS:
if query in album.album:
albums.append(album)
if query.lower() in album.album.lower():
title_albums.append(album)
return albums
for album in ALBUMS:
if query.lower() in album.artist.lower():
artist_albums.append(album)
return [*title_albums, *artist_albums]