mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
rewrite search functions as classes
This commit is contained in:
@@ -52,6 +52,10 @@ def create_everything() -> List[models.Track]:
|
||||
def find_album(albums: List[models.Album], hash: str) -> int | None:
|
||||
"""
|
||||
Finds an album by album title and artist.
|
||||
|
||||
:param `albums`: List of album objects.
|
||||
:param `hash`: Hash of album.
|
||||
:return: Index of album in list.
|
||||
"""
|
||||
|
||||
left = 0
|
||||
@@ -62,8 +66,11 @@ def find_album(albums: List[models.Album], hash: str) -> int | None:
|
||||
iter += 1
|
||||
mid = (left + right) // 2
|
||||
|
||||
if albums[mid].hash == hash:
|
||||
return mid
|
||||
try:
|
||||
if albums[mid].hash == hash:
|
||||
return mid
|
||||
except AttributeError:
|
||||
print(albums)
|
||||
|
||||
if albums[mid].hash < hash:
|
||||
left = mid + 1
|
||||
@@ -151,7 +158,7 @@ def get_album_tracks(album: str, artist: str) -> List:
|
||||
return GetAlbumTracks(album, artist).find_tracks()
|
||||
|
||||
|
||||
def create_album(track: dict, tracklist: list) -> models.Album:
|
||||
def create_album(track: dict, tracklist: list) -> dict:
|
||||
"""
|
||||
Generates and returns an album object from a track object.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user