shipgirlproject / Shoukaku

A stable, powerful and updated wrapper around Lavalink
https://guide.shoukaku.shipgirl.moe/
MIT License
276 stars 86 forks source link

No matches found using ytsearch with query including special characters #96

Closed Hydro001 closed 2 years ago

Hydro001 commented 2 years ago

Description

Hi,

When using ytsearch with a query containing "é" or "à" or any "special" character, for exemple Annonces de Macron détaillées, députés accusés, trésor à 17 milliards d'€... Actus du jour, i get : No matches found and when looking at the request it replaces "é" with "Θ" for exemple, it replaces other special characters with other things too.

Error :

2022-06-25 23:58:07.312  INFO 13696 --- [  XNIO-1 task-1] l.server.player.AudioLoaderRestHandler   : Got request to load for identifier "ytsearch:Hugo DΘcrypte - Annonces de Macron dΘtaillΘes, dΘputΘs accusΘs, trΘsor α 17 milliards d'Ç... Actus du jour"
2022-06-25 23:58:07.533  INFO 13696 --- [ader-2-thread-1] lavalink.server.player.AudioLoader       : No matches found

Version info

Client used: Shoukaku v3.1.0 (Latest)

Output of java -version:

java version "17.0.2" 2022-01-18 LTS
Java(TM) SE Runtime Environment (build 17.0.2+8-LTS-86)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.2+8-LTS-86, mixed mode, sharing)

Output of java -jar Lavalink.jar --version:

Version:        4d005aa65d398ec9e494e9ea2f30221b3910b7df-SNAPSHOT
Build:          1365
Build time:     25.06.2022 13:57:44 UTC
Branch          master
Commit:         4d005aa
Commit time:    25.06.2022 13:52:17 UTC
JVM:            17.0.2
Lavaplayer      1.3.96-original
Deivu commented 2 years ago

Works on my side, Shoukaku properly serializes search queries using URLSearchParams, so this is either a lavalink issue, or an encoding issue on your side(?)

Relevant Logs:

022-06-26 18:55:28.211  INFO 3772 --- [ader-2-thread-1] lavalink.server.player.AudioLoader       : Loaded playlist Search music results for: Annonces de Macron dΘtaillΘes, dΘputΘs accusΘs, trΘsor α 17 milliards d'Ç... Actus du jour,
2022-06-26 18:55:29.061  INFO 3772 --- [   XNIO-1 I/O-7] lavalink.server.io.SocketServer          : {"op":"voiceUpdate","guildId":"450644221410410498","sessionId":"de21ab3f0debbfb61fecc3db17a914ec","event":{"endpoint":"hongkong1245.discord.media:443","guild_id":"450644221410410498","token":"6b1cdd82e1244282"}}
2022-06-26 18:55:29.066  INFO 3772 --- [   XNIO-1 I/O-7] lavalink.server.io.SocketServer          : {"op":"play","guildId":"450644221410410498","track":"QAAAlAIANEV4dHJhaXQgZGUgbGEgZMOpY2xhcmF0aW9uIGRlIFDDqXRhaW4gKDE3IGp1aW4gMTk0MCkABlBldGFpbgAAAAAAAqPIAAtoWGUtNUpxTzdEawABACtodHRwczovL3d3dy55b3V0dWJlLmNvbS93YXRjaD92PWhYZS01SnFPN0RrAAd5b3V0dWJlAAAAAAAAAAA=","noReplace":false,"pause":false}
2022-06-26 18:55:39.844  INFO 3772 --- [   XNIO-1 I/O-7] lavalink.server.io.SocketServer          : {"op":"destroy","guildId":"450644221410410498"}
Hydro001 commented 2 years ago

I'll try again with a fresh project and update the issue it it still isn't working, Though i have one question, why does lavalink replaces the special characters when outputing in the console ?

Deivu commented 2 years ago

It's kinda an issue in Java programs when the encoding is not properly set to UTF8. I remember having this similar issue on my Java project (which is not Lavalink) way before

Hydro001 commented 2 years ago

I have the following code which is in Node.js :

const Discord = require('discord.js');
const { Shoukaku, Connectors } = require('shoukaku');
const config = require('./config.json');
const Nodes = [{
    name: config.lavalink_name,
    url: `${config.lavalink_url}:${config.lavalink_port}`,
    auth: config.lavalink_auth
}];

