From b6e1a7d14ec40f7c1de65c412d8c95c1233c63bd Mon Sep 17 00:00:00 2001 From: JotaChina Date: Thu, 22 May 2025 17:22:05 -0300 Subject: [PATCH] =?UTF-8?q?caminhos=20de=20=C3=A1udio=20nos=20instrumentos?= =?UTF-8?q?=20em=20projetos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _layouts/projetos.html | 115 +++++++++-------------------- scripts/handler/src_instruments.py | 28 +++++++ 2 files changed, 62 insertions(+), 81 deletions(-) create mode 100644 scripts/handler/src_instruments.py diff --git a/_layouts/projetos.html b/_layouts/projetos.html index 5c7da27..53fec1b 100644 --- a/_layouts/projetos.html +++ b/_layouts/projetos.html @@ -88,8 +88,9 @@ title: "{{ page.file }}" {% if page.tracks and page.tracks.size > 0 %}
-

🎚️ Instrumentos

+

🎚️ Instrumentos

+
    {% for track in page.tracks %} {% assign tem_instr = false %} @@ -104,89 +105,41 @@ title: "{{ page.file }}" {% endif %} {% if tem_instr %} -
      - {% for instrument in track.instruments %} - {% if instrument.instrument_name %} -
    • - - {% assign instrument_slug = instrument.instrument_name | replace: ' ', '+' %} +
        + {% for instrument in track.instruments %} + {% if instrument.instrument_name %} +
      • + + {% assign instrument_slug = instrument.instrument_name | replace: ' ', '+' %} + + {{ instrument.instrument_name }} + - - {{ instrument.instrument_name }} - - - {% if page.tracks and page.tracks.size > 0 %} -
        -

        🎚️ Instrumentos

        -
        - -
          - {% for track in page.tracks %} - {% assign tem_instr = false %} - {% if track.instruments and track.instruments.size > 0 %} - {% assign tem_instr = true %} - {% endif %} - - {% if track.bassline_name or tem_instr %} -
        • - {% if track.bassline_name %} -

          🎼 {{ track.bassline_name }}

          - {% endif %} - - {% if tem_instr %} -
            - {% for instrument in track.instruments %} - {% if instrument.instrument_name %} -
          • - - {% assign instrument_slug = instrument.instrument_name | replace: ' ', '+' %} - - {{ instrument.instrument_name }} - - - - {% assign base_path = "/usr/share/lmms/" %} - {% assign found_audio = false %} - - - {% assign subfolders = "instrumentos/sintetizadores, instrumentos/bateria, outros" | split: ", " %} - - {% for folder in subfolders %} - {% assign audio_file_path = base_path | append: folder | append: "/" | append: instrument.instrument_name | append: ".wav" %} - - - {% if audio_file_path %} - {% assign found_audio = true %} -
            - -
            - {% break %} - {% endif %} - {% endfor %} - - {% if found_audio == false %} -

            Áudio não encontrado para este instrumento.

            - {% endif %} - -
          • - {% endif %} - {% endfor %} -
          - {% endif %} -
        • - {% endif %} - {% endfor %} -
        + + {% assign found_audio = false %} + + {% for audio_file in site.data.audio_files %} + {% if audio_file contains instrument.instrument_name %} + {% assign audio_file_path = audio_file %} + {% assign found_audio = true %} +
        +
        -
        - {% endif %} -
      • + {% break %} + {% endif %} + {% endfor %} + + {% if found_audio == false %} +

        Áudio não encontrado para este instrumento.

        {% endif %} - {% endfor %} -
      + +
    • + {% endif %} + {% endfor %} +
    {% endif %} {% endif %} diff --git a/scripts/handler/src_instruments.py b/scripts/handler/src_instruments.py new file mode 100644 index 0000000..6a0af68 --- /dev/null +++ b/scripts/handler/src_instruments.py @@ -0,0 +1,28 @@ +import os +import json + +# Caminho base onde os arquivos .wav estão localizados +base_dir = "/usr/share/lmms/" + +# Caminho para salvar o arquivo JSON na pasta metadata (na raiz do seu site) +output_file = "metadata/src_audio_files.json" # Substitua com o caminho correto + +# Função para percorrer o diretório e suas subpastas +def find_audio_files(base_dir): + audio_files = [] + for root, dirs, files in os.walk(base_dir): + for file in files: + if (file.endswith(".wav") or file.endswith(".ogg") or + file.endswith(".flac") or file.endswith(".mp3")): + # Adiciona o caminho completo do arquivo + audio_files.append(os.path.join(root, file)) + return audio_files + +# Chama a função para encontrar os arquivos +audio_files = find_audio_files(base_dir) + +# Salva a lista de arquivos encontrados em um arquivo JSON +with open(output_file, "w") as f: + json.dump(audio_files, f, indent=4) + +print(f"Arquivo JSON gerado com sucesso em: {output_file}")