diff --git a/app/controllers/last_fm_controller.rb b/app/controllers/last_fm_controller.rb index a9accb0..8953c90 100644 --- a/app/controllers/last_fm_controller.rb +++ b/app/controllers/last_fm_controller.rb @@ -47,7 +47,7 @@ class LastFmController < ApplicationController return unless authorized? @res = {} - if params[:artist].nil? or params[:track].nil? + if params[:artist].nil? or params[:album].nil? or params[:track].nil? render :json => {:status => 'bad params'} return end @@ -70,7 +70,7 @@ class LastFmController < ApplicationController return unless authorized? @res = {} - if params[:artist].nil? or params[:track].nil? + if params[:artist].nil? or params[:album].nil? or params[:track].nil? render :json => {:status => 'bad params'} return end @@ -83,7 +83,7 @@ class LastFmController < ApplicationController lastfm = Lastfm.new(@@api_key, @@secret) lastfm.session = user.lastfm_key - r = lastfm.track.scrobble(params[:artist], params[:track], nil, Time.now.utc.to_i) + r = lastfm.track.scrobble(params[:artist], params[:track], params[:album], Time.now.utc.to_i) render :json => {:status => r ? 'success' : 'failed', time: Time.now.utc} return diff --git a/public/js/beathaven/player.js b/public/js/beathaven/player.js index ed8e9af..303cff0 100644 --- a/public/js/beathaven/player.js +++ b/public/js/beathaven/player.js @@ -28,8 +28,8 @@ var Player = { this.jp.bind($.jPlayer.event.timeupdate, function(e){ data = e.jPlayer.status; if (!Player.scrobbled && data.currentPercentAbsolute > 50) { - var tmp = $('#player .now-playing').text().split(' — '); - Player.scrobble(tmp[0], tmp[1]); + var $obj = $('.playlist-tracks li.now'); + Player.scrobble($obj.attr('data-artist'), $obj.attr('data-album'), $obj.attr('data-track')); Player.scrobbled = true; } $('#player .progress .loaded').width(data.seekPercent * Player.bar_width / 100); @@ -40,10 +40,13 @@ var Player = { }); }, - addTrack: function(artist, track, length) { + addTrack: function(artist, album, track, length, autoplay) { + if (typeof autoplay === 'undefined') { + autoplay = false; + } var initial_count = $('.playlist-tracks li').length; $('.playlist-tracks').append('\ -