From 36db883be7aba9188a5440473840189b86371760 Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Tue, 22 Nov 2022 09:08:59 +0100 Subject: [PATCH] arreglar audios despues de cambiar los titulos de formato --- Makefile | 4 ++-- res/less/main.less | 1 + res/templates/song.html | 5 ++--- src/audio_scanner.py | 7 +++---- src/latex_scanner.py | 9 --------- src/model.py | 5 +---- 6 files changed, 9 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index fd3d188..baa7f50 100644 --- a/Makefile +++ b/Makefile @@ -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 $< $@ diff --git a/res/less/main.less b/res/less/main.less index 2544c35..e1464dd 100644 --- a/res/less/main.less +++ b/res/less/main.less @@ -14,6 +14,7 @@ h1 { h2, h3 { color: @subtitle; font-weight: lighter; + margin-bottom: 0; } footer { diff --git a/res/templates/song.html b/res/templates/song.html index 105b485..f16acf7 100644 --- a/res/templates/song.html +++ b/res/templates/song.html @@ -106,13 +106,12 @@ {% endfor %} - {% for audio in audios %} + {% for audio in song.audios %} {% if forloop.first %}

Audios

{% endif %}
- Audio del {{ audio.date_text }} Descargar -
diff --git a/src/audio_scanner.py b/src/audio_scanner.py index 5b98f7b..d798cd5 100644 --- a/src/audio_scanner.py +++ b/src/audio_scanner.py @@ -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 diff --git a/src/latex_scanner.py b/src/latex_scanner.py index 26d9f6c..1d38570 100644 --- a/src/latex_scanner.py +++ b/src/latex_scanner.py @@ -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): diff --git a/src/model.py b/src/model.py index 6dc4d35..0b599be 100644 --- a/src/model.py +++ b/src/model.py @@ -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):