use of se.light.assembly64.model.PlaylistInfo in project assembly64fx by freabemania.
the class PlaylistService method addSong.
public void addSong(PlaylistInfo playlist, ContentEntry song) {
List<PlaylistEntry> entryAsList = new ArrayList<>();
entryAsList.add(song.getFullPlaylistInfo());
List<ContentEntry> contentEntries = new ArrayList<>();
contentEntries.add(new ContentEntry(song.getId(), song.getName()));
List<List<ContentEntry>> listOfListsOfContent = new ArrayList<>();
listOfListsOfContent.add(contentEntries);
addSongs(playlist, entryAsList, listOfListsOfContent);
}
use of se.light.assembly64.model.PlaylistInfo in project assembly64fx by freabemania.
the class PlaylistService method deleteSongs.
public void deleteSongs(PlaylistInfo playlist, List<PlaylistEntry> playlistEntry) {
StringKeys keys = StringKeys.of(playlistEntry.stream().map(item -> String.valueOf(item.getSongId())).collect(Collectors.toList()));
getClient().target(getBackendServer()).path("/leet/playlistsnew/deletesongs/" + playlist.getId()).request().header("email", getSessionInfo().getEmail()).header("token", getSessionInfo().getToken()).put(Entity.json(keys)).close();
List<PlaylistEntry> list = getSongsForPlaylist(playlist);
keys.getKeys().stream().forEach(item -> list.removeIf(entry -> entry.getSongId().equals(item)));
flushLocalList(playlist, list);
playlist.setChecksum(getChksum(list));
flushPlaylistInfo();
Analytics.sendEvent("sidify", "deletesong");
}
use of se.light.assembly64.model.PlaylistInfo in project assembly64fx by freabemania.
the class PlaylistService method createPlaylist.
public PlaylistInfo createPlaylist(String name, Boolean publicList) {
PlaylistInfo newPlaylist = getClient().target(server).path("/leet/playlistsnew/addplaylist/" + name + "/" + Boolean.toString(publicList)).request().header("email", email).header("token", token).get(PlaylistInfo.class);
playlists.add(newPlaylist);
flushLocalList(newPlaylist, new ArrayList<PlaylistEntry>());
flushPlaylistInfo();
Analytics.sendEvent("sidify", "createplaylist");
return newPlaylist;
}
use of se.light.assembly64.model.PlaylistInfo in project assembly64fx by freabemania.
the class PlaylistService method subscribeToPlaylist.
public PlaylistInfo subscribeToPlaylist(String id) {
if (!myPlaylistIds().contains(id)) {
PlaylistInfo newPlaylist = getClient().target(server).path("/leet/playlistsnew/subscribetoplaylist/" + id).request().header("email", email).header("token", token).get(PlaylistInfo.class);
newPlaylist.setMine(false);
newPlaylist.setPublicList(true);
playlists.add(newPlaylist);
flushPlaylistInfo();
Analytics.sendEvent("sidify", "subscribetoplaylist");
getSongsForPlaylist(newPlaylist);
return newPlaylist;
} else {
return getPlaylistInfo(id);
}
}
use of se.light.assembly64.model.PlaylistInfo in project assembly64fx by freabemania.
the class PlaylistService method mergePlaylists.
private void mergePlaylists() {
PlaylistChecksum serverChecksums = getChecksumsFromServer();
// get local list
List<PlaylistInfo> localPlayListInfo = getLocalPlaylistInfo();
long localPlaylistChksum = Support.getChksumPInfo(localPlayListInfo, false);
// get local public list
List<PlaylistInfo> localPublicPlayListInfo = getLocalPublicPlaylistInfo();
long localPublicPlaylistChksum = Support.getChksumPInfo(localPublicPlayListInfo, true);
if (!serverChecksums.getPrivateList().equals(localPlaylistChksum)) {
List<PlaylistInfo> playlistInfo = getPlaylistInfo();
playlists = playlistInfo;
flushPlaylistInfo(false, playlistInfo);
LOGGER.info("Refreshed and flushed private playlist");
} else {
playlists = localPlayListInfo;
LOGGER.info("Resolved local playlist with ok checksum");
}
if (!serverChecksums.getPublicList().equals(localPublicPlaylistChksum)) {
List<PlaylistInfo> remotePublicPlayListInfo = getPublicPlaylists();
flushPublicPlaylistInfo(remotePublicPlayListInfo);
LOGGER.info("Refreshed and flushed public playlist");
} else {
publicPlaylists = localPublicPlayListInfo;
LOGGER.info("Resolved public playlist with ok checksum");
}
}
Aggregations