caminhos de áudio nos instrumentos em projetos
This commit is contained in:
1 parent
17f4e147bd
commit
b6e1a7d14e
2 files changed
+32
-51
No files matched your search
+4
-51
@@ -85,35 +85,6 @@ title: "{{ page.file }}"
|
||||
{% endunless %}
|
||||
{% endif %}
|
||||
|
||||
<!-- Instrumentos -->
|
||||
{% if page.tracks and page.tracks.size > 0 %}
|
||||
<section class="instruments-section">
|
||||
<h2 class="title is-5"><code>🎚️ Instrumentos</h2></code>
|
||||
<div class="content">
|
||||
<ul style="list-style: none; padding-left: 0;">
|
||||
{% 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 %}
|
||||
<li class="mb-5">
|
||||
{% if track.bassline_name %}
|
||||
<p class="has-text-weight-bold mb-2">🎼 {{ track.bassline_name }}</p>
|
||||
{% endif %}
|
||||
|
||||
{% if tem_instr %}
|
||||
<ul class="pl-4">
|
||||
{% for instrument in track.instruments %}
|
||||
{% if instrument.instrument_name %}
|
||||
<li style="margin-bottom: 0.4rem;">
|
||||
<!-- Gerar link para filtro por instrumento -->
|
||||
{% assign instrument_slug = instrument.instrument_name | replace: ' ', '+' %}
|
||||
|
||||
<a href="{{ '/instruments/?instrument=' | append: instrument_slug | relative_url }}" class="tag is-info is-light">
|
||||
<code>{{ instrument.instrument_name }}</code>
|
||||
</a>
|
||||
<!-- Instrumentos -->
|
||||
{% if page.tracks and page.tracks.size > 0 %}
|
||||
<section class="instruments-section">
|
||||
@@ -144,18 +115,12 @@ title: "{{ page.file }}"
|
||||
<code>{{ instrument.instrument_name }}</code>
|
||||
</a>
|
||||
|
||||
<!-- Gerar o caminho absoluto para o áudio -->
|
||||
{% assign base_path = "/usr/share/lmms/" %}
|
||||
<!-- Buscar o caminho do áudio no arquivo JSON -->
|
||||
{% assign found_audio = false %}
|
||||
|
||||
<!-- Vamos tentar procurar em diferentes subpastas -->
|
||||
{% 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" %}
|
||||
|
||||
<!-- Verificar se o arquivo de áudio existe no caminho gerado -->
|
||||
{% if audio_file_path %}
|
||||
{% 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 %}
|
||||
<div class="audio-player-section mt-3">
|
||||
<audio controls>
|
||||
@@ -183,18 +148,6 @@ title: "{{ page.file }}"
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
@@ -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}")
|
||||
Reference in new issue
Block a user