ready for cache implementations, started on get artist tracks
This commit is contained in:
parent
2bc9aff667
commit
fdac060b98
@ -1,4 +1,4 @@
|
|||||||
package sarsoo.fmframework.util.tagpool;
|
package sarsoo.fmframework.cache;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -132,8 +132,7 @@ public class FmUserNetwork extends FmNetwork {
|
|||||||
Artist artistObj = getArtist(track.getJSONObject("artist").getString("#text"));
|
Artist artistObj = getArtist(track.getJSONObject("artist").getString("#text"));
|
||||||
|
|
||||||
Track trackObj = getTrack(track.getString("name"), artistObj);
|
Track trackObj = getTrack(track.getString("name"), artistObj);
|
||||||
trackObj.setAlbum(getAlbum(track.getJSONObject("album").getString("#text"),
|
trackObj.setAlbum(getAlbum(track.getJSONObject("album").getString("#text"), artistObj));
|
||||||
artistObj));
|
|
||||||
|
|
||||||
return trackObj;
|
return trackObj;
|
||||||
|
|
||||||
@ -233,6 +232,49 @@ public class FmUserNetwork extends FmNetwork {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Artist getArtistTracks(String artistName) {
|
||||||
|
return getArtistTracks(getArtist(artistName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Artist getArtistTracks(Artist artist) {
|
||||||
|
|
||||||
|
Logger.getLog().log(new LogEntry("getArtistTracks").addArg(artist.getName()));
|
||||||
|
|
||||||
|
int limit = 50;
|
||||||
|
|
||||||
|
ArrayList<Scrobble> scrobbles = new ArrayList<Scrobble>();
|
||||||
|
|
||||||
|
Boolean done = false;
|
||||||
|
int counter = 1;
|
||||||
|
while (!done) {
|
||||||
|
|
||||||
|
HashMap<String, String> parameters = new HashMap<String, String>();
|
||||||
|
|
||||||
|
parameters.put("user", userName);
|
||||||
|
parameters.put("artist", artist.getName());
|
||||||
|
parameters.put("limit", Integer.toString(limit));
|
||||||
|
parameters.put("page", Integer.toString(counter + 1));
|
||||||
|
|
||||||
|
JSONObject obj = makeGetRequest("user.getartisttracks", parameters);
|
||||||
|
|
||||||
|
JSONArray returnedScrobbles = obj.getJSONObject("artisttracks").getJSONArray("track");
|
||||||
|
|
||||||
|
if (returnedScrobbles.length() > 0) {
|
||||||
|
|
||||||
|
for (int i = 0; i < returnedScrobbles.length(); i++) {
|
||||||
|
|
||||||
|
JSONObject scrob = returnedScrobbles.getJSONObject(i);
|
||||||
|
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public ArrayList<Scrobble> getRecentScrobbles(int number) {
|
public ArrayList<Scrobble> getRecentScrobbles(int number) {
|
||||||
|
|
||||||
Logger.getLog().log(new LogEntry("getRecentTracks").addArg(Integer.toString(number)));
|
Logger.getLog().log(new LogEntry("getRecentTracks").addArg(Integer.toString(number)));
|
||||||
|
@ -7,8 +7,8 @@ import java.util.Comparator;
|
|||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.scene.chart.PieChart;
|
import javafx.scene.chart.PieChart;
|
||||||
|
import sarsoo.fmframework.cache.TagPool;
|
||||||
import sarsoo.fmframework.util.FMObjList;
|
import sarsoo.fmframework.util.FMObjList;
|
||||||
import sarsoo.fmframework.util.tagpool.TagPool;
|
|
||||||
|
|
||||||
public class GenrePieChart extends PieChart{
|
public class GenrePieChart extends PieChart{
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ import javafx.event.ActionEvent;
|
|||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.stage.FileChooser;
|
import javafx.stage.FileChooser;
|
||||||
|
import sarsoo.fmframework.cache.TagPool;
|
||||||
import sarsoo.fmframework.file.ListPersister;
|
import sarsoo.fmframework.file.ListPersister;
|
||||||
import sarsoo.fmframework.fm.FmUserNetwork;
|
import sarsoo.fmframework.fm.FmUserNetwork;
|
||||||
import sarsoo.fmframework.fx.TextAreaConsole;
|
import sarsoo.fmframework.fx.TextAreaConsole;
|
||||||
@ -45,7 +46,6 @@ import sarsoo.fmframework.music.Track;
|
|||||||
import sarsoo.fmframework.net.Key;
|
import sarsoo.fmframework.net.Key;
|
||||||
import sarsoo.fmframework.util.FMObjList;
|
import sarsoo.fmframework.util.FMObjList;
|
||||||
import sarsoo.fmframework.util.Reference;
|
import sarsoo.fmframework.util.Reference;
|
||||||
import sarsoo.fmframework.util.tagpool.TagPool;
|
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.input.KeyCode;
|
import javafx.scene.input.KeyCode;
|
||||||
import javafx.scene.input.KeyEvent;
|
import javafx.scene.input.KeyEvent;
|
||||||
|
@ -8,10 +8,10 @@ import javafx.concurrent.Task;
|
|||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.scene.control.MenuItem;
|
import javafx.scene.control.MenuItem;
|
||||||
|
import sarsoo.fmframework.cache.TagPool;
|
||||||
import sarsoo.fmframework.fx.FmFramework;
|
import sarsoo.fmframework.fx.FmFramework;
|
||||||
import sarsoo.fmframework.fx.tab.FMObjListTab;
|
import sarsoo.fmframework.fx.tab.FMObjListTab;
|
||||||
import sarsoo.fmframework.music.Tag;
|
import sarsoo.fmframework.music.Tag;
|
||||||
import sarsoo.fmframework.util.tagpool.TagPool;
|
|
||||||
|
|
||||||
public class GetTagMenuItemsService extends Service<ArrayList<MenuItem>> {
|
public class GetTagMenuItemsService extends Service<ArrayList<MenuItem>> {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user