added artist scrobble getting
This commit is contained in:
parent
d9fb9195f9
commit
f9b81093db
@ -4,6 +4,7 @@ import java.text.NumberFormat;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -49,8 +50,13 @@ public class ScrobblesViewPaneController {
|
|||||||
@FXML
|
@FXML
|
||||||
private CheckBox checkBoxCumulative;
|
private CheckBox checkBoxCumulative;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private CheckBox checkBoxTotal;
|
||||||
|
|
||||||
private FMObj obj;
|
private FMObj obj;
|
||||||
|
|
||||||
|
private List<Scrobble> scrobbles;
|
||||||
|
|
||||||
private LocalDate firstDate;
|
private LocalDate firstDate;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
@ -63,10 +69,19 @@ public class ScrobblesViewPaneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void populate(FMObj obj) {
|
public void populate(FMObj obj) {
|
||||||
|
|
||||||
this.obj = obj;
|
this.obj = obj;
|
||||||
|
this.scrobbles = obj.getScrobbles();
|
||||||
|
populate();
|
||||||
|
}
|
||||||
|
|
||||||
ArrayList<Scrobble> scrobbles = obj.getScrobbles();
|
public void populate(ArrayList<Scrobble> scrobbles) {
|
||||||
|
this.scrobbles = scrobbles;
|
||||||
|
populate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populate() {
|
||||||
|
|
||||||
|
scrobbles.sort(Comparator.comparing(Scrobble::getDateTime).reversed());
|
||||||
|
|
||||||
if (scrobbles != null) {
|
if (scrobbles != null) {
|
||||||
if (scrobbles.size() > 0) {
|
if (scrobbles.size() > 0) {
|
||||||
@ -115,7 +130,7 @@ public class ScrobblesViewPaneController {
|
|||||||
|
|
||||||
ScrobbleCountCalendar totalCalendar = new ScrobbleCountCalendar(firstDate, "total");
|
ScrobbleCountCalendar totalCalendar = new ScrobbleCountCalendar(firstDate, "total");
|
||||||
|
|
||||||
for (Scrobble scrobble : obj.getScrobbles()) {
|
for (Scrobble scrobble : scrobbles) {
|
||||||
|
|
||||||
Boolean needNew = true;
|
Boolean needNew = true;
|
||||||
|
|
||||||
@ -145,7 +160,7 @@ public class ScrobblesViewPaneController {
|
|||||||
List<ScrobbleCountCalendar> toShow = list.stream().map(FMObjCalendarWrapper::getCalendar)
|
List<ScrobbleCountCalendar> toShow = list.stream().map(FMObjCalendarWrapper::getCalendar)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (list.size() > 1) {
|
if (list.size() > 1 && checkBoxTotal.isSelected()) {
|
||||||
toShow.add(totalCalendar);
|
toShow.add(totalCalendar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +174,7 @@ public class ScrobblesViewPaneController {
|
|||||||
|
|
||||||
ScrobbleCountCalendar totalCalendar = new ScrobbleCountCalendar(firstDate, "total");
|
ScrobbleCountCalendar totalCalendar = new ScrobbleCountCalendar(firstDate, "total");
|
||||||
|
|
||||||
for (Scrobble scrobble : obj.getScrobbles()) {
|
for (Scrobble scrobble : scrobbles) {
|
||||||
|
|
||||||
Boolean needNew = true;
|
Boolean needNew = true;
|
||||||
|
|
||||||
@ -189,7 +204,7 @@ public class ScrobblesViewPaneController {
|
|||||||
List<ScrobbleCountCalendar> toShow = list.stream().map(FMObjCalendarWrapper::getCalendar)
|
List<ScrobbleCountCalendar> toShow = list.stream().map(FMObjCalendarWrapper::getCalendar)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (list.size() > 1) {
|
if (list.size() > 1 && checkBoxTotal.isSelected()) {
|
||||||
toShow.add(totalCalendar);
|
toShow.add(totalCalendar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +218,7 @@ public class ScrobblesViewPaneController {
|
|||||||
|
|
||||||
ScrobbleCountCalendar totalCalendar = new ScrobbleCountCalendar(firstDate, "total");
|
ScrobbleCountCalendar totalCalendar = new ScrobbleCountCalendar(firstDate, "total");
|
||||||
|
|
||||||
for (Scrobble scrobble : obj.getScrobbles()) {
|
for (Scrobble scrobble : scrobbles) {
|
||||||
|
|
||||||
Boolean needNew = true;
|
Boolean needNew = true;
|
||||||
|
|
||||||
@ -221,7 +236,7 @@ public class ScrobblesViewPaneController {
|
|||||||
|
|
||||||
if (needNew) {
|
if (needNew) {
|
||||||
|
|
||||||
ScrobbleCountCalendar calendar = new ScrobbleCountCalendar(firstDate, scrobble.getAlbum().getName());
|
ScrobbleCountCalendar calendar = new ScrobbleCountCalendar(firstDate, scrobble.getTrack().getName() + " / " + scrobble.getAlbum().getName());
|
||||||
|
|
||||||
calendar.addCount(scrobbleDate.getMonth(), scrobbleDate.getYear());
|
calendar.addCount(scrobbleDate.getMonth(), scrobbleDate.getYear());
|
||||||
|
|
||||||
@ -234,7 +249,7 @@ public class ScrobblesViewPaneController {
|
|||||||
List<ScrobbleCountCalendar> toShow = list.stream().map(FMObjCalendarWrapper::getCalendar)
|
List<ScrobbleCountCalendar> toShow = list.stream().map(FMObjCalendarWrapper::getCalendar)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (list.size() > 1) {
|
if (list.size() > 1 && checkBoxTotal.isSelected()) {
|
||||||
toShow.add(totalCalendar);
|
toShow.add(totalCalendar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import java.awt.Desktop;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.concurrent.Service;
|
import javafx.concurrent.Service;
|
||||||
@ -17,6 +18,9 @@ import sarsoo.fmframework.fm.FmUserNetwork;
|
|||||||
import sarsoo.fmframework.fx.FmFramework;
|
import sarsoo.fmframework.fx.FmFramework;
|
||||||
import sarsoo.fmframework.fx.controller.info.ArtistPaneController;
|
import sarsoo.fmframework.fx.controller.info.ArtistPaneController;
|
||||||
import sarsoo.fmframework.music.Artist;
|
import sarsoo.fmframework.music.Artist;
|
||||||
|
import sarsoo.fmframework.music.Scrobble;
|
||||||
|
import sarsoo.fmframework.music.Track;
|
||||||
|
import sarsoo.fmframework.util.FMObjList;
|
||||||
|
|
||||||
public class ArtistBorderPaneController extends FMObjBorderPaneController{
|
public class ArtistBorderPaneController extends FMObjBorderPaneController{
|
||||||
|
|
||||||
@ -92,11 +96,25 @@ public class ArtistBorderPaneController extends FMObjBorderPaneController{
|
|||||||
|
|
||||||
artist = FmFramework.getArtistPool().getNew(artist);
|
artist = FmFramework.getArtistPool().getNew(artist);
|
||||||
|
|
||||||
|
Config config = FmFramework.getSessionConfig();
|
||||||
|
FmUserNetwork net = new FmUserNetwork(config.getValue("api_key"), config.getValue("username"));
|
||||||
|
|
||||||
|
FMObjList topTracks = net.getArtistTopTracks(artist, 10);
|
||||||
|
|
||||||
|
ArrayList<Scrobble> scrobbles = new ArrayList<>();
|
||||||
|
|
||||||
|
topTracks.stream().forEach(t -> {
|
||||||
|
|
||||||
|
scrobbles.addAll(net.getTrackScrobbles((Track) t));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
Platform.runLater(new Runnable() {
|
Platform.runLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
infoPaneController.refresh(artist);
|
infoPaneController.refresh(artist);
|
||||||
|
scrobblePaneController.populate(scrobbles);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -32,14 +32,19 @@ public class ScrobbleCountCalendar {
|
|||||||
|
|
||||||
public void addCount(Month monthIn, int year) {
|
public void addCount(Month monthIn, int year) {
|
||||||
|
|
||||||
|
Boolean found = false;
|
||||||
|
|
||||||
for (MonthScrobbles month : months) {
|
for (MonthScrobbles month : months) {
|
||||||
if (month.getMonth().getValue() == monthIn.getValue() && year == month.getYear()) {
|
if (month.getMonth().getValue() == monthIn.getValue() && year == month.getYear()) {
|
||||||
month.addCount();
|
month.addCount();
|
||||||
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.getLog().logError(new ErrorEntry("ScrobbleCountCalendar").addArg("add count").addArg("month not found"));
|
if (found == false)
|
||||||
|
Logger.getLog().logError(new ErrorEntry("ScrobbleCountCalendar").addArg("add count")
|
||||||
|
.addArg("month not found").addArg(monthIn.toString()).addArg(Integer.toString(year)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
<Button fx:id="buttonAlbums" mnemonicParsing="false" onAction="#handleShowAlbums" text="albums" />
|
<Button fx:id="buttonAlbums" mnemonicParsing="false" onAction="#handleShowAlbums" text="albums" />
|
||||||
<Button fx:id="buttonTracksAlbums" mnemonicParsing="false" onAction="#handleShowTracksByAlbums" text="tracks & albums" />
|
<Button fx:id="buttonTracksAlbums" mnemonicParsing="false" onAction="#handleShowTracksByAlbums" text="tracks & albums" />
|
||||||
<CheckBox fx:id="checkBoxCumulative" mnemonicParsing="false" selected="true" text="cumulative" />
|
<CheckBox fx:id="checkBoxCumulative" mnemonicParsing="false" selected="true" text="cumulative" />
|
||||||
|
<CheckBox fx:id="checkBoxTotal" mnemonicParsing="false" selected="true" text="show total" />
|
||||||
</items>
|
</items>
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
</bottom>
|
</bottom>
|
||||||
|
Loading…
Reference in New Issue
Block a user