plugins/code/lfmimporter.js @develop
var lfmImporter = function() {
var lfmi = null;
var offset = prefs.lfm_importer_start_offset;
var alloffset = 0;
var alldata = new Array();
var limit = 25;
var row;
var tracksdone = 0;
var totaltracks;
var starttime;
var errorTimer;
var running = false;
function getNextChunk() {
$.ajax({
url: 'plugins/code/lfmimporter.php',
type: "POST",
data: {action: 'getchunk', offset: offset, limit: limit},
dataType: 'json'
})
.done(putTracks)
.fail(function() {
infobar.error(language.gettext('label_general_error'));
});
}
function putTracks(data) {
alldata = data;
alloffset = 0;
if (data.length > 0) {
$('#lfmitable tr:not(:first-child)').remove();
debug.debug("LFMIMPORTER","Got data",data);
for (var i in data) {
var tr = $('<tr>', {name: data[i].TTindex}).appendTo('#lfmitable');
tr.append('<td class="playlistinfo underline" name="albumartist">'+data[i].Albumartist+'</td>');
tr.append('<td class="playlistinfo underline" name="Album">'+data[i].Albumname+'</td>');
tr.append('<td class="playlistinfo underline" name="Title">'+data[i].Title+'</td>');
tr.append('<td class="playlistinfo invisible" name="trackartist">'+data[i].Trackartist+'</td>');
tr.append('<td class="playlistinfo invisible" name="Track">'+data[i].TrackNo+'</td>');
tr.append('<td class="playlistinfo invisible" name="Disc">'+data[i].Disc+'</td>');
tr.append('<td class="underline" name="playcount">'+data[i].Playcount+'</td>');
tr.append('<td class="underline" name="lastfmplaycount"></td>');
tr.append('<td class="underline" name="tick"></td>');
}
offset += limit;
getNextRow();
} else {
debug.info("LFMIMPORTER","Got all data");
metaHandlers.resetSyncCounts();
}
}
function getNextRow() {
var data = cloneObject(alldata[alloffset]);
lastfm.track.getInfo( { artist: data.Albumartist, track: data.Title },
lfmResponseHandler,
lfmResponseHandler,
alloffset);
alloffset++;
}
function lfmResponseHandler(data, reqid) {
if (da...
The content has been truncated. see original