Search in sources :

Example 16 with PlaylistInfo

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);
}
Also used : ContentEntry(se.light.assembly64.model.ContentEntry) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) Support.readList(se.light.assembly64.Support.readList) List(java.util.List) PlaylistEntry(se.light.assembly64.model.PlaylistEntry)

Example 17 with PlaylistInfo

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");
}
Also used : Support.isOffline(se.light.assembly64.Support.isOffline) ReturningTask(se.light.assembly64.model.ReturningTask) PlaylistEntry(se.light.assembly64.model.PlaylistEntry) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) Support.getBackendServer(se.light.assembly64.Support.getBackendServer) PlaylistInfo(se.light.assembly64.model.PlaylistInfo) ArrayList(java.util.ArrayList) Support.getSessionInfo(se.light.assembly64.Support.getSessionInfo) Support.getChksum(se.light.assembly64.Support.getChksum) ExecutorUtil.executeAsyncWithRetry(se.light.assembly64.util.ExecutorUtil.executeAsyncWithRetry) Map(java.util.Map) Support(se.light.assembly64.Support) PlaylistChecksum(se.light.assembly64.model.PlaylistChecksum) Support.flush(se.light.assembly64.Support.flush) ContentEntry(se.light.assembly64.model.ContentEntry) MD5Method(libsidplay.sidtune.MD5Method) Analytics(se.light.assembly64.Analytics) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) SidTune(libsidplay.sidtune.SidTune) SidFileInfo(se.light.assembly64.model.SidFileInfo) Support.getClient(se.light.assembly64.Support.getClient) Set(java.util.Set) FileUtils(org.apache.commons.io.FileUtils) Collectors(java.util.stream.Collectors) Entity(javax.ws.rs.client.Entity) File(java.io.File) Executors(java.util.concurrent.Executors) GenericType(javax.ws.rs.core.GenericType) Support.readList(se.light.assembly64.Support.readList) List(java.util.List) Response(javax.ws.rs.core.Response) Entry(java.security.KeyStore.Entry) Optional(java.util.Optional) StringKeys(se.light.assembly64.model.StringKeys) PlaylistEntry(se.light.assembly64.model.PlaylistEntry) StringKeys(se.light.assembly64.model.StringKeys)

Example 18 with PlaylistInfo

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;
}
Also used : PlaylistInfo(se.light.assembly64.model.PlaylistInfo) PlaylistEntry(se.light.assembly64.model.PlaylistEntry)

Example 19 with PlaylistInfo

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);
    }
}
Also used : PlaylistInfo(se.light.assembly64.model.PlaylistInfo)

Example 20 with PlaylistInfo

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");
    }
}
Also used : PlaylistChecksum(se.light.assembly64.model.PlaylistChecksum) PlaylistInfo(se.light.assembly64.model.PlaylistInfo)

Aggregations

PlaylistInfo (se.light.assembly64.model.PlaylistInfo)17 PlaylistEntry (se.light.assembly64.model.PlaylistEntry)14 ContentEntry (se.light.assembly64.model.ContentEntry)7 File (java.io.File)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 Collectors (java.util.stream.Collectors)4 ActionEvent (javafx.event.ActionEvent)4 ContextMenu (javafx.scene.control.ContextMenu)4 MenuItem (javafx.scene.control.MenuItem)4 PlaylistMenuItem (se.light.assembly64.model.PlaylistMenuItem)4 Set (java.util.Set)3 Executors (java.util.concurrent.Executors)3 Menu (javafx.scene.control.Menu)3 GenericType (javax.ws.rs.core.GenericType)3 SidTune (libsidplay.sidtune.SidTune)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 Analytics (se.light.assembly64.Analytics)3 Support (se.light.assembly64.Support)3