songs2slides

A tool that automatically finds song lyrics and creates lyric slideshows
git clone https://git.ashermorgan.net/songs2slides/
Log | Files | Refs | README

commit ba110de0dd274d2f50b4a992bd9d2024cdbab2fc
parent 06df44551af42bcb18a4b45b924316d91637b8e8
Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com>
Date:   Sat, 16 May 2020 12:21:19 -0700

Implement error messages.

Diffstat:
MSongs2Slides/routes.py | 5+++--
MSongs2Slides/static/index.css | 6++++++
MSongs2Slides/static/index.js | 12++++++++++++
MSongs2Slides/templates/index.html | 2++
4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/Songs2Slides/routes.py b/Songs2Slides/routes.py @@ -72,11 +72,12 @@ def lyrics(): # Get lyrics lyrics = [] + failed = [] for song in request.json["songs"]: try: lyrics += models.ParseLyrics(song[0], song[1], settings) except: - pass + failed += [song] # Return lyrics - return jsonify({"lyrics": lyrics}) + return jsonify({"lyrics": lyrics, "errors": failed}) diff --git a/Songs2Slides/static/index.css b/Songs2Slides/static/index.css @@ -86,6 +86,12 @@ button { box-sizing: border-box; } +#errors { + margin-top: 10px; + color: #E00000; + font-weight: bold; +} + #lyricsButtons { margin-top: 15px; text-align: left; diff --git a/Songs2Slides/static/index.js b/Songs2Slides/static/index.js @@ -191,6 +191,7 @@ async function ReviewLyrics() { // Show and hide elements document.getElementById("lyrics").value = "Loading lyrics..."; document.getElementById("lyrics").readOnly = true; + document.getElementById("errors").textContent = ""; document.getElementById("songsContainer").hidden = true; document.getElementById("lyricsContainer").hidden = false; @@ -210,6 +211,17 @@ async function ReviewLyrics() { // Set lyrics document.getElementById("lyrics").value = json["lyrics"].join("\n\n") document.getElementById("lyrics").readOnly = false; + + // Set errors + if (json["errors"].length != 0) + { + errors = "The lyrics to the following songs could not be found: "; + for (error of json["errors"]) { + errors += `"${error[0]}" by "${error[1]}", `; + } + errors = errors.slice(0, -2); // Remove trailing ', ' + document.getElementById("errors").textContent = errors; + } } diff --git a/Songs2Slides/templates/index.html b/Songs2Slides/templates/index.html @@ -41,6 +41,8 @@ <textarea rows="15" id="lyrics"></textarea> + <p id="errors"></p> + <div id="lyricsButtons"> <a id="lyricsBack" href="javascript:Back()">Back</a> <button id="submitLyricsButton" onclick="SubmitLyrics();">Create Powerpoint</button>