1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Compare commits

...

3 Commits

Author SHA1 Message Date
krateng
0a4ac23dfa Fixed manual scrobbling of compilation albums 2023-05-07 22:49:50 +02:00
krateng
d5c457a2e9 Added albums to manual scrobbling 2023-05-07 18:27:14 +02:00
krateng
501984d04e Added option to show album art for tracks 2023-04-01 04:16:58 +02:00
5 changed files with 111 additions and 14 deletions

View File

@ -444,7 +444,7 @@ def post_scrobble(
artists:list=[],
title:str="",
album:str=None,
albumartists:list=[],
albumartists:list=None,
duration:int=None,
length:int=None,
time:int=None,
@ -478,7 +478,7 @@ def post_scrobble(
}
# for logging purposes, don't pass values that we didn't actually supply
rawscrobble = {k:rawscrobble[k] for k in rawscrobble if rawscrobble[k]}
rawscrobble = {k:rawscrobble[k] for k in rawscrobble if rawscrobble[k] is not None} # [] should be passed
result = database.incoming_scrobble(

View File

@ -134,6 +134,14 @@ resolve_semaphore = BoundedSemaphore(8)
def resolve_track_image(track_id):
if malojaconfig["USE_ALBUM_ARTWORK_FOR_TRACKS"]:
track = database.sqldb.get_track(track_id)
if "album" in track:
album_id = database.sqldb.get_album_id(track["album"])
albumart = resolve_album_image(album_id)
if albumart:
return albumart
with resolve_semaphore:
# check cache
result = get_image_from_cache(track_id,'tracks')

View File

@ -196,6 +196,7 @@ malojaconfig = Configuration(
"album_showcase":(tp.Boolean(), "Display Album Showcase", True, "Display a graphical album showcase for artist overview pages instead of a chart list"),
"display_art_icons":(tp.Boolean(), "Display Album/Artist Icons", True),
"default_album_artist":(tp.String(), "Default Albumartist", "Various Artists"),
"use_album_artwork_for_tracks":(tp.Boolean(), "Use Album Artwork for tracks", True),
"discourage_cpu_heavy_stats":(tp.Boolean(), "Discourage CPU-heavy stats", False, "Prevent visitors from mindlessly clicking on CPU-heavy options. Does not actually disable them for malicious actors!"),
"use_local_images":(tp.Boolean(), "Use Local Images", True),
#"local_image_rotate":(tp.Integer(), "Local Image Rotate", 3600),

View File

@ -4,6 +4,14 @@
{% block scripts %}
<script src="/manualscrobble.js"></script>
<style>
.tooltip {
cursor: help;
}
.tooltip:hover {
text-decoration: underline dotted;
}
</style>
{% endblock %}
@ -26,14 +34,34 @@
<input placeholder='Enter to scrobble' class='simpleinput' id='title' onKeydown='scrobbleIfEnter(event)' />
</td>
</tr>
<tr>
<td style="padding-right:7px;">
Album artists (Optional):
</td><td id="albumartists_td">
<input placeholder='Separate with Enter' class='simpleinput' id='albumartists' onKeydown='keyDetect2(event)' onblur='addEnteredAlbumartist()' />
</td>
</tr>
<tr>
<td style="padding-right:7px;">
Album (Optional):
</td><td>
<input placeholder='Enter to scrobble' class='simpleinput' id='album' onKeydown='scrobbleIfEnter(event)' />
</td>
</tr>
</table>
<br/>
<input type="checkbox" id="use_track_artists_for_album" checked='true' />
<span class="tooltip" title="If this is unchecked, specifying no album artists will result in a compilation album ('Various Artists')">Use track artists as album artists fallback</span>
<br/><br/>
<button type="button" onclick="scrobbleNew(event)">Scrobble!</button>
<button type="button" onclick="repeatLast()">↻</button>
<br/>

View File

@ -1,5 +1,7 @@
var lastArtists = []
var lastTrack = ""
var lastArtists = [];
var lastTrack = "";
var lastAlbumartists = [];
var lastAlbum = "";
function addArtist(artist) {
@ -10,11 +12,23 @@ function addArtist(artist) {
document.getElementById("artists_td").insertBefore(artistelement,newartistfield);
newartistfield.placeholder = "Backspace to remove last"
}
function addAlbumartist(artist) {
var newartistfield = document.getElementById("albumartists");
var artistelement = document.createElement("span");
artistelement.innerHTML = artist;
artistelement.style = "padding:5px;";
document.getElementById("albumartists_td").insertBefore(artistelement,newartistfield);
newartistfield.placeholder = "Backspace to remove last"
}
function keyDetect(event) {
if (event.key === "Enter" || event.key === "Tab") { addEnteredArtist() }
if (event.key === "Backspace" && document.getElementById("artists").value == "") { removeArtist() }
}
function keyDetect2(event) {
if (event.key === "Enter" || event.key === "Tab") { addEnteredAlbumartist() }
if (event.key === "Backspace" && document.getElementById("albumartists").value == "") { removeAlbumartist() }
}
function addEnteredArtist() {
var newartistfield = document.getElementById("artists");
@ -24,6 +38,14 @@ function addEnteredArtist() {
addArtist(newartist);
}
}
function addEnteredAlbumartist() {
var newartistfield = document.getElementById("albumartists");
var newartist = newartistfield.value.trim();
newartistfield.value = "";
if (newartist != "") {
addAlbumartist(newartist);
}
}
function removeArtist() {
var artists = document.getElementById("artists_td").getElementsByTagName("span")
var lastartist = artists[artists.length-1]
@ -32,14 +54,28 @@ function removeArtist() {
document.getElementById("artists").placeholder = "Separate with Enter"
}
}
function removeAlbumartist() {
var artists = document.getElementById("albumartists_td").getElementsByTagName("span")
var lastartist = artists[artists.length-1]
document.getElementById("albumartists_td").removeChild(lastartist);
if (artists.length < 1) {
document.getElementById("albumartists").placeholder = "Separate with Enter"
}
}
function clear() {
document.getElementById("title").value = "";
document.getElementById("artists").value = "";
document.getElementById("album").value = "";
document.getElementById("albumartists").value = "";
var artists = document.getElementById("artists_td").getElementsByTagName("span")
while (artists.length > 0) {
removeArtist();
}
var albumartists = document.getElementById("albumartists_td").getElementsByTagName("span")
while (albumartists.length > 0) {
removeAlbumartist();
}
}
@ -55,31 +91,51 @@ function scrobbleNew() {
for (let node of artistnodes) {
artists.push(node.textContent);
}
var albumartistnodes = document.getElementById("albumartists_td").getElementsByTagName("span");
var albumartists = [];
for (let node of albumartistnodes) {
albumartists.push(node.textContent);
}
if (albumartists.length == 0) {
var use_track_artists = document.getElementById('use_track_artists_for_album').checked;
if (use_track_artists) {
albumartists = null;
}
}
var title = document.getElementById("title").value;
scrobble(artists,title);
var album = document.getElementById("album").value;
scrobble(artists,title,albumartists,album);
}
function scrobble(artists,title) {
function scrobble(artists,title,albumartists,album) {
lastArtists = artists;
lastTrack = title;
lastAlbum = album;
lastAlbumartists = albumartists;
var payload = {
"artists":artists,
"title":title
"title":title,
"album": album
}
if (albumartists != null) {
payload['albumartists'] = albumartists
}
console.log(payload);
if (title != "" && artists.length > 0) {
neo.xhttpreq("/apis/mlj_1/newscrobble",data=payload,method="POST",callback=notifyCallback,json=true)
}
document.getElementById("title").value = "";
document.getElementById("artists").value = "";
var artists = document.getElementById("artists_td").getElementsByTagName("span");
while (artists.length > 0) {
removeArtist();
}
clear()
}
function scrobbledone(req) {
@ -98,6 +154,10 @@ function repeatLast() {
addArtist(artist);
}
document.getElementById("title").value = lastTrack;
for (let artist of lastAlbumartists) {
addAlbumartist(artist);
}
document.getElementById("album").value = lastAlbum;
}