Moosic icon indicating copy to clipboard operation
Moosic copied to clipboard

Local files - !np throws an exception

Open pwhodges opened this issue 7 years ago • 2 comments

In the absence of instructions, I put some files in a subdirectory "local" of Moosic, and wrote their names in songs.txt in the form "local\filename.m4a" for instance (I'm on Windows Server).

Although a single file plays fine (and every format I've tried has worked), if I list more than one file the program processes them all (the number is correct), but then only the last one plays, and every attempt to play the others throws an exception "Invalid URI" (or something like). Is this a bug, or do I have to write something different in songs.txt?

Paul

pwhodges avatar Aug 30 '18 20:08 pwhodges

I misinterpreted something; it is the !np command which is causing the exception to be thrown, even when the file is tagged (though the tags are in Japanese).

pwhodges avatar Aug 31 '18 09:08 pwhodges

The code assumes that the uri is a YouTube URL. I simplified the output format and removed that assumption for my own use, replacing "onGuildMessageReceived" with:

    public void onGuildMessageReceived(GuildMessageReceivedEvent e) {
        if (e.getMessage().getContentRaw().toLowerCase().startsWith(Config.command_prefix.toLowerCase() + "np")) {
            AudioTrack PlayingTrack = Login.scheduler.player.getPlayingTrack();
            String trackUri = PlayingTrack.getInfo().uri;
            \\ if (trackUri.contains("\\")) trackUri = trackUri.substring(0, trackUri.lastIndexOf("\\"));
            e.getChannel().sendMessage(new EmbedBuilder()
                    .setColor(Color.GREEN)
                    .setDescription( "Track playing:   " + PlayingTrack.getInfo().title + "\n"
                                   + "Track progress:  " + String.format("`%s of %s`", this.getLength(PlayingTrack.getPosition()), this.getLength(PlayingTrack.getDuration()) ) + "\n"
                                   + "Track source:    " + trackUri)
                    .build()
            ).queue();
        }
    }

The commented line is for my Windows server, and removes the filename from a local file reference, leaving the folder name - which is the album name (it's within the Moosic directory, so no prefix is necessary). If it's not a local reference, then the uri is output, which Discord displays as a link without the Markdown syntax being necessary, as I don't use the abbreviated forms. There is a bug in the commented line, in that if the YouTube id includes a backslash, it will destroy it - this is not an issue for me!

pwhodges avatar Sep 06 '18 17:09 pwhodges