# utils.py import os # --- Configurações de Caminhos --- #BASE_PATH = "/nethome/jotachina/projetos/mmpSearch" #MMP_FOLDER = "/nethome/jotachina/projetos/src_mmpSearch/mmp" #MMPZ_FOLDER = "/nethome/jotachina/projetos/src_mmpSearch/mmpz" #WAV_FOLDER = "/nethome/jotachina/projetos/src_mmpSearch/wav" #### # Corrigir caminhos do site global (user www-data) #### BASE_PATH = "/mmpSearch" MMP_FOLDER = "src_mmpSearch/mmp" MMPZ_FOLDER = "src_mmpSearch/mmpz" WAV_FOLDER = "src_mmpSearch/wav" METADATA_FOLDER = os.path.join(BASE_PATH, "metadata") DATA_FOLDER = os.path.join(BASE_PATH, "_data") CERT_PATH = "/etc/letsencrypt/live/alice.ufsj.edu.br/fullchain.pem" KEY_PATH = "/etc/letsencrypt/live/alice.ufsj.edu.br/privkey.pem" RUNTIME_DIR = "/tmp/runtime-root" CONFIGS = [ { "source_dir": "src/samples", "output_file": "metadata/samples-manifest.json", "scan_type": "tree", }, { "source_dir": BASE_PATH, "output_file": METADATA_FOLDER, "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)