# utils.py import os # --- Configurações de Caminhos --- BASE_PATH = "/nethome/jotachina/projetos/mmpSearch" MMP_FOLDER = os.path.join(BASE_PATH, "mmp") MMPZ_FOLDER = os.path.join(BASE_PATH, "mmp/mmpz") WAV_FOLDER = os.path.join(BASE_PATH, "mmp/wav") METADATA_FOLDER = os.path.join(BASE_PATH, "metadata") DATA_FOLDER = os.path.join(BASE_PATH, "_data") CONFIGS = [ { "source_dir": "src/samples", "output_file": "metadata/samples-manifest.json", "scan_type": "tree", }, { "source_dir": "mmp", "output_file": "metadata/mmp-manifest.json", "scan_type": "list", "extensions": [".mmp", ".mmpz"], }, ] def scan_directory_tree(path): tree = {} if not os.path.isdir(path): return tree for item in os.listdir(path): full_path = os.path.join(path, item) if os.path.isdir(full_path): tree[item] = scan_directory_tree(full_path) else: tree[item] = {"_isFile": True} return tree def scan_directory_list(path, allowed_extensions): file_list = [] if not os.path.isdir(path): return file_list for item in os.listdir(path): full_path = os.path.join(path, item) if os.path.isfile(full_path) and any( item.lower().endswith(ext) for ext in allowed_extensions ): file_list.append(item) return sorted(file_list) SUPPORTED_PLUGINS = [ "audiofileprocessor", "bitinvader", "freeboy", "papu", "gigplayer", "kicker", "lb302", "malletsstk", "monstro", "nes", "opl2", "organic", "patman", "sf2player", "sfxr", "sid", "tripleoscillator", "vibedstrings", "watsyn", "zynaddsubfx", ] tags = {} tags["TAG"] = [] tags["plugin"] = [] tags["sample"] = [] tags["bassline"] = [] tags["automation"] = [] def create_folders_if_not_exist(folders): for folder in folders: if not os.path.exists(folder): os.makedirs(folder)