<commit_before>package com.bwfcwalshy.flarebot.music;

import com.arsenarsen.lavaplayerbridge.hooks.QueueHook;
import com.arsenarsen.lavaplayerbridge.player.Item;
import com.arsenarsen.lavaplayerbridge.player.Player;
import com.arsenarsen.lavaplayerbridge.player.Track;
import com.bwfcwalshy.flarebot.FlareBot;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;

import java.util.ArrayList;
import java.util.List;

public class QueueListener implements QueueHook {

    @Override
    public void execute(Player player, Item item) {
        List<Track> tracks = new ArrayList<>();
        if(item instanceof Track){
            tracks.add(new Track((AudioTrack) item));
            sendQueueData(tracks);
        }else if(item instanceof AudioPlaylist){
            ((AudioPlaylist) item).getTracks().forEach(track -> tracks.add(new Track(track)));
        }else{
            FlareBot.LOGGER.error("Unsupported item! " + item);
        }
    }

    private void sendQueueData(List<Track> tracks){
        JsonArray array = new JsonArray();
        for(Track t : tracks){
            JsonObject o = new JsonObject();
            o.addProperty("title", t.getTrack().getInfo().title);
            o.addProperty("length", t.getTrack().getDuration());
            o.addProperty("id", t.getTrack().getIdentifier());
            o.addProperty("requester", t.getMeta().getOrDefault("requester", "Unknown").toString());
            array.add(o);
        }
        System.out.println(array.toString());

        FlareBot.getInstance().postToApi("updatePlaylists", "playlist", array);
    }
}<commit_msg>* Push latest changes to the queue listener<commit_after>package com.bwfcwalshy.flarebot.music;

import com.arsenarsen.lavaplayerbridge.hooks.QueueHook;
import com.arsenarsen.lavaplayerbridge.player.Item;
import com.arsenarsen.lavaplayerbridge.player.Player;
import com.arsenarsen.lavaplayerbridge.player.Playlist;
import com.arsenarsen.lavaplayerbridge.player.Track;
import com.bwfcwalshy.flarebot.FlareBot;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;

import java.util.ArrayList;
import java.util.List;

public class QueueListener implements QueueHook {

    @Override
    public void execute(Player player, Item item) {
        List<Track> tracks = new ArrayList<>();
        if(item instanceof Playlist) {
            ((AudioPlaylist) item).getTracks().forEach(track -> tracks.add(new Track(track)));
        }else if(item instanceof Track){
            tracks.add((Track) item);
        }else{
            FlareBot.LOGGER.error("Unsupported item! " + item);
            return;
        }

        sendQueueData(tracks);
    }

    private void sendQueueData(List<Track> tracks){
        JsonArray array = new JsonArray();
        for(Track t : tracks){
            JsonObject o = new JsonObject();
            o.addProperty("title", t.getTrack().getInfo().title);
            o.addProperty("length", t.getTrack().getDuration());
            o.addProperty("id", t.getTrack().getIdentifier());
            o.addProperty("requester", t.getMeta().getOrDefault("requester", "Unknown").toString());
            array.add(o);
        }
        FlareBot.LOGGER.debug(array.toString());

        FlareBot.getInstance().postToApi("updatePlaylists", "playlist", array);
    }
}
{'fraction_non_alphanumeric': 0.1293746414228342, 'fraction_numerical': 0.0, 'mean_word_length': 3.310259579728059, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6815222', 'n_tokens_mistral': 1044, 'n_tokens_neox': 1033, 'n_words': 183}