add: last.fm status integration
This commit is contained in:
parent
3e2bdceb99
commit
0765156697
17 changed files with 397 additions and 3 deletions
|
@ -381,6 +381,37 @@ macros -%}
|
|||
}
|
||||
}, 150);
|
||||
</script>
|
||||
{% elif user and user.connections.LastFm and
|
||||
config.connections.last_fm_key and
|
||||
user.connections.LastFm[0].data.session_token %}
|
||||
<script>
|
||||
setTimeout(async () => {
|
||||
if (window.last_fm_init) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.last_fm_init = true;
|
||||
const user = "{{ user.connections.LastFm[0].data.name }}";
|
||||
const session_token =
|
||||
"{{ user.connections.LastFm[0].data.session_token }}";
|
||||
|
||||
if (session_token) {
|
||||
// we already have a token
|
||||
const pull_playing = async () => {
|
||||
const playing = await trigger("last_fm::get_playing", [
|
||||
user,
|
||||
session_token,
|
||||
]);
|
||||
await trigger("last_fm::publish_playing", [playing]);
|
||||
};
|
||||
|
||||
await pull_playing();
|
||||
setInterval(pull_playing, 30_000);
|
||||
} else {
|
||||
window.last_fm_needs_token = true;
|
||||
}
|
||||
}, 150);
|
||||
</script>
|
||||
{% endif %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue