mirror of
https://gitlab.com/parroquia-san-leandro/cancionero-web.git
synced 2024-12-22 00:33:33 +01:00
canciones que no estan en el cancionero
tambien se han arreglado las comillas en algunas canciones
This commit is contained in:
parent
362dfd34e7
commit
bbf76fa6a3
2 changed files with 32 additions and 5 deletions
2
Makefile
2
Makefile
|
@ -14,7 +14,7 @@ public:
|
|||
mkdir public
|
||||
|
||||
public/index.html: $(ALL_TEMPLATES) $(PY_SRC)
|
||||
python3 src/latex_scanner.py --latex latex/cancionero.tex --audios audios
|
||||
python3 src/latex_scanner.py --latex latex/cancionero.tex --audios audios --other-latex latex/canciones/
|
||||
|
||||
public/audios: audios public
|
||||
rm -f public/audios
|
||||
|
|
|
@ -11,10 +11,12 @@ from pathlib import Path
|
|||
from audio_scanner import find_audios
|
||||
from model import Chord, Line, Song, Verse
|
||||
|
||||
|
||||
def mkdir(path):
|
||||
if not os.path.exists(path):
|
||||
os.mkdir(path)
|
||||
|
||||
|
||||
# Note that re.match prepends ^ to the pattern, whereas re.search doesn't
|
||||
|
||||
|
||||
|
@ -66,6 +68,19 @@ class SongLoader:
|
|||
input_file += ".tex"
|
||||
self.scan_song_file(input_file)
|
||||
|
||||
def scan_others(self, folder, start_index):
|
||||
self.index = start_index
|
||||
self.category = "Nuevas"
|
||||
self.categories.append(self.category)
|
||||
files_scanned = [s.latex_file for s in self.songs]
|
||||
files_to_scan = [os.path.join(root, name) for root, dirs, files in os.walk(folder, topdown=False) for name in
|
||||
files]
|
||||
files_to_scan = [f for f in files_to_scan if f.endswith(".tex") and f[f.index('/') + 1:] not in files_scanned]
|
||||
files_to_scan = sorted(files_to_scan)
|
||||
for f in files_to_scan:
|
||||
print("Scanning extra file", f)
|
||||
self.scan_song_file(f)
|
||||
|
||||
def scan_song_file(self, song_file):
|
||||
# Variables
|
||||
ignore = False
|
||||
|
@ -83,6 +98,10 @@ class SongLoader:
|
|||
# Remove commends and \brk commands
|
||||
text = re.sub(r"%.*$", "", line)
|
||||
text = re.sub(r"\\brk({})?", '', text)
|
||||
text = re.sub(r"``", u"\u201C", text)
|
||||
text = re.sub(r"''", u"\u201D", text)
|
||||
text = re.sub(r"`", u"\u2018", text)
|
||||
text = re.sub(r"'", u"\u2019", text)
|
||||
|
||||
extras = {}
|
||||
i = 0
|
||||
|
@ -114,7 +133,7 @@ class SongLoader:
|
|||
author=read_property(re_song_begin_match.group(2), "by"),
|
||||
origin=read_property(re_song_begin_match.group(2), "m"),
|
||||
category=self.category,
|
||||
latex_file=song_file[song_file.index('/')+1:])
|
||||
latex_file=song_file[song_file.index('/') + 1:])
|
||||
transpose = 0
|
||||
memory = None
|
||||
memorizing = False
|
||||
|
@ -240,9 +259,10 @@ class SongLoader:
|
|||
with open(index_file, 'w') as f:
|
||||
f.write(html)
|
||||
|
||||
def print_song(self, song, directory, dj_engine):
|
||||
@staticmethod
|
||||
def print_song(song, directory, dj_engine):
|
||||
context = Context({'song': song})
|
||||
num_dir = join(directory, "%03d" % (song.number))
|
||||
num_dir = join(directory, "%03d" % song.number)
|
||||
mkdir(num_dir)
|
||||
with open(join(num_dir, "index.html"), 'w') as f:
|
||||
f.write(dj_engine.get_template("song_redir.html").render(context))
|
||||
|
@ -261,7 +281,12 @@ class SongLoader:
|
|||
def parse_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--latex", required=True, nargs=1, help="The main LaTeX file. It may include other documents")
|
||||
parser.add_argument("--audios", required=False, nargs=1, default=[None], help="The folder containing the audio files.")
|
||||
parser.add_argument("--other-latex", required=False, nargs=1, default=[None],
|
||||
help="A folder with songs, those not referenced in the main file will be included at the end.")
|
||||
parser.add_argument("--other-index", required=False, nargs=1, default=["400"],
|
||||
help="The first song number for songs outside the main songbook.")
|
||||
parser.add_argument("--audios", required=False, nargs=1, default=[None],
|
||||
help="The folder containing the audio files.")
|
||||
parser.add_argument("--output-dir", required=False, nargs=1, default=["public"])
|
||||
return parser.parse_args()
|
||||
|
||||
|
@ -269,6 +294,8 @@ def parse_args():
|
|||
if __name__ == '__main__':
|
||||
args = parse_args()
|
||||
loader = SongLoader(args.latex[0], args.audios[0])
|
||||
if args.other_latex:
|
||||
loader.scan_others(args.other_latex[0], int(args.other_index[0]))
|
||||
settings.configure(USE_TZ=False, USE_I18N=False)
|
||||
e = Engine(dirs=["res/templates/"])
|
||||
loader.generate_html(args.output_dir[0], e)
|
||||
|
|
Loading…
Reference in a new issue