const client = new Discord.Client({ 
    intents: [Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MESSAGES, Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Discord.Intents.FLAGS.GUILD_VOICE_STATES, Discord.Intents.FLAGS.GUILD_INTEGRATIONS ],
    partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
});
const shoukaku = new Shoukaku(new Connectors.DiscordJS(client), Nodes);

shoukaku.on('error', (_, error) => console.error(error));

client.on('ready', () => {
    console.log('Bot ready !');
});

client.on('messageCreate', async (message) => {
    const node = shoukaku.getNode();
    if (!node) return;
    const result = await node.rest.resolve(`ytsearch:"Annonces de Macron détaillées, députés accusés, trésor à 17 milliards d'€... Actus du jour"`);
});

client.login(config.bot_token);

And i get on the lavalink side :

2022-06-26 13:18:34.297  INFO 2096 --- [  XNIO-1 task-1] lavalink.server.io.SocketServer          : Connection successfully established from shoukakubot/3.1.2 (https://github.com/Deivu/Shoukaku)
2022-06-26 13:18:51.099  INFO 2096 --- [  XNIO-1 task-1] l.server.player.AudioLoaderRestHandler   : Got request to load for identifier "ytsearch:Annonces de Macron dΘtaillΘes, dΘputΘs accusΘs, trΘsor α 17 milliards d'Ç... Actus du jour"
2022-06-26 13:18:51.568  INFO 2096 --- [ader-2-thread-1] lavalink.server.player.AudioLoader       : No matches found

Using the latest version of Shoukaku which is 3.1.2 i believe.

I even opened an issue on both lavalink and lavaplayer and they said that it would come from the client i use which is Shoukaku, i even tried other clients (Poru) and it did the same.

And i finnaly did a request using Axios on the loadtracks endpoint and it shows me the same.

I'm honestly kinda lost on this and don't know how to solve the issue, lavalink says that the issue comes from the clients used and the clients says that it probably comes from Lavalink so i don't know what to do.

Deivu commented 2 years ago

I think this is an issue with your Lavalink and your server most likely, I don't do any modification on the raw query you pass to Shoukaku. Infact the reason why you do ytsearch:query now in v3 is to signify that what you pass here is on 1:1 ratio on what Lavalink receives. Nothing is modified. Now it means its very likely the Lavalink you are using is the one causing issues here. Now on your topic on why the Lavalink logs looks different on your query is because your Lavalink can't show the special character.

cc:

It's kinda an issue in Java programs when the encoding is not properly set to UTF8. I remember having this similar issue on my Java project (which is not Lavalink) way before

Hydro001 commented 2 years ago

Can you give me the Lavalink version your using, just to try, because if it still isn't working with the one you use it really means that the issue comes from me and not from lavalink or any clients.

Thank you

Deivu commented 2 years ago

I can't remember if I built this or I downloaded this but here is what I use in my dev enviroment

Version:        8ac9b9576910aabff7a683195cb1cd904bb59ee8-SNAPSHOT
Build:          1337
Build time:     26.01.2022 11:01:52 UTC
Branch          dev
Commit:         8ac9b95
Commit time:    26.01.2022 10:58:41 UTC
JVM:            13.0.2
Lavaplayer      1.3.97-original
Hydro001 commented 2 years ago

I found this version on the ci server but the jar doesn't seem to be there anymore, could you send me your jar ? Or tell me how you built it by yourself, never used gradle or maven.

Sorry for asking dumb stuff

Deivu commented 2 years ago

Clone the repo, call gradlew build or ./gradlew build depending on system

Hydro001 commented 2 years ago

I did but i get :

FAILURE: Build failed with an exception.

* What went wrong:
Could not open settings generic class cache for settings file 'C:\Users\Hydro\Downloads\Lavalink\settings.gradle' (C:\Users\Hydro\.gradle\caches\6.5\scripts\6gt1o4mpfcco114nd63sm1c55\settings6418c6d726070f323dbddda2aadc82ef).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 61

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
Deivu commented 2 years ago

Most of that could be fixed by googling, while I do give support for Lavalink, this is not the place for that. Since this already not involves the library Shoukaku. Try asking on my server OR lavalink server for that

Hydro001 commented 2 years ago

I understand, i will join your discord server and ask there then, thanks 👍