arreglar audios despues de cambiar los titulos de formato

This commit is contained in:
Carlos Galindo 2022-11-22 09:08:59 +01:00
parent cb2ced5d52
commit 36db883be7
6 changed files with 9 additions and 22 deletions

View file

@ -14,11 +14,11 @@ public:
mkdir public
public/index.html: $(ALL_TEMPLATES) $(PY_SRC)
python3 src/latex_scanner.py --latex latex/cancionero.tex --audios audios --other-latex latex/canciones/
python3 src/latex_scanner.py --latex latex/cancionero.tex --audios audios/Canciones --other-latex latex/canciones/
public/audios: audios public
rm -f public/audios
ln -s ../audios public/audios
ln -s ../audios/Canciones public/audios
public/main.css: res/less/main.less res/less/colors.less
lessc $< $@

View file

@ -14,6 +14,7 @@ h1 {
h2, h3 {
color: @subtitle;
font-weight: lighter;
margin-bottom: 0;
}
footer {

View file

@ -106,13 +106,12 @@
{% endfor %}
</div>
</div>
{% for audio in audios %}
{% for audio in song.audios %}
{% if forloop.first %}
<h3>Audios</h3>
{% endif %}
<div>
Audio del {{ audio.date_text }} <a href="{{ audio.audio_file|urlencode }}"><span>Descargar</span></a>
<audio controls style='width: 100%%;'>
<audio controls style='width: 100%;'>
<source src='{{ audio.audio_file|urlencode }}' type='audio/mpeg'/>
</audio>
</div>

View file

@ -8,7 +8,7 @@ from datetime import datetime
def find_audios(index, audio_dir):
"""
Finds all audios in a folder that match the given index.
Audios must be in the format [index]_[YYYY]-[MM]-[DD].mp3
Audios must be in the format [index].[songname].mp3
:param index: An integer denoting the song's index
:param audio_dir: The directory where the songs can be found
:return: A list of matching Audio objects
@ -16,9 +16,8 @@ def find_audios(index, audio_dir):
res = []
for f in listdir(audio_dir):
full_file = join(audio_dir, f)
re_date_match = re.match(r"^%03d[_ ](\d{4}-[01]\d-[0-3]\d).mp3$" % index, f)
re_date_match = re.match(r"^%03d\..*\.mp3$" % index, f)
if not isfile(full_file) or not re_date_match:
continue
date = datetime.strptime(re_date_match.group(1), "%Y-%m-%d")
res.append(Audio(date, join("../", full_file)))
res.append(Audio(join("../", full_file)))
return res

View file

@ -1,7 +1,6 @@
import argparse
import os
import re
import shutil
from django.conf import settings
from django.template import Engine, Context
@ -141,14 +140,6 @@ class SongLoader:
replay_index = 0
if hasattr(self, "audio_dir"):
for a in find_audios(self.index, self.audio_dir):
a_split = a.audio_file.split("/")
renamed_dir = join(join(".", "audios"), "Canciones")
new_name = "%03d %s - %s - %s.mp3" % (
current_song.number,
current_song.name,
current_song.author if current_song.author else "-",
a.date.strftime("%Y-%m-%d"))
shutil.copy2("/".join(a_split[1:]), join(renamed_dir, new_name))
current_song.add_audio(a)
continue
if re.match(r"\\endsong", remain):

View file

@ -200,10 +200,7 @@ class Chord:
class Audio:
def __init__(self, date, audio_file):
assert isinstance(date, datetime)
self.date = date
self.date_text = date.strftime("%A %-d de %B del %Y")
def __init__(self, audio_file):
self.audio_file = audio_file
def __str__(self):