Search for files containing image_name
This commit is contained in:
@@ -12,23 +12,25 @@ def get_all_tracks():
|
|||||||
return sorted([x.name for x in os.scandir(TRACKS_FOLDER) if x.is_dir()])
|
return sorted([x.name for x in os.scandir(TRACKS_FOLDER) if x.is_dir()])
|
||||||
|
|
||||||
def get_preview_image(track: str, config: str = ""):
|
def get_preview_image(track: str, config: str = ""):
|
||||||
return get_path_image("preview.png", track, config)
|
return get_path_image("preview", track, config)
|
||||||
|
|
||||||
def get_outline_image(track: str, config: str = ""):
|
def get_outline_image(track: str, config: str = ""):
|
||||||
return get_path_image("outline.png", track, config)
|
return get_path_image("outline", track, config)
|
||||||
|
|
||||||
def get_path_image(image_name, track: str, config: str = ""):
|
def get_path_image(image_name, track: str, config: str = ""):
|
||||||
img_path = os.path.join(TRACKS_FOLDER, track, "ui", config, image_name)
|
img_path = os.path.join(TRACKS_FOLDER, track, "ui", config)
|
||||||
if os.path.exists(img_path):
|
for name in os.listdir(img_path):
|
||||||
return img_path
|
lower = name.lower()
|
||||||
|
if image_name in lower and lower.endswith(".png"):
|
||||||
|
return os.path.join(img_path, name)
|
||||||
|
|
||||||
|
|
||||||
img_path = os.path.join(TRACKS_FOLDER, track, image_name)
|
img_path = os.path.join(TRACKS_FOLDER, track, image_name)
|
||||||
if os.path.exists(img_path):
|
for name in os.listdir(img_path):
|
||||||
return img_path
|
lower = name.lower()
|
||||||
|
if image_name in lower and lower.endswith(".png"):
|
||||||
img_path = os.path.join(TRACKS_FOLDER, track, image_name.replace(".png",".PNG"))
|
return os.path.join(img_path, name)
|
||||||
if os.path.exists(img_path):
|
|
||||||
return img_path
|
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user