who up scrobbling
This commit is contained in:
parent
2c4e493833
commit
bc8da35381
2 changed files with 13 additions and 0 deletions
12
src/api.vala
12
src/api.vala
|
@ -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) {
|
||||
|
|
|
@ -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) => {
|
||||
|
|
Loading…
Reference in a new issue