Added time selection for manual scrobbling, fix GH-221

This commit is contained in:
krateng 2023-08-11 20:23:47 +02:00
parent 759e88db3e
commit 174f096a05
2 changed files with 30 additions and 3 deletions

View File

@ -48,9 +48,24 @@
<input placeholder='Enter to scrobble' class='simpleinput' id='album' onKeydown='scrobbleIfEnter(event)' />
</td>
</tr>
<tr>
<td>
<input type="checkbox" id="use_custom_time" />
Custom Time:
</td>
<td>
<input id="scrobble_datetime" type="datetime-local">
</td>
</tr>
</table>
<script>
const now = new Date();
const localDateTime = new Date(now.getTime() - now.getTimezoneOffset() * 60000).toISOString().slice(0, 16);
document.getElementById("scrobble_datetime").value = localDateTime;
</script>
<br/>
<input type="checkbox" id="use_track_artists_for_album" checked='true' />

View File

@ -108,11 +108,20 @@ function scrobbleNew() {
var title = document.getElementById("title").value;
var album = document.getElementById("album").value;
if (document.getElementById("use_custom_time").checked) {
var date = new Date(document.getElementById("scrobble_datetime").value + ':00Z');
var timestamp = (date.getTime() + (date.getTimezoneOffset() * 60000)) / 1000;
}
else {
var timestamp = null;
}
scrobble(artists,title,albumartists,album);
scrobble(artists,title,albumartists,album,timestamp);
}
function scrobble(artists,title,albumartists,album) {
function scrobble(artists,title,albumartists,album,timestamp) {
lastArtists = artists;
lastTrack = title;
@ -125,7 +134,10 @@ function scrobble(artists,title,albumartists,album) {
"album": album
}
if (albumartists != null) {
payload['albumartists'] = albumartists
payload['albumartists'] = albumartists;
}
if (timestamp != null) {
payload['time'] = timestamp;
}
console.log(payload);