Search in sources :

Example 16 with PlaylistEntry

use of se.light.assembly64.model.PlaylistEntry 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 PlaylistEntry

use of se.light.assembly64.model.PlaylistEntry 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 PlaylistEntry

use of se.light.assembly64.model.PlaylistEntry 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 PlaylistEntry

use of se.light.assembly64.model.PlaylistEntry in project assembly64fx by freabemania.

the class PlaylistService method addTmpPlaylist.

public void addTmpPlaylist(List<PlaylistEntry> entries) {
    PlaylistInfo tmpEntry = new PlaylistInfo();
    tmpEntry.setName(TMP_PLAYLIST_ID);
    tmpEntry.setId(TMP_PLAYLIST_ID);
    playlistSongs.put(tmpEntry.getId(), entries);
    playlists.removeIf(item -> item.getId().equals(TMP_PLAYLIST_ID));
    playlists.add(tmpEntry);
}
Also used : PlaylistInfo(se.light.assembly64.model.PlaylistInfo)

Example 20 with PlaylistEntry

use of se.light.assembly64.model.PlaylistEntry in project assembly64fx by freabemania.

the class PlaylistService method addSongs.

public void addSongs(PlaylistInfo playlist, List<PlaylistEntry> entry, List<List<ContentEntry>> songs) {
    if (entry.size() != songs.size()) {
        throw new IllegalStateException("Bah!!!");
    }
    List<PlaylistEntry> entries = new ArrayList<>();
    Iterator<PlaylistEntry> entryLists = entry.iterator();
    Iterator<List<ContentEntry>> entryListsSongs = songs.iterator();
    while (entryLists.hasNext()) {
        PlaylistEntry pEntry = entryLists.next();
        List<ContentEntry> pSongs = entryListsSongs.next();
        for (ContentEntry song : pSongs) {
            if (song.getName().toLowerCase().endsWith(".sid")) {
                PlaylistEntry tmp = new PlaylistEntry(pEntry.getId(), pEntry.getCategory(), song.getId());
                tmp.setName(song.getName());
                if (song.getFullPlaylistInfo() != null) {
                    tmp.setGroup(song.getFullPlaylistInfo().getGroup());
                    tmp.setYear(song.getFullPlaylistInfo().getYear());
                }
                entries.add(tmp);
            }
        }
    }
    Executors.newSingleThreadExecutor().execute(() -> {
        List<PlaylistEntry> addedSongs = getClient().target(server).path("/leet/playlistsnew/addsongs/" + playlist.getId()).request().header("email", getSessionInfo().getEmail()).header("token", getSessionInfo().getToken()).post(Entity.json(entries), new GenericType<List<PlaylistEntry>>() {
        });
        List<PlaylistEntry> songsForPlaylist = getSongsForPlaylist(playlist);
        for (PlaylistEntry tmp1 : addedSongs) {
            for (PlaylistEntry tmp2 : songsForPlaylist) {
                if (tmp2.getSongId().equals(tmp1.getSongId())) {
                    tmp2.setGroup(tmp1.getGroup());
                    tmp2.setYear(tmp1.getYear());
                    tmp2.setName(tmp1.getName());
                    break;
                }
            }
        }
        flush(songsForPlaylist, resolvePlaylistFilename(playlist));
        playlist.setChecksum(getChksum(songsForPlaylist));
        Analytics.sendEvent("sidify", "addsongs");
    });
    List<PlaylistEntry> songsForPlaylist = getSongsForPlaylist(playlist);
    songsForPlaylist.addAll(entries);
    flush(songsForPlaylist, resolvePlaylistFilename(playlist));
    playlist.setChecksum(getChksum(songsForPlaylist));
    flushPlaylistInfo();
}
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)

Aggregations

PlaylistEntry (se.light.assembly64.model.PlaylistEntry)19 PlaylistInfo (se.light.assembly64.model.PlaylistInfo)11 File (java.io.File)9 ContentEntry (se.light.assembly64.model.ContentEntry)9 ArrayList (java.util.ArrayList)8 List (java.util.List)8 Collectors (java.util.stream.Collectors)6 Set (java.util.Set)5 Executors (java.util.concurrent.Executors)5 SidTune (libsidplay.sidtune.SidTune)5 SearchException (se.light.assembly64.model.SearchException)5 SongNotAvailableException (se.light.assembly64.model.SongNotAvailableException)5 SpecifyFileIdException (se.light.assembly64.model.SpecifyFileIdException)5 Comparator (java.util.Comparator)4 ChangeListener (javafx.beans.value.ChangeListener)4 ObservableValue (javafx.beans.value.ObservableValue)4 ActionEvent (javafx.event.ActionEvent)4 ContextMenu (javafx.scene.control.ContextMenu)4 Menu (javafx.scene.control.Menu)4 MenuItem (javafx.scene.control.MenuItem)4