fix messed up bisection search

This commit is contained in:
geoffrey45
2022-05-07 14:45:16 +03:00
parent d6a01cd35e
commit fb67f568ad
8 changed files with 137 additions and 59 deletions
+17 -10
View File
@@ -1,5 +1,5 @@
"""
This module contains mimi functions for the server.
This module contains mini functions for the server.
"""
import datetime
import os
@@ -27,9 +27,7 @@ def background(func):
return background_func
def run_fast_scandir(__dir: str,
ext: list,
full=False) -> Dict[List[str], List[str]]:
def run_fast_scandir(__dir: str, ext: list, full=False) -> Dict[List[str], List[str]]:
"""
Scans a directory for files with a specific extension. Returns a list of files and folders in the directory.
"""
@@ -62,10 +60,12 @@ def remove_duplicates(tracklist: List[models.Track]) -> List[models.Track]:
while song_num < len(tracklist) - 1:
for index, song in enumerate(tracklist):
if (tracklist[song_num].title == song.title
and tracklist[song_num].album == song.album
and tracklist[song_num].artists == song.artists
and index != song_num):
if (
tracklist[song_num].title == song.title
and tracklist[song_num].album == song.album
and tracklist[song_num].artists == song.artists
and index != song_num
):
tracklist.remove(song)
song_num += 1
@@ -108,8 +108,7 @@ def check_artist_image(image: str) -> str:
"""
img_name = image.replace("/", "::") + ".webp"
if not os.path.exists(os.path.join(app_dir, "images", "artists",
img_name)):
if not os.path.exists(os.path.join(app_dir, "images", "artists", img_name)):
return use_memoji()
else:
return img_name
@@ -125,3 +124,11 @@ class Timer:
def stop(self):
self.end = time.time()
print(str(datetime.timedelta(seconds=round(self.end - self.begin))))
def create_album_hash(title: str, artist: str) -> str:
"""
Creates a simple hash for an album
"""
return (title + artist).replace(" ", "").lower()