Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local files - !np throws an exception #25

Open
pwhodges opened this issue Aug 30, 2018 · 2 comments
Open

Local files - !np throws an exception #25

pwhodges opened this issue Aug 30, 2018 · 2 comments
Labels

Comments

@pwhodges
Copy link

pwhodges commented Aug 30, 2018

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
Copy link
Author

pwhodges commented Aug 31, 2018

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 pwhodges changed the title Local files - only works with a single file? Local files - !np throws an exception Aug 31, 2018
@pwhodges
Copy link
Author

pwhodges commented Sep 6, 2018

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!

@Repulser Repulser added the bug label Aug 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants