who up scrobbling

This commit is contained in:
Erica Z 2024-10-12 16:40:52 +00:00
parent 2c4e493833
commit bc8da35381
2 changed files with 13 additions and 0 deletions

View file

@ -204,6 +204,18 @@ public class Wavelet.Subsonic : Object {
this.unwrap_response (reader);
}
public async void scrobble (string id) throws Error {
var msg = new Soup.Message ("GET", @"$(this.url)/rest/scrobble?id=$(Uri.escape_string (id))&f=json&$(this.parameters)");
var bytes = yield this.session.send_and_read_async (msg, Priority.DEFAULT, null);
assert (msg.get_status () == Soup.Status.OK);
var parser = new Json.Parser ();
parser.load_from_data ((string) bytes.get_data ());
var reader = new Json.Reader (parser.get_root ());
this.unwrap_response (reader);
}
public async void get_random_songs (string? parameters, SongCallback callback) throws Error {
string str_parameters;
if (parameters == null) {

View file

@ -102,6 +102,7 @@ class Wavelet.Window : Adw.ApplicationWindow {
this.play_queue.now_playing.connect ((song) => {
this.playing = true;
this.song = song;
api.scrobble.begin (song.id);
});
this.play_queue.play_now.connect ((song) => {