mirror of
https://github.com/krateng/maloja.git
synced 2025-07-09 03:04:07 -04:00
Updated manual scrobbling page
This commit is contained in:
parent
2c754c75ce
commit
a0a8ba4052
@ -1,68 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<title>Maloja - Issues</title>
|
|
||||||
<script src="/cookies.js"></script>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<table class="top_info">
|
|
||||||
<tr>
|
|
||||||
<td class="image">
|
|
||||||
<div style="background-image:url('/favicon.png')"></div>
|
|
||||||
</td>
|
|
||||||
<td class="text">
|
|
||||||
<h1>Possible Issues</h1><br/>
|
|
||||||
<span>with your library</span>
|
|
||||||
<p class="stats">KEY_ISSUES Issues</p>
|
|
||||||
|
|
||||||
<p>Maloja can identify possible problems with consistency or redundancy in your library. After making any changes, you should <a class="textlink" onclick='fullrebuild()'>rebuild your library</a>.<br/>
|
|
||||||
Your API key is required to make any changes to the server: <input id='apikey' onchange='checkAPIkey()' style='width:300px;'/></p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
KEY_ISSUESLIST
|
|
||||||
|
|
||||||
</body>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
|
|
||||||
|
|
||||||
function newrule() {
|
|
||||||
if (apikeycorrect) {
|
|
||||||
keys = ""
|
|
||||||
for (var i = 1; i < arguments.length; i++) {
|
|
||||||
keys += encodeURIComponent(arguments[i]) + "&"
|
|
||||||
}
|
|
||||||
apikey = document.getElementById("apikey").value
|
|
||||||
keys += "key=" + encodeURIComponent(apikey)
|
|
||||||
console.log(keys)
|
|
||||||
|
|
||||||
|
|
||||||
var xhttp = new XMLHttpRequest();
|
|
||||||
xhttp.open("POST","/api/newrule?", true);
|
|
||||||
xhttp.send(keys);
|
|
||||||
e = arguments[0]
|
|
||||||
line = e.parentNode
|
|
||||||
line.parentNode.removeChild(line)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function fullrebuild() {
|
|
||||||
if (apikeycorrect) {
|
|
||||||
apikey = document.getElementById("apikey").value
|
|
||||||
|
|
||||||
var xhttp = new XMLHttpRequest();
|
|
||||||
xhttp.open("POST","/api/rebuild", true);
|
|
||||||
xhttp.send("key=" + encodeURIComponent(apikey))
|
|
||||||
window.location = "/wait";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</html>
|
|
@ -1,44 +0,0 @@
|
|||||||
import urllib
|
|
||||||
from .. import database
|
|
||||||
from ..htmlgenerators import artistLink
|
|
||||||
|
|
||||||
def instructions(keys):
|
|
||||||
|
|
||||||
db_data = database.issues()
|
|
||||||
i = 0
|
|
||||||
|
|
||||||
html = "<table class='list'>"
|
|
||||||
if db_data["inconsistent"]:
|
|
||||||
html += "<tr>"
|
|
||||||
html += "<td>The current database wasn't built with all current rules in effect. Any problem below might be a false alarm and fixing it could create redundant rules.</td>"
|
|
||||||
html += """<td class='button important' onclick="fullrebuild()"><div>Rebuild the database</div></td>"""
|
|
||||||
html += "</tr>"
|
|
||||||
i += 1
|
|
||||||
for d in db_data["duplicates"]:
|
|
||||||
html += "<tr>"
|
|
||||||
html += "<td>'" + artistLink(d[0]) + "'"
|
|
||||||
html += " is a possible duplicate of "
|
|
||||||
html += "'" + artistLink(d[1]) + "'</td>"
|
|
||||||
html += """<td class='button' onclick="newrule(this,'replaceartist','""" + d[0] + """','""" + d[1] + """')"><div>""" + d[1] + """ is correct</div></td>"""
|
|
||||||
html += """<td class='button' onclick="newrule(this,'replaceartist','""" + d[1] + """','""" + d[0] + """')"><div>""" + d[0] + """ is correct</div></td>"""
|
|
||||||
html += "</tr>"
|
|
||||||
i += 1
|
|
||||||
for c in db_data["combined"]:
|
|
||||||
html += "<tr>"
|
|
||||||
html += "<td>'" + artistLink(c[0]) + "' sounds like the combination of " + str(len(c[1])) + " artists: "
|
|
||||||
for a in c[1]:
|
|
||||||
html += "'" + artistLink(a) + "' "
|
|
||||||
html += "</td>"
|
|
||||||
html += """<td class='button' onclick="newrule(this,'replaceartist','""" + c[0] + """','""" + "␟".join(c[1]) + """')"><div>Fix it</div></td>"""
|
|
||||||
html += "</tr>"
|
|
||||||
i += 1
|
|
||||||
for n in db_data["newartists"]:
|
|
||||||
html += "<tr>"
|
|
||||||
html += "<td>Is '" + n[0] + "' in '" + artistLink(n[1]) + "' an artist?</td>"
|
|
||||||
html += """<td class='button' onclick="newrule(this,'replaceartist','""" + n[1] + """','""" + "␟".join(n[2] + [n[0]]) + """')"><div>Yes</div></td>"""
|
|
||||||
html += "</tr>"
|
|
||||||
i += 1
|
|
||||||
|
|
||||||
html += "</table>"
|
|
||||||
|
|
||||||
return ({"KEY_ISSUESLIST":html,"KEY_ISSUES":str(i)},[])
|
|
186
maloja/web/jinja/manual.jinja
Normal file
186
maloja/web/jinja/manual.jinja
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
{% extends "base.jinja" %}
|
||||||
|
{% block title %}Maloja - Manual Scrobbling{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
<script src="/cookies.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function keyDetect(event) {
|
||||||
|
if (event.key === "Enter" || event.key === "Tab") { addArtist() }
|
||||||
|
if (event.key === "Backspace" && document.getElementById("artists").value == "") { removeArtist() }
|
||||||
|
}
|
||||||
|
|
||||||
|
function addArtist() {
|
||||||
|
element = document.getElementById("artists");
|
||||||
|
newartist = element.value.trim();
|
||||||
|
element.value = "";
|
||||||
|
if (newartist != "") {
|
||||||
|
artist = document.createElement("span");
|
||||||
|
artist.innerHTML = newartist;
|
||||||
|
artist.style = "padding:5px;";
|
||||||
|
document.getElementById("artists_td").insertBefore(artist,element);
|
||||||
|
|
||||||
|
element.placeholder = "Backspace to remove last"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function removeArtist() {
|
||||||
|
artists = document.getElementById("artists_td").getElementsByTagName("span")
|
||||||
|
lastartist = artists[artists.length-1]
|
||||||
|
document.getElementById("artists_td").removeChild(lastartist);
|
||||||
|
if (artists.length < 1) {
|
||||||
|
document.getElementById("artists").placeholder = "Separate with Enter"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function scrobbleIfEnter(event) {
|
||||||
|
if (event.key === "Enter") {
|
||||||
|
scrobbleNew()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function scrobbleNew() {
|
||||||
|
artistnodes = document.getElementById("artists_td").getElementsByTagName("span");
|
||||||
|
artists = [];
|
||||||
|
for (let node of artistnodes) {
|
||||||
|
artists.push(node.innerHTML);
|
||||||
|
}
|
||||||
|
title = document.getElementById("title").value;
|
||||||
|
scrobble(artists,title);
|
||||||
|
}
|
||||||
|
|
||||||
|
function scrobble(artists,title) {
|
||||||
|
|
||||||
|
|
||||||
|
artist = artists.join(";");
|
||||||
|
|
||||||
|
if (title != "" && artists.length > 0) {
|
||||||
|
xhttp = new XMLHttpRequest();
|
||||||
|
xhttp.onreadystatechange = scrobbledone
|
||||||
|
xhttp.open("GET","/api/newscrobble?artist=" + encodeURIComponent(artist) +
|
||||||
|
"&title=" + encodeURIComponent(title), true);
|
||||||
|
xhttp.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById("title").value = "";
|
||||||
|
document.getElementById("artists").value = "";
|
||||||
|
parent = document.getElementById("artists_td");
|
||||||
|
artists = document.getElementById("artists_td").getElementsByTagName("span")
|
||||||
|
while (artists.length > 0) {
|
||||||
|
removeArtist();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function scrobbledone() {
|
||||||
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
|
result = JSON.parse(this.responseText);
|
||||||
|
txt = result["track"]["title"] + " by " + result["track"]["artists"][0];
|
||||||
|
if (result["track"]["artists"].length > 1) {
|
||||||
|
txt += " et al.";
|
||||||
|
}
|
||||||
|
document.getElementById("scrobbleresult").innerHTML = "Scrobbled " + txt + "!";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// SEARCH
|
||||||
|
///
|
||||||
|
|
||||||
|
function search_manualscrobbling(searchfield) {
|
||||||
|
txt = searchfield.value;
|
||||||
|
if (txt == "") {
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
xhttp = new XMLHttpRequest();
|
||||||
|
xhttp.onreadystatechange = searchresult_manualscrobbling;
|
||||||
|
xhttp.open("GET","/api/search?max=5&query=" + encodeURIComponent(txt), true);
|
||||||
|
xhttp.send();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function searchresult_manualscrobbling() {
|
||||||
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
|
document.getElementById("searchresults").innerHTML = "";
|
||||||
|
result = JSON.parse(this.responseText);
|
||||||
|
tracks = result["tracks"].slice(0,10);
|
||||||
|
console.log(tracks);
|
||||||
|
for (let t of tracks) {
|
||||||
|
track = document.createElement("span");
|
||||||
|
trackstr = t["artists"].join(", ") + " - " + t["title"];
|
||||||
|
tracklink = t["link"];
|
||||||
|
track.innerHTML = "<a href='" + tracklink + "'>" + trackstr + "</a>";
|
||||||
|
row = document.createElement("tr")
|
||||||
|
col1 = document.createElement("td")
|
||||||
|
col1.className = "button"
|
||||||
|
col1.innerHTML = "Scrobble!"
|
||||||
|
col1.onclick = function(){ scrobble(t["artists"],t["title"])};
|
||||||
|
col2 = document.createElement("td")
|
||||||
|
row.appendChild(col1)
|
||||||
|
row.appendChild(col2)
|
||||||
|
col2.appendChild(track)
|
||||||
|
document.getElementById("searchresults").appendChild(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<table class="top_info">
|
||||||
|
<tr>
|
||||||
|
<td class="image">
|
||||||
|
<div style="background-image:url('/favicon.png')"></div>
|
||||||
|
</td>
|
||||||
|
<td class="text">
|
||||||
|
<h1>Manual Scrobbling</h1><br/>
|
||||||
|
<br/><br/>
|
||||||
|
<span id="scrobbleresult"></span>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h1>Scrobble new discovery</h1>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td style="padding-right:7px;">
|
||||||
|
Artists:
|
||||||
|
</td><td id="artists_td">
|
||||||
|
<input placeholder='Separate with Enter' class='simpleinput' id='artists' onKeydown='keyDetect(event)' />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding-right:7px;">
|
||||||
|
Title:
|
||||||
|
</td><td>
|
||||||
|
<input placeholder='Enter to scrobble' class='simpleinput' id='title' onKeydown='scrobbleIfEnter(event)' />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<span class="button" onclick="scrobbleNew(event)">Scrobble!</span>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h1>Search</h1>
|
||||||
|
|
||||||
|
<input class="simpleinput" placeholder='Search for a track' oninput='search_manualscrobbling(this)' />
|
||||||
|
<br/><br/>
|
||||||
|
<table id="searchresults"></table>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -1,199 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<title>Maloja</title>
|
|
||||||
<script src="/cookies.js"></script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function keyDetect(event) {
|
|
||||||
if (event.key === "Enter" || event.key === "Tab") { addArtist() }
|
|
||||||
if (event.key === "Backspace" && document.getElementById("artists").value == "") { removeArtist() }
|
|
||||||
}
|
|
||||||
|
|
||||||
function addArtist() {
|
|
||||||
element = document.getElementById("artists");
|
|
||||||
newartist = element.value.trim();
|
|
||||||
element.value = "";
|
|
||||||
if (newartist != "") {
|
|
||||||
artist = document.createElement("span");
|
|
||||||
artist.innerHTML = newartist;
|
|
||||||
artist.style = "padding:5px;";
|
|
||||||
document.getElementById("artists_td").insertBefore(artist,element);
|
|
||||||
|
|
||||||
element.placeholder = "Backspace to remove last"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function removeArtist() {
|
|
||||||
artists = document.getElementById("artists_td").getElementsByTagName("span")
|
|
||||||
lastartist = artists[artists.length-1]
|
|
||||||
document.getElementById("artists_td").removeChild(lastartist);
|
|
||||||
if (artists.length < 1) {
|
|
||||||
document.getElementById("artists").placeholder = "Separate with Enter"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function scrobbleIfEnter(event) {
|
|
||||||
if (event.key === "Enter") {
|
|
||||||
scrobbleNew()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function scrobbleNew() {
|
|
||||||
artistnodes = document.getElementById("artists_td").getElementsByTagName("span");
|
|
||||||
artists = [];
|
|
||||||
for (let node of artistnodes) {
|
|
||||||
artists.push(node.innerHTML);
|
|
||||||
}
|
|
||||||
title = document.getElementById("title").value;
|
|
||||||
scrobble(artists,title);
|
|
||||||
}
|
|
||||||
|
|
||||||
function scrobble(artists,title) {
|
|
||||||
|
|
||||||
|
|
||||||
artist = artists.join(";");
|
|
||||||
key = APIkey();
|
|
||||||
|
|
||||||
if (title != "" && artists.length > 0) {
|
|
||||||
xhttp = new XMLHttpRequest();
|
|
||||||
xhttp.onreadystatechange = scrobbledone
|
|
||||||
xhttp.open("GET","/api/newscrobble?artist=" + encodeURIComponent(artist) +
|
|
||||||
"&title=" + encodeURIComponent(title) +
|
|
||||||
"&key=" + encodeURIComponent(key), true);
|
|
||||||
xhttp.send();
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById("title").value = "";
|
|
||||||
document.getElementById("artists").value = "";
|
|
||||||
parent = document.getElementById("artists_td");
|
|
||||||
artists = document.getElementById("artists_td").getElementsByTagName("span")
|
|
||||||
while (artists.length > 0) {
|
|
||||||
removeArtist();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function scrobbledone() {
|
|
||||||
if (this.readyState == 4 && this.status == 200) {
|
|
||||||
result = JSON.parse(this.responseText);
|
|
||||||
txt = result["track"]["title"] + " by " + result["track"]["artists"][0];
|
|
||||||
if (result["track"]["artists"].length > 1) {
|
|
||||||
txt += " et al.";
|
|
||||||
}
|
|
||||||
document.getElementById("scrobbleresult").innerHTML = "Scrobbled " + txt + "!";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
// SEARCH
|
|
||||||
///
|
|
||||||
|
|
||||||
function search_manualscrobbling(searchfield) {
|
|
||||||
txt = searchfield.value;
|
|
||||||
if (txt == "") {
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
xhttp = new XMLHttpRequest();
|
|
||||||
xhttp.onreadystatechange = searchresult_manualscrobbling;
|
|
||||||
xhttp.open("GET","/api/search?max=5&query=" + encodeURIComponent(txt), true);
|
|
||||||
xhttp.send();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function searchresult_manualscrobbling() {
|
|
||||||
if (this.readyState == 4 && this.status == 200) {
|
|
||||||
document.getElementById("searchresults").innerHTML = "";
|
|
||||||
result = JSON.parse(this.responseText);
|
|
||||||
tracks = result["tracks"].slice(0,10);
|
|
||||||
console.log(tracks);
|
|
||||||
for (let t of tracks) {
|
|
||||||
track = document.createElement("span");
|
|
||||||
trackstr = t["artists"].join(", ") + " - " + t["title"];
|
|
||||||
tracklink = t["link"];
|
|
||||||
track.innerHTML = "<a href='" + tracklink + "'>" + trackstr + "</a>";
|
|
||||||
row = document.createElement("tr")
|
|
||||||
col1 = document.createElement("td")
|
|
||||||
col1.className = "button"
|
|
||||||
col1.innerHTML = "Scrobble!"
|
|
||||||
col1.onclick = function(){ scrobble(t["artists"],t["title"])};
|
|
||||||
col2 = document.createElement("td")
|
|
||||||
row.appendChild(col1)
|
|
||||||
row.appendChild(col2)
|
|
||||||
col2.appendChild(track)
|
|
||||||
document.getElementById("searchresults").appendChild(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
</head>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<table class="top_info">
|
|
||||||
<tr>
|
|
||||||
<td class="image">
|
|
||||||
<div style="background-image:url('/favicon.png')"></div>
|
|
||||||
</td>
|
|
||||||
<td class="text">
|
|
||||||
<h1>Manual Scrobbling</h1><br/>
|
|
||||||
<br/><br/>
|
|
||||||
API Key: <input id='apikey' onchange='checkAPIkey()' style='width:300px;'/><br/><br/>
|
|
||||||
<span id="scrobbleresult"></span>
|
|
||||||
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<h1>Scrobble new discovery</h1>
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td style="padding-right:7px;">
|
|
||||||
Artists:
|
|
||||||
</td><td id="artists_td">
|
|
||||||
<input placeholder='Separate with Enter' class='simpleinput' id='artists' onKeydown='keyDetect(event)' />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="padding-right:7px;">
|
|
||||||
Title:
|
|
||||||
</td><td>
|
|
||||||
<input placeholder='Enter to scrobble' class='simpleinput' id='title' onKeydown='scrobbleIfEnter(event)' />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
<span class="button" onclick="scrobbleNew(event)">Scrobble!</span>
|
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h1>Search</h1>
|
|
||||||
|
|
||||||
<input class="simpleinput" placeholder='Search for a track' oninput='search_manualscrobbling(this)' />
|
|
||||||
<br/><br/>
|
|
||||||
<table id="searchresults"></table>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
Loading…
x
Reference in New Issue
Block a